{
"info": {
"author": "Karl N. Redman",
"author_email": "karl.redman@gmail.com",
"bugtrack_url": null,
"classifiers": [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3"
],
"description": "# Batch Edit Yaml Front Matter\n\nEdit front matter markdown files with Jinja2 templates.\n\n## Description:\n\nThis is a `python3` (v3.5.3+) class/module that can be used for batch processing and
\nediting front matter in markdown files. Front matter is managed via
\n[Jinja2](http://jinja.pocoo.org/) template processor.\n\n## Features:\n\n* Add / Update / Delete any front matter fields\n* Preserves front matter element order via [oyaml](https://github.com/wimglenn/oyaml)\n* Uses [Jinja2](http://jinja.pocoo.org/) Templates for configuration and processing:\n * Use Jinja2 filters for complex processing\n * Incrementally process files with multiple templates\n* Uses Exceptions around sensitive areas of code\n* Examples for implementation:\n 1. [Basic usage](https://karlredman.github.io/EditFrontMatter/examples/example1/readme.html)\n 2. [Advanced mulit-pass processor](https://karlredman.github.io/EditFrontMatter/examples/example2/readme.html)\n 3. [Recursive directory walker that uses multi-threading to edit files](https://karlredman.github.io/EditFrontMatter/examples/example3/readme.html)\n* Documented with [Sphinx](https://www.sphinx-doc.org/en/master/) and [hosted on Github](https://karlredman.github.io/EditFrontMatter)\n\n## Documentation:\n\n* [Project Documentation with examples Page](https://karlredman.github.io/EditFrontMatter/)\n\n# Installation:\n\n```sh\npip install editfrontmatter\n```\n\n## TL;DR Example Usage:\n\n* Original markdown file with yaml front matter ([example1.md](https://github.com/karlredman/EditFrontMatter/blob/master/examples/data/example1.md))\n\n```md\n---\ntitle: \"EditFrontMatter Class Example 1\"\ndescription: \"Edit 2 fields in this front matter\"\ncatagories: [programming, python, markdown]\n\ndeleteme: this will be deleted\n\ntags: [front matter, administration, testing]\n\n# comments and spaces will be eliminated (see docs)\n\nauthor: \"Karl N. Redman\"\ncreatordisplayname: \"Karl N. Redman\"\ncreatoremail: \"karl.redman@example.com\"\ndate: 2019-05-23T17:43:45-05:00\nlastmodifierdisplayname: \"Karl N. Redman\"\nlastmodifieremail: \"karl.redman@gmail.com\"\nlastmod: 2019-05-23T17:43:45-05:00\ntoc: false\ntype: \"page\"\nhasMath: false\ndraft: false\nweight: 5\n---\n\n# EditFontMatter Class Example 1\n\nEdit several fields of front matter.\n\n## Fields affected in this example:\n\n* toc\n * note: uses local template variable\n * pre: false\n * post: true\n* draft:\n * note: uses jinja2 filter (callback)\n * pre: false\n * post: true\n* hasMath\n * note: uses program variable\n * pre: true\n * post: false\n* stuff:\n * note: uses program variable to create field\n * pre: did not exist\n * post: (list) ['one', 'two', 'three']\n* deleteme:\n * note: removed from final result\n * pre: this will be deleted\n * post: N/A\n```\n\n* Jinja2 template that will update the front matter data of the source markdown file ([template1.j2](https://github.com/karlredman/EditFrontMatter/blob/master/examples/data/template1.j2))\n\n```jinja\n{% set toc = \"true\" %}\n\ntoc: {{ toc }}\ndraft: {{ false | canPublish }}\nhasMath: {{ hasMath }}\nstuff: {{ addedVariable }}\n```\n\n* Python program to edit the markdown file with the Jinja2 template ([example1.py](https://github.com/karlredman/EditFrontMatter/blob/master/examples/example1/example1.py))\n\n```py\n#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\n\nfrom editfrontmatter import EditFrontMatter\nimport os\n\n\ndef canPublish_func(val):\n # do some processing....\n return True\n\n\ndef main():\n\n # generic path - overridden by env var `TEST_DATA_DIR`\n DATA_PATH = \"../data/\"\n\n if \"TEST_DATA_DIR\" in os.environ:\n DATA_PATH = os.path.abspath(os.environ.get(\"TEST_DATA_DIR\")) + \"/\"\n\n # set path to input file\n file_path = os.path.abspath(DATA_PATH + \"example1.md\")\n\n # initialize `template_str` with template file content\n template_str = ''.join(open(os.path.abspath(DATA_PATH + \"template1.j2\"), \"r\").readlines())\n print(template_str)\n\n # instantiate the processor\n proc = EditFrontMatter(file_path=file_path, template_str=template_str)\n\n # set fields to delete from yaml\n proc.keys_toDelete = ['deleteme']\n\n # add a filter and callback function\n proc.add_JinjaFilter('canPublish', canPublish_func)\n\n # populate variables and run processor\n proc.run({'toc': 'no effect', 'hasMath': \"false\",\n 'addedVariable': ['one', 'two', 'three']})\n\n # dump file\n print(proc.dumpFileData())\n\n\nif __name__ == '__main__':\n main()\n\n```\n\n\n* Final Output:\n\n```md\n---\ntitle: EditFrontMatter Class Example 1\ndescription: Edit 2 fields in this front matter\ncatagories:\n- programming\n- python\n- markdown\ntags:\n- front matter\n- administration\n- testing\nauthor: Karl N. Redman\ncreatordisplayname: Karl N. Redman\ncreatoremail: karl.redman@example.com\ndate: 2019-05-23 22:43:45\nlastmodifierdisplayname: Karl N. Redman\nlastmodifieremail: karl.redman@gmail.com\nlastmod: 2019-05-23 22:43:45\ntoc: true\ntype: page\nhasMath: false\ndraft: true\nweight: 5\nstuff:\n- one\n- two\n- three\n---\n\n# EditFontMatter Class Example 1\n\nEdit several fields of front matter.\n\n## Fields affected in this example:\n\n* toc\n * note: uses local template variable\n * pre: false\n * post: true\n* draft:\n * note: uses jinja2 filter (callback)\n * pre: false\n * post: true\n* hasMath\n * note: uses program variable\n * pre: true\n * post: false\n* stuff:\n * note: uses program variable to create field\n * pre: did not exist\n * post: (list) ['one', 'two', 'three']\n* deleteme:\n * note: removed from final result\n * pre: this will be deleted\n * post: N/A\n```\n\n\n",
"description_content_type": "text/markdown",
"docs_url": null,
"download_url": "",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://karlredman.github.io/EditFrontMatter",
"keywords": "jinja2 markdown front-matter",
"license": "",
"maintainer": "",
"maintainer_email": "",
"name": "editfrontmatter",
"package_url": "https://pypi.org/project/editfrontmatter/",
"platform": "",
"project_url": "https://pypi.org/project/editfrontmatter/",
"project_urls": {
"Documentation": "https://karlredman.github.io/EditFrontMatter",
"Homepage": "https://karlredman.github.io/EditFrontMatter",
"Source Code": "http://github.com/karlredman/EditFrontMatter"
},
"release_url": "https://pypi.org/project/editfrontmatter/0.0.1/",
"requires_dist": [
"jinja2",
"oyaml"
],
"requires_python": ">=3.5.3",
"summary": "Edit front matter with Jinja2 templates",
"version": "0.0.1"
},
"last_serial": 5377584,
"releases": {
"0.0.1": [
{
"comment_text": "",
"digests": {
"md5": "66a2933fb0f0aa9b15047d70c2af49a9",
"sha256": "323e1e729e361b77b02f94fdfadd566f4b4e552d7fb2864c9dad78738fca50b0"
},
"downloads": -1,
"filename": "editfrontmatter-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "66a2933fb0f0aa9b15047d70c2af49a9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.5.3",
"size": 8945,
"upload_time": "2019-06-09T12:23:00",
"url": "https://files.pythonhosted.org/packages/18/81/c4d808ce3d9ebb5bcb2ebdd88c3e14eef1f7b20d4d38bb3ef3244c99cd42/editfrontmatter-0.0.1-py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "1d2f99c1cf4eb0888180f0c2f61acbc1",
"sha256": "aefb2d584e1ca380bbfff2bcb069f82a8ee59cfb875558c3d7a6c18a2bf3f04e"
},
"downloads": -1,
"filename": "editfrontmatter-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "1d2f99c1cf4eb0888180f0c2f61acbc1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.5.3",
"size": 7767,
"upload_time": "2019-06-09T12:23:02",
"url": "https://files.pythonhosted.org/packages/51/85/1d02aa4fc89425ff295604898fd4f6315eaa4b9f0eb5250faa99ee7c6905/editfrontmatter-0.0.1.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "66a2933fb0f0aa9b15047d70c2af49a9",
"sha256": "323e1e729e361b77b02f94fdfadd566f4b4e552d7fb2864c9dad78738fca50b0"
},
"downloads": -1,
"filename": "editfrontmatter-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "66a2933fb0f0aa9b15047d70c2af49a9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.5.3",
"size": 8945,
"upload_time": "2019-06-09T12:23:00",
"url": "https://files.pythonhosted.org/packages/18/81/c4d808ce3d9ebb5bcb2ebdd88c3e14eef1f7b20d4d38bb3ef3244c99cd42/editfrontmatter-0.0.1-py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "1d2f99c1cf4eb0888180f0c2f61acbc1",
"sha256": "aefb2d584e1ca380bbfff2bcb069f82a8ee59cfb875558c3d7a6c18a2bf3f04e"
},
"downloads": -1,
"filename": "editfrontmatter-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "1d2f99c1cf4eb0888180f0c2f61acbc1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.5.3",
"size": 7767,
"upload_time": "2019-06-09T12:23:02",
"url": "https://files.pythonhosted.org/packages/51/85/1d02aa4fc89425ff295604898fd4f6315eaa4b9f0eb5250faa99ee7c6905/editfrontmatter-0.0.1.tar.gz"
}
]
}