{ "info": { "author": "Alfredo Deza", "author_email": "alfredodeza [at] gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries", "Topic :: Utilities" ], "description": "tambo\n=====\nUse *any* argument parser you want for *each* sub-command. Easily manage each\ncommand as a self-contained application.\n\nCommand Line Traversing Engine\n------------------------------\n``tambo`` is a Python package that helps to automatically traverse a tree of\ncommand line options and subcommands dispatching them to mapped classes that\ncan use any command line parser they want.\n\nWhenever a command line interface of a program grows beyond a few flags and\noptions it becomes painful to manage all the different options and calls\nhappening on a single place.\n\n`tambo`'s approach\n------------------\nWhat if we could **map** the command line options to objects and just deal with\nthe incoming action *once*? Dealing with subcommands would not be up to\na single object that gets constructed, but rather, to a chain of events that\nstart at the root of an object that has the first level options mapped.\n\nThis would be an example of how ``tambo`` would a dispatch of a subcommand:\n\n.. code-block:: python\n\n parser = tambo.Transport(args)\n parser.mapper = { 'subcommand' : MySubcommandClass }\n parser.dispatch()\n\nThe dispatcher would call ``MySubcommandClass`` passing in all the arguments\nthat came in initially to the constructor and would then call the\n``main`` method so that your class can handle the logic of what to do\nwith the incoming arguments and options there.\n\nDo you need to add more commands? Just add them to this root mapper and they\nwill be kept self contained. No need to declare *every* single option for all\ncommands in one place. This is how it would look for a few more commands:\n\n.. code-block:: python\n\n parser = tambo.Transport(args)\n parser.mapper = {'subcommand': MySubcommandClass,\n 'bar': BarClass,\n 'foo': FooClass}\n parser.dispatch()\n\n j\nIf the ``main`` dispatcher is doing other stuff after dispatching, like\ndisplaying help (useful when nothing is matched when dispatching) then\na ``with_exit`` flag can be passed to get a ``SystemExit(0)`` be called::\n\n parser.dispatch(with_exit=True)\n\nYou can still handle options, boolean flags and anything you want before\nhitting ``tambo`` to dispatch to subcommands, and again, you may use *whatever\nargument parser you want.*\n\nLets put this abundantly clear:\n\n-------------------------------------------------\n**You can use whatever argument parser you want**\n-------------------------------------------------\n\nWhat is wrong with current approaches\n-------------------------------------\nEven current, widely used command line option parsers in Python suffer from\nthis case: ``argparse`` and ``optparser`` both require one to explicitly\nconstruct the objects with the parameters when the interface is called.\n\nNot only it forces you to create them before hand, but it also forces one to\nmake decisions based on what the parsed objects got. For example, if you have\na ``--verbose`` flag you would first need to add it to the parsing object,\nsomething along the lines of:\n\n.. code-block:: python\n\n parser = ParserObject()\n options, arguments = parser.parse_args(args)\n\n parser.add_option('--verbose', action='store_true', help='Increase\n verbosity')\n\nAnd then to act upon whatever the parser object got, you would do something\nlike:\n\n.. code-block:: python\n\n if parser.verbose:\n # do something about verbosity here\n my_program.verbose()\n\nAgain, this is all *OK* if you have just a few flags and options, but if you\nhave, say, 10 or 20 of those, or are combining some with subcommands, you get\nhighly convoluted methods or functions that are trying to deal with the high\ndemand for object construction.\n\nMoreover, you are causing that method to create and evaluate *everything* all\nthe time.\n\nIf this was a web framework, it would be a highly inefficient one, wouldn't it?\nExecuting all the code all the time when a request comes in?\n\n\nCommand Line Class\n------------------\nThe command line class is what ``tambo`` would look forward when dispatching to\nsubcommands. They need to follow a couple of constraints but will still allow\nto handle the command line arguments in whatever way you want with whatever\nlibrary you want.\n\nThe most simple class you would need to have a valid dispatch call would look\nlike this (following the example of the verbose flag from above):\n\n.. code-block:: python\n\n class MySubCommand(object):\n\n def __init__(self, argv):\n self.argv = argv\n\n def main(self):\n if '--verbose' in self.argv:\n my_program.verbose()\n\nIn ``tambo`` internals, the above class will get called when it matches the\nmapping defined in your root dictionary, and will receive the ``argv`` argument\nwhich is nothing else than the list of arguments (same as what you would expect\nfrom ``sys.argv`` received on the command line.\nIf we are following the examples from above, the call would've been like this\non the CLI::\n\n my_cli subcommand --verbose\n\nUsing ``tambo`` parsed args\n---------------------------\nAlthough you can use whatever argument parser you want, ``tambo`` also comes\nwith its own little engine that maps arguments in the command line to values,\nthat represents the flags and arguments that you expect:\n\n.. code-block:: python\n\n from tambo import Transport\n\n class MySubCommand(object):\n\n def __init__(self, argv):\n self.argv = argv\n self.parser = Transport(self.argv)\n\n def main(self):\n if self.parser.has('--verbose'):\n my_program.verbose()\n\nIn the above case ``--verbose`` wasn't expecting a value assigned so later we\njust verified it existed by calling ``has('--verbose')``.\n\nThe ``Transport`` object allows you to define all the flags and options you need as\na tuple or a list so that they can be taken into account when mapping the\nvalues. If you want to define aliases, you can do so by grouping them in a list\nwithin the main list passed in to ``Transport``::\n\n >>> from tambo import Transport\n >>> options = [['-i', '--import'], '--verbose']\n >>> sys_argv = ['/bin/myapp', '-i', 'somevalue']\n >>> parse = Transport(sys_argv, options=options)\n >>> parse.parse_args()\n >>> parse.get('-i')\n 'somevalue'\n >>> parse.get('--import')\n 'somevalue'\n\nSo aliases work by grouping them together in a list, but what happens on\nboolean flags? You can check them by calling the ``has`` method::\n\n\n >>> from tambo import Transport\n >>> options = [['-i', '--import'], '--verbose']\n >>> sys_argv = ['/bin/myapp', '--verbose']\n >>> parse = Transport(sys_argv, options=options)\n >>> parse.parse_args()\n >>> parse.has('-i')\n False\n >>> parse.has('--verbose')\n True\n\nIf you need to check for boolean flags in batch, you can pass in a list::\n\n >>> from tambo import Transport\n >>> options = [['-i', '--import'], '--verbose']\n >>> sys_argv = ['/bin/myapp', '--verbose']\n >>> parse = Transport(sys_argv, options=options)\n >>> parse.parse_args()\n >>> parse.has('-i')\n False\n >>> parse.has(['-v', '--verbose'])\n True\n\n\n\nHelp generation\n---------------\nA common problem for subcommands and command line tools that have these is\ngenerating help in a semi-automated way. ``tambo`` has a way to do this for\nsubcommands that are mapped by calling the help property if there is one and\nwould in turn output that information when called:\n\n.. code-block:: python\n\n class MySubcommandClass(object):\n\n help = 'A sub-command that does some stuff'\n\n\nAnd then in the handler for your arguments it will automaticall check for the\npresence of the help attribute to display it if needed:\n\n.. code-block:: python\n\n # parser is an instance of the Transport class from ``tambo``\n parser.parse_args()\n\n\nWhich would make sure that when help is set on the command line it would output\nsomething like this::\n\n my_cli_tool version 0.0.1\n\n SubCommands:\n\n subcommand A sub-command that does some stuff\n\nThis is again, entirely optional, as you can avoid making those calls to catch\nhelp by telling the ``Transport`` class to avoid checking for it:\n\n.. code-block:: python\n\n parser = Transport(sys.argv, check_help=False)\n\nIf for some reason you wanted to force printing the help menu, for example when\nno options have been matched, you can also do that with ``print_help()``:\n\n.. code-block:: python\n\n parser = Transport(sys.argv, check_help=False)\n\n if parser.has('--mandatory-option'):\n my_program.mandatory_thing()\n else:\n parser.print_help()", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "UNKNOWN", "keywords": "cli,command,command line,dispatcher,subcommands", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "tambo", "package_url": "https://pypi.org/project/tambo/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/tambo/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/tambo/0.4.0/", "requires_dist": null, "requires_python": null, "summary": "A command line object dispatcher", "version": "0.4.0" }, "last_serial": 2974459, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "89f072d909e6f94c0c637dd38a40fde4", "sha256": "534c2c185c37cf9ded985a7800e8d7bd7da2fd77009928998987d9993f4ea587" }, "downloads": -1, "filename": "tambo-0.0.1.zip", "has_sig": false, "md5_digest": "89f072d909e6f94c0c637dd38a40fde4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19269, "upload_time": "2012-03-01T19:23:35", "url": "https://files.pythonhosted.org/packages/ef/e7/112c3945ddc06242fbbcfa01f4f953309531cd5c0fccee273af9fa0b653f/tambo-0.0.1.zip" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "824a9ea1ebc0f06d9f1b62795d11be4c", "sha256": "dce3d2b7e6070d5db3f40849d8de42556b651f2f659088ba2290e0be8d0a65df" }, "downloads": -1, "filename": "tambo-0.0.2.zip", "has_sig": false, "md5_digest": "824a9ea1ebc0f06d9f1b62795d11be4c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19491, "upload_time": "2012-03-09T23:31:15", "url": "https://files.pythonhosted.org/packages/be/b9/f765c2e8f0f64660bb7cf5f12b28953ba48944f72e24e27eac3dc788511f/tambo-0.0.2.zip" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "631c362f5b45f507c9daa56b10bb85f0", "sha256": "87a010962700c931dabbbe3509aa08fa9f28965cb8845f7b06352e7b5a28c434" }, "downloads": -1, "filename": "tambo-0.0.3.zip", "has_sig": false, "md5_digest": "631c362f5b45f507c9daa56b10bb85f0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19999, "upload_time": "2012-04-18T17:14:16", "url": "https://files.pythonhosted.org/packages/69/ec/3d9eb14e6cc62aaebc45312e867bd15b855e5292fb827f2a6c5f6239f00e/tambo-0.0.3.zip" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "981972f454f0501404d5ce9351b24a91", "sha256": "9b813f36325008e5a294ff0d14ca78d41e35ea2f9cced2a7075863c53382de8c" }, "downloads": -1, "filename": "tambo-0.0.4.zip", "has_sig": false, "md5_digest": "981972f454f0501404d5ce9351b24a91", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20162, "upload_time": "2012-05-23T17:36:02", "url": "https://files.pythonhosted.org/packages/87/86/7b3772f9d62c62302043245161519533d3e6bb4981c0f00829e4ba08f8bc/tambo-0.0.4.zip" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "c68c1af928693c70b46ff7f6a5745a5e", "sha256": "0230eca722a3fad6be6e847d5b180984865a96ddf31abf70aa80c61beff0c72d" }, "downloads": -1, "filename": "tambo-0.0.5.tar.gz", "has_sig": false, "md5_digest": "c68c1af928693c70b46ff7f6a5745a5e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14326, "upload_time": "2012-06-19T22:08:52", "url": "https://files.pythonhosted.org/packages/5d/54/9959cb6a1563d42f04a5dce16f43c13900500a00172fb1b0a16de72a0bcd/tambo-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "e3b496e506901067dbad77e68330d609", "sha256": "83ba8a7ee36822d32a176a4d77e09fb739d6d53af4040dee13adfa8a6d77e7e6" }, "downloads": -1, "filename": "tambo-0.0.6.tar.gz", "has_sig": false, "md5_digest": "e3b496e506901067dbad77e68330d609", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8565, "upload_time": "2013-01-12T18:32:23", "url": "https://files.pythonhosted.org/packages/ec/4c/36012990c3d08af1cffbb4e8c0d8b2ab0469ff6ff10ff5c58953adf6aab2/tambo-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "c968d41a81456ace1ab389603bedce95", "sha256": "39a24d1c89a543ac6663f504ab13236debcd8308434f164183c1f9725c80b6d4" }, "downloads": -1, "filename": "tambo-0.0.7.tar.gz", "has_sig": false, "md5_digest": "c968d41a81456ace1ab389603bedce95", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31092, "upload_time": "2013-03-19T22:34:26", "url": "https://files.pythonhosted.org/packages/ab/84/fbe7f44c0e9b4be2f0300a725c54a3fdc45cf53d1ec53a46bdc9a67f5f16/tambo-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "45dfea591817829e5619e3d8941d2196", "sha256": "81a0891537a4801cc948166109a2ebdf34e2c23640180f32252694e599247960" }, "downloads": -1, "filename": "tambo-0.0.8.tar.gz", "has_sig": false, "md5_digest": "45dfea591817829e5619e3d8941d2196", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32248, "upload_time": "2013-07-25T13:02:24", "url": "https://files.pythonhosted.org/packages/f2/c7/78fe98d6531d22594a8d15dd88195d39881a62f78a02493ab8bbb0e93092/tambo-0.0.8.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "e5f6249852a16a32240f3bd92af3a96f", "sha256": "47cf2f8fcbeaaac0a88eedc2089c834675d3efd551ca8f8c619d9c23660a3072" }, "downloads": -1, "filename": "tambo-0.0.9.tar.gz", "has_sig": false, "md5_digest": "e5f6249852a16a32240f3bd92af3a96f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 33204, "upload_time": "2015-04-02T19:28:56", "url": "https://files.pythonhosted.org/packages/77/0e/fcfbb9d4ce724af73415577860fa299ceba2cf1de7086a8516acbc9da3e8/tambo-0.0.9.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "f374d84578209e79a699701241500298", "sha256": "12ee97177d1660d520b7f976862a09edf3a392ad62c69f0cabb4c9b1a2a8e95a" }, "downloads": -1, "filename": "tambo-0.1.0.tar.gz", "has_sig": false, "md5_digest": "f374d84578209e79a699701241500298", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11608, "upload_time": "2015-09-25T15:38:57", "url": "https://files.pythonhosted.org/packages/dd/38/ab4dcbdcfc54c2f2a1591e803ddc0809a0f4e83196743beb62cf6cf545c1/tambo-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "923a8333c1d3e15f186778c8d408fd71", "sha256": "9b95f1525c90a10605516cb921bcbc39097441cc07803db7dcdf824cba013be4" }, "downloads": -1, "filename": "tambo-0.2.0.tar.gz", "has_sig": false, "md5_digest": "923a8333c1d3e15f186778c8d408fd71", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11754, "upload_time": "2015-10-19T11:46:17", "url": "https://files.pythonhosted.org/packages/ee/da/bac5be6dc886952c79f84040819a80329ea93608d9ed6988cae2518919e9/tambo-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "b795d980275a8e2f570aef610443aa3d", "sha256": "23784c9b4c78eb6707ec77f17e80dd8ec54da20813e08ee9cc319e352304100e" }, "downloads": -1, "filename": "tambo-0.3.0.tar.gz", "has_sig": false, "md5_digest": "b795d980275a8e2f570aef610443aa3d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11928, "upload_time": "2017-05-10T21:58:53", "url": "https://files.pythonhosted.org/packages/39/a1/3cef697520e530614d0e18004556cbdd230cf2bb12ba171ccce28a3d1fa7/tambo-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "f1df2aef9d295f881f84264d934f5c5a", "sha256": "9f0144302ecdb55860372b57f3c5168b45658e0a409b8d724086b90e42fa71f3" }, "downloads": -1, "filename": "tambo-0.4.0.tar.gz", "has_sig": false, "md5_digest": "f1df2aef9d295f881f84264d934f5c5a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27586, "upload_time": "2017-06-23T20:09:06", "url": "https://files.pythonhosted.org/packages/42/2f/4813e296ae44c6d8d6507c34b47c9753da915ed14dfaee34b0f7eeef477d/tambo-0.4.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f1df2aef9d295f881f84264d934f5c5a", "sha256": "9f0144302ecdb55860372b57f3c5168b45658e0a409b8d724086b90e42fa71f3" }, "downloads": -1, "filename": "tambo-0.4.0.tar.gz", "has_sig": false, "md5_digest": "f1df2aef9d295f881f84264d934f5c5a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27586, "upload_time": "2017-06-23T20:09:06", "url": "https://files.pythonhosted.org/packages/42/2f/4813e296ae44c6d8d6507c34b47c9753da915ed14dfaee34b0f7eeef477d/tambo-0.4.0.tar.gz" } ] }