{ "info": { "author": "Bachynin Ivan", "author_email": "bachynin.i@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Utilities" ], "description": "easy_flags\n==========\n\nThe goal of this nano-project is to provide simple alternative for ``argparse`` by adding some new features:\n\n#. easy definition\n#. type checking (with static type checking tools)\n#. reusability\n\n\nInstallation\n------------\n\n.. code-block:: bash\n\n pip install easy_flags\n\n\nBasic example\n-------------\n\nfoo.py\n\n.. code-block:: python\n\n from easy_flags import SimpleConfig\n\n class MyConfig(SimpleConfig):\n int_val = 4\n bool_val = True\n with_doc = 0.4, 'some docs' # type: float\n without_default = None, int, 'another docs' # type: bool\n\n if __name__ == '__main__':\n # command line arguments will be parsed after ::define call\n c = MyConfig().define().print()\n print('bool_val:', c.bool_val)\n\n\nRun:\n\n.. code-block::\n\n $ python foo.py\n\n + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n | bool_val : True\n | int_val : 4\n | with_doc : 0.4\n | without_default : None\n + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n bool_val: True\n\n Process finished with exit code 0\n\n\n $ python foo.py -h\n\n usage: foo.py [-h] [--bool_val | --no-bool_val] [--int_val INT_VAL]\n [--with_doc WITH_DOC] [--without_default WITHOUT_DEFAULT]\n\n optional arguments:\n -h, --help show this help message and exit\n --bool_val bool, default: True\n --no-bool_val\n --int_val INT_VAL int, default: 4\n --with_doc WITH_DOC float, default: 0.4 - some docs\n --without_default WITHOUT_DEFAULT\n int, default: None - another docs\n\n\nAlternative definition\n----------------------\n\n.. code-block:: python\n\n from easy_flags import Config, IntField, BoolField, FloatField\n\n class MyConfig(Config):\n int_val = IntField(4)\n bool_val = BoolField(default=True)\n with_doc = FloatField(0.4, 'some docs')\n without_default = IntField(doc='another docs')\n\n\nReusabillity\n------------\n\n.. code-block:: python\n\n from easy_flags import Config\n\n class ModelConfig(Config):\n layers = 4\n time_steps = 256\n cell_size = 256\n dropout = 1.0\n\n # same as model config + additional parameters\n class TrainingConfig(ModelConfig):\n lr = 0.001\n epochs = 10000\n dropout = 0.9 # change parent arg\n\n\nDocstrings\n----------\n\nIf you want to add help message for field (which will be displayed if you run script with ``--help`` flag), then you need to add it after flags' default value:\n\n.. code-block:: python\n\n class ExampleConfig(BaseConfig):\n foo = 5.0, 'Some float field.'\n bar = 'field with only default docstring'\n\n.. code-block:: bash\n\n ./script.py --help\n usage: test_base.py [-h] [--bar BAR] [--foo FOO]\n\n optional arguments:\n -h, --help show this help message and exit\n --bar BAR String field, default='field with default docstring'.\n --foo FOO Float field, default=5.0. Some float field.\n\n\n\nBooleans\n--------\n\nBoolean flag with spefied in config name will set destination value to ``True``, and the same flag prefixed with 'no-' will set value to ``False``\n\n.. code-block:: python\n\n class ExampleConfig(BaseConfig):\n cache = True\n f = False\n\n\n.. code-block:: bash\n\n ./script --cache -f\n # cache=True, f=True\n\n ./script --no-cache --no-f\n # cache=False, f=False\n\n\n\nShort flag names\n----------------\n\nIf flag name consists only from one letter then it can be specified with one dash instead of two.\n\n.. code-block:: python\n\n class ExampleConfig(BaseConfig):\n e = 100, 'number of epochs'\n b = True\n\n\n.. code-block:: bash\n\n ./train.py -e 42 -b\n # also valid with two dashes\n ./train.py --e 42 --b\n ./train.py --e 42 --no-b\n\n\n\nSpecify type for tuples\n-----------------------\n\n.. code-block:: python\n\n class ExampleConfig(BaseConfig):\n lr = 0.001, 'learning rate'\n conf = ExampleConfig()\n conf.define()\n\n\nIn example above pre-defined ``conf.lr`` is obviously not a float and some static checkers after typec hecking will make a warning that they expected a float as argument for some function but got tuple instead. Fortunately we can help IDE by adding special comment with proper after-define type:\n\n.. code-block:: python\n\n class ExampleConfig(BaseConfig):\n lr = 0.001, 'learning rate' # type: float\n\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/vaniakosmos/easy_flags", "keywords": "flags,argparse", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "easy-flags", "package_url": "https://pypi.org/project/easy-flags/", "platform": "", "project_url": "https://pypi.org/project/easy-flags/", "project_urls": { "Homepage": "https://github.com/vaniakosmos/easy_flags" }, "release_url": "https://pypi.org/project/easy-flags/0.2.1/", "requires_dist": null, "requires_python": "", "summary": "Simplified flags definition.", "version": "0.2.1" }, "last_serial": 4197189, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "37dd1d1b767659a6ffe09c1f55b5652d", "sha256": "2b4e357cd6cdd7ba5e58b9edb06eeeef34187f4b510585b4e59b4b22728c7b45" }, "downloads": -1, "filename": "easy_flags-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "37dd1d1b767659a6ffe09c1f55b5652d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4086, "upload_time": "2018-04-07T20:45:26", "url": "https://files.pythonhosted.org/packages/12/e4/c38f8ce18362fd722a3733ec59579a4f33aa6c5df4f6d11af2085eb663c0/easy_flags-0.1.0-py3-none-any.whl" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "444d82763c2c5ddca451f5731e763426", "sha256": "b20ace670831fbb8949658a51e723ddfc8bd142c56855263375584fdd48b8125" }, "downloads": -1, "filename": "easy_flags-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "444d82763c2c5ddca451f5731e763426", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4088, "upload_time": "2018-04-07T20:50:05", "url": "https://files.pythonhosted.org/packages/e9/85/64de153e511126c5eff2282332a240d118ae6c5f41326b328ba71a303b3d/easy_flags-0.1.1-py3-none-any.whl" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "abb087e1bb56ac0584d69794c01cfbb3", "sha256": "45c5841ddc367d476a0e7d788f1b2f219f5377864e612cc19dab7723fe903529" }, "downloads": -1, "filename": "easy_flags-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "abb087e1bb56ac0584d69794c01cfbb3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7432, "upload_time": "2018-04-08T12:59:40", "url": "https://files.pythonhosted.org/packages/b9/0e/0b3096cb2317a0295a0e90f1bcc235b91a7578b70d344fc77fd50f6d515a/easy_flags-0.1.2-py3-none-any.whl" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "fff7ac9cb589b95a371853b43c8df2f0", "sha256": "efb1e65a67d1cce16be805beaaab42bdebc4d1957492e28cb818ad19a8ece043" }, "downloads": -1, "filename": "easy_flags-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "fff7ac9cb589b95a371853b43c8df2f0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7513, "upload_time": "2018-07-26T12:24:39", "url": "https://files.pythonhosted.org/packages/5a/84/0167afd6e63bb78be75448dd3bd0e06e3238e099ac9a8683b4db9e17aa4d/easy_flags-0.1.3-py3-none-any.whl" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "39eb955404667274aa84e7f84f9b41d4", "sha256": "b7a8e34812131b1351cedcdc1437b3037b849302e16cf8f858cca1e2258dd765" }, "downloads": -1, "filename": "easy_flags-0.1.4-py3-none-any.whl", "has_sig": false, "md5_digest": "39eb955404667274aa84e7f84f9b41d4", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7606, "upload_time": "2018-07-28T19:33:56", "url": "https://files.pythonhosted.org/packages/4a/42/1530fd89c78abe336e967f3a4794ef6df87438ba704b5d091208836c1aac/easy_flags-0.1.4-py3-none-any.whl" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "328a3c78c510d5e769647b42fefe3f8a", "sha256": "950a1ed876b1d54894a57d7374e97c3381d40749dd86c89605b32ffba2e2beb8" }, "downloads": -1, "filename": "easy_flags-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "328a3c78c510d5e769647b42fefe3f8a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8780, "upload_time": "2018-08-14T16:11:35", "url": "https://files.pythonhosted.org/packages/bd/5a/9d89ac6ded2dbd6041cbc525f4423051f3bf82a8cc3223ea53f740efb410/easy_flags-0.2.0-py3-none-any.whl" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "5c972f26c194a7a0aca0893cae810d07", "sha256": "d9d8da38cb2ac426894abfdb254b3dce3417cff23bb10edf716c80a5358c499f" }, "downloads": -1, "filename": "easy_flags-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "5c972f26c194a7a0aca0893cae810d07", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8762, "upload_time": "2018-08-22T18:06:27", "url": "https://files.pythonhosted.org/packages/44/3b/a4c868d8412f11fbd4f7d0b5051d89ee26228fb1a427e561509c694042d0/easy_flags-0.2.1-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5c972f26c194a7a0aca0893cae810d07", "sha256": "d9d8da38cb2ac426894abfdb254b3dce3417cff23bb10edf716c80a5358c499f" }, "downloads": -1, "filename": "easy_flags-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "5c972f26c194a7a0aca0893cae810d07", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8762, "upload_time": "2018-08-22T18:06:27", "url": "https://files.pythonhosted.org/packages/44/3b/a4c868d8412f11fbd4f7d0b5051d89ee26228fb1a427e561509c694042d0/easy_flags-0.2.1-py3-none-any.whl" } ] }