{ "info": { "author": "Nino Walker", "author_email": "nino.walker@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: BSD License" ], "description": "\n# Pyyacc\n\nPython implementation of a Yet Another Configuration Compiler.\n\n## Why? What about INI, XML, JSON, or plain Python?\n\nThe YACC DSL provides an efficient way to specify, document, and construct\na typed configuration system that supports common patterns through overlays,\nenvironment injection, default, optional, and required variables.\n\nNone of the above support this as simply or clearly as the YACC DSL and\npython configuration builder.\n\n## Concepts\n\nThe system is built around three concepts:\n\n* A YACC Descriptor, authored in a YAML DSL.\n* Overlays which are additive.\n* Output, which represents the assembly of a YACC Descriptor and the Overlays.\n\n### YACC Descriptor\n\nThe YACC Descriptor borrows heavily from the INI format: a configuration is a\ncollection of `sections`, with one or more `keys` within a section.\n\nThe YACC Descriptor adds the notion of a `Specification`, which describes a `key`:\n\n* The type\n* A default value (or `optional` or `required`)\n* Documenation\n* Examples\n* Deprecated (flag)\n* Sensitive\n\n#### Example\n\n```yaml\nwebserver:\n port: !spec\n description: Port to accept general traffic.\n type: !!int \"0\"\n value: 80\n debug: !spec\n description: Is debug mode enabled.\n type: !!bool \"0\"\n value: false\n public-name: !spec\n description: DNS name for routing public traffic (e.g. redirects).\n type: !!str \"\"\n value: !environment HOSTNAME\n ssl-private-key: !spec\n description: \n sensitive: true\n type: !!str \"\"\n value: !required \n```\n\n### Overlays\n\nAn overlay is simply a set of key-level overrides, where last takes precedence.\n\n#### Overlay as JSON\n\nThis can be provided as a YAML document (or equivalent JSON):\n\n```yaml\nwebserver:\n port: 9999\n```\n\n#### Overlay as ENV variable\n\nVia a key the environment (the prefix is configurable):\n\n```sh\nexport YACC__WEBSERVER__PORT=9999\n```\n\n### Output\n\nAfter merging the descriptor and all overlays via the algorithm described below\nthe compiled configuration is a `Dict[section, Dict[key, value]]`\n\nThis can be injected into a running python process or output via the CLL into formats\nconsumable by other programs (INI, SH, Make, JSON).\n\n\n## Resolution Algorithm\n\n### Overlay Assembly\n\n```python\ndesc_object = yml.load(open(file).read()) #: :type: Dict[str, Dict[str, ValueSpec]]\n\nresolver = YaccResolver(desc_object)\nresolver.assemble(overlays)\n```\n\n#### 1. Parse the descriptor and provided overlays.\n\nThe descriptor defines the complete set of accepted parameters as defined by `ValueSpec` objects.\n\n#### 2. Resolve overlays as defined in the environment\n\n```python\ndefault_overlays = [EnvVar(\"YACC__OVERLAY\")]\nextra_overlays = os.environ.get(\"PYACC_RESOLVER__OVERLAYS\")\nif not extra_overlays:\n extra_overlays = default_overlays\nreturn map(yml.load, filter(None, map(read, extra_overlays))) \n```\n\n#### 3. Define the environment key prefix `${ENV_PREFIX}`\n\nThe environment prefix is used to resolve key-specific overlays.\n\n```python\nenv_prefix = os.environ.get(\"YACC_RESOLVER__ENV_PREFIX\", \"PYYACC\")\n```\n\n\n#### 4. Construct an overlay from the environment\n\n- Values are parsed as YAML values.\n- Section/keys map to:\n\n```python\nre.sub(r'[^a-z0-9]', '_', \"%s__%s__%s\" % (env_prefix, section, key), flags=re.I).upper()\n```\n\n#### 4. Merge down each overlay onto the descriptor.\n\n```python\ndescriptor.update(*itertools.chain(provided_overlays, extra_overlays, [environment_overlay]))\n```\n\n### Final Resolution\n\n```python\ndescriptor.finalize()\n```\n\n#### 1. Iterate over all ValueSpecs\n\n1. Resolve any values !environment objects.\n2. Validate type against the spec.\n3. Store values and errors.\n\n## CLI\n\n\n```bash\npyyacc3 -h\n```\n\n Usage: pyyacc3 [options] yaml [yaml ...]\n \n Options:\n -h, --help show this help message and exit\n -v Verbose logging output.\n -V Very verbose logging output.\n --flat Flatten into 'section.key': value notation\n -f ARG_FORMAT, --format=ARG_FORMAT\n Output format: yaml, json, sh, make are supported.\n --no-validate Disable validation [default: on]\n -o ARG_OUTPUT, --output=ARG_OUTPUT\n Output destination: path where to write output. If not\n provided, stdout is used.\n --env-prefix=ARG_ENV_PREFIX\n Prefix for overlays from the environment\n --env-overlay=ARG_ENV_OVERLAY\n Name of an overlay to load from the environment\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Livefyre/py-yacc", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "py-yacc", "package_url": "https://pypi.org/project/py-yacc/", "platform": "", "project_url": "https://pypi.org/project/py-yacc/", "project_urls": { "Homepage": "https://github.com/Livefyre/py-yacc" }, "release_url": "https://pypi.org/project/py-yacc/3.0.1/", "requires_dist": null, "requires_python": "", "summary": "A YAML based configuration DSL and associated parser/validator.", "version": "3.0.1" }, "last_serial": 4981894, "releases": { "0.0.11": [ { "comment_text": "", "digests": { "md5": "251e337819daa5fad760119726ad196d", "sha256": "8b298ea8c70567716baa80c19171bffc6fcbda726595d1a8ced4a140882afddb" }, "downloads": -1, "filename": "py-yacc-0.0.11.tar.gz", "has_sig": false, "md5_digest": "251e337819daa5fad760119726ad196d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7013, "upload_time": "2018-06-08T09:46:12", "url": "https://files.pythonhosted.org/packages/78/74/b22e5c03ab6fd7cc138d42f2c57ca6302d95118c301f1631b591389c7b17/py-yacc-0.0.11.tar.gz" } ], "2.1.1": [ { "comment_text": "", "digests": { "md5": "65ddde05e066b729328f7d71e3d9fdf6", "sha256": "092825bbbe39769c187f3b3172a970e166b7eb584f4965a09a2848b391656483" }, "downloads": -1, "filename": "py-yacc-2.1.1.tar.gz", "has_sig": false, "md5_digest": "65ddde05e066b729328f7d71e3d9fdf6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7585, "upload_time": "2018-06-08T09:48:52", "url": "https://files.pythonhosted.org/packages/8a/fb/7e1ba00e3418d83d4edaee266dc50d111660fe927ed386de67135d52ca4a/py-yacc-2.1.1.tar.gz" } ], "3.0.0": [ { "comment_text": "", "digests": { "md5": "58afd4659f589e49c33052ef0abc5464", "sha256": "dcc99511396cd26f9fc3a9da97c6d72f7634b3f428f6b92472d6aedf74caf89a" }, "downloads": -1, "filename": "py-yacc-3.0.0.tar.gz", "has_sig": false, "md5_digest": "58afd4659f589e49c33052ef0abc5464", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14652, "upload_time": "2018-07-20T22:15:08", "url": "https://files.pythonhosted.org/packages/81/c9/a7b95a661898189741908c30e4fa291e59d66695d8e4390dab1b8c8791f8/py-yacc-3.0.0.tar.gz" } ], "3.0.1": [ { "comment_text": "", "digests": { "md5": "8a72b614f2809e455284f076a718134a", "sha256": "0b61defb6c941b3de85f007564e48f7775b5886908b059fa92c4b8a78ddbb584" }, "downloads": -1, "filename": "py-yacc-3.0.1.tar.gz", "has_sig": false, "md5_digest": "8a72b614f2809e455284f076a718134a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14664, "upload_time": "2018-11-15T11:25:10", "url": "https://files.pythonhosted.org/packages/eb/0c/ae576196eed361a3641e0088a9f9e86e112dfa77a600d191a2376af37a1b/py-yacc-3.0.1.tar.gz" } ], "4.0.0a1": [ { "comment_text": "", "digests": { "md5": "d1bdeee96b2020267198af6fa6286dd2", "sha256": "e78b5e98cbfef827d52e963db1ac9d5d408ca4ea1d0b0eecb38a15c93ef817dd" }, "downloads": -1, "filename": "py-yacc-4.0.0a1.tar.gz", "has_sig": false, "md5_digest": "d1bdeee96b2020267198af6fa6286dd2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9986, "upload_time": "2019-03-25T10:05:10", "url": "https://files.pythonhosted.org/packages/14/7a/24936ec8ee8338aeca21da6ed428890969466d292ddb3a619e2bce247f8d/py-yacc-4.0.0a1.tar.gz" } ], "4.0.0a2": [ { "comment_text": "", "digests": { "md5": "4e6095387de3b46484bf59e535ebd8e4", "sha256": "cffa8589b39e0931f54d5fd464745ab15f6f14fdb42ad00c3d9c0b7469973565" }, "downloads": -1, "filename": "py-yacc-4.0.0a2.tar.gz", "has_sig": false, "md5_digest": "4e6095387de3b46484bf59e535ebd8e4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9990, "upload_time": "2019-03-25T10:49:48", "url": "https://files.pythonhosted.org/packages/5f/97/2624c6bebed116b93b51a2bdb850ae11dc45d9e9a1dc5065acfcaea401fd/py-yacc-4.0.0a2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8a72b614f2809e455284f076a718134a", "sha256": "0b61defb6c941b3de85f007564e48f7775b5886908b059fa92c4b8a78ddbb584" }, "downloads": -1, "filename": "py-yacc-3.0.1.tar.gz", "has_sig": false, "md5_digest": "8a72b614f2809e455284f076a718134a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14664, "upload_time": "2018-11-15T11:25:10", "url": "https://files.pythonhosted.org/packages/eb/0c/ae576196eed361a3641e0088a9f9e86e112dfa77a600d191a2376af37a1b/py-yacc-3.0.1.tar.gz" } ] }