{ "info": { "author": "Lionel D. Hummel", "author_email": "lionel@ieee.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", "Natural Language :: English", "Operating System :: POSIX", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Text Processing :: Filters" ], "description": "==============\ncounterpart(s)\n==============\n-------------------------------------------------------------\nConfiguration file-driven values for shell and Python scripts\n-------------------------------------------------------------\n\nThe ``counterparts`` module takes mappings, specified via files in the\n``ConfigParser[1]`` format (default file name: ``.counterc``), and\nuses them to look up a string value corresponding to each string that\nit is given. For example, given a file with a different path in your\npresent tree than in another tree, when generating a list of files,\nyou might wish to automatically substitute that other tree's path (the\ncounterpart of the present path). First you would keep a list of\nthose special cases in a human-readable config file, and second,\narrange to let your shell or Python script use whatever\n``counterparts`` finds.\n\nThe ``counterpart`` command provides shell access to the string\nmapping abilities of the ``counterparts`` module. Help for that\ncommand is available[2] by running ``counterpart --help``.\n\nNotice the slightly different names of ``counterpart`` (the shell\ncommand) and ``counterparts`` (the Python module). Besides giving a\nclue as to which is being referred to, the choice of names reflects\nthat the command *is for looking up a counterpart* whereas the module\n*is a more general treatment of counterparts*. Except where noted,\nthe ``counterpart`` command and the ``counterparts`` module behave the\nsame: The command is essentially a front-end to the module's\n``get_counterpart_mapping`` function; it runs the input string(s)\nthrough the returned mapping, echoing the results as specified.\n\n.. [1] https://docs.python.org/2/library/configparser.html\n.. [2] ``counterpart`` is available after installing ``counterparts``\n and updating your ``PATH`` environment variable if necessary.\n\n\nRequirements\n============\n\nPython 2.6+ and Python 3 are supported.\n\nTests have been run (and passed) on:\n\n * Mac OS X 10.5 and 10.8, using Python 2.7 and 3.4.\n\n\nInstallation\n============\n\n``pip`` is the recommended way to obtain and install ``counterparts``::\n\n pip install counterparts\n\nWritten in Python, this package's source code is on GitHub::\n\n git clone https://github.com/lionel/counterparts\n\nFrom the top-level source directory, the usual ``setuptools`` operations\nare available, i.e.::\n\n python setup.py install\n\n\nUsage Summary\n=============\n\nBy default, ``counterparts`` tries to read both ``~/.counterc`` and\n``./.counterc``. Their existence is optional. Any additional config\nfiles specified by the caller are mandatory. In general,\n``ConfigParser`` overrides earlier values with ones from files read\nlater, so values in a user-supplied config file take precedence over\nthe default files when they exist.\n\nGiven a ``.counterc`` file in the PWD containing::\n\n [COUNTERPART_MAP]\n foo = bar\n\nUsing the ``counterpart`` command::\n\n $ counterpart foo\n bar\n $\n\n $ diff foo `counterpart foo`\n # output diff between foo and bar\n\n $ counterpart baz\n Traceback (most recent call last):\n ... \n KeyError: 'Mapping not found in COUNTERPART_MAP: baz'\n $\n\nBecause ``counterparts`` expects ``ConfigParser``-format files, the\nsections in ``[SQUARE BRACES]`` are case sensitive, but the *option*\nlines (left-hand side) ignore case. Therefore, in the above config\nexample: ``foo``, ``Foo``, and ``FOO`` would all map to ``bar``, even\nthough ``[COUNTERPART_map]`` will **not** work correctly in place of\n``[COUNTERPART_MAP]``.\n \nNext, using the ``counterparts`` module::\n\n import counterparts\n before = \"foo\"\n after = counterparts.map_counterpart(before)\n\n # or, to avoid need for repeated map_counterpart calls to re-read config file(s):\n mapping = counterparts.get_counterpart_mapping()\n after = mapping[before]\n # the variable 'after' is assigned the value '\"bar\"'\n\nYou can specify, via a ``COUNTERPART_DIR`` section, a default mapping\nfor strings (\"paths\" in this case) that are not listed in the\n``COUNTERPART_MAP``. The ``prepend_path`` option in the\n``COUNTERPART_DIR`` section tells ``counterparts`` to prepend its value\nto any input that doesn't hit in the ``COUNTERPART_MAP``.\n\nSo, for example, given the ``.counterc``::\n\n [DEFAULT]\n up = ..\n [COUNTERPART_MAP]\n foo = %(home)s/bar\n [COUNTERPART_DIR]\n prepend_path = %(up)s/quux\n\n $ counterpart baz\n ../quux/baz\n $\n\nThe previous ``.counterc`` example also shows another feature:\n``home`` is pre-populated in the ``DEFAULT`` section. Hence, you can\nmanually provide a path relative to ``$HOME`` to use in the other\nsections' right-hand-side values::\n\n $ [ `counterpart foo` == \"$HOME/bar\" ] && echo '%(home)s equals $HOME'\n %(home)s equals $HOME\n $\n\nFinally, ``counterparts`` also supports an ``INCLUDE`` directive. It\nis specified as a section by that same name, and it accepts a\n``paths`` option, which is a newline-separated list of one or more\nother config files. Some files that demonstrate valid uses of the\n``INCLUDE`` section are:\n\n* ``tests/counterparts_data/conf-include-logging``\n* ``tests/counterparts_data/conf-include-more``\n* ``tests/counterparts_data/conf-2-with-include``\n* ``tests/counterparts_data/conf-include-still-more``\n\nThe ``INCLUDE`` section has proven useful for things like controlling\nlogging, setting site-specific options, and picking up global\ndefaults.\n\n\nConfiguration File\n==================\n\nThe configuration file is in the format used by the ``ConfigParser``\nmodule. See Documentation_, below, for more about the format.\n\nThe special sections and options used by ``counterparts`` are\ndescribed above in the `Usage Summary`_.\n\nThe *sections* and *options* can be read from the config files of\nother applications, as long as those applications ignore unknown\nsections and ``counterparts`` is told to look in those files.\n\nIf no configuration file is provided to ``counterparts``, it looks\nfirst in ``./.counterc`` and second in ``~/.counterc``.\n\n\nDocumentation\n=============\n\nFor the most part, you're looking at it.\n\nFor some useful information on ``ConfigParser``-format files, see::\n\n https://docs.python.org/2/library/configparser.html\n\n\nLicense\n=======\n\n``counterparts`` is released under the GPLv2, contained in the ``LICENSE.txt`` file.\n\n\nAuthors\n=======\n\nCopyright (c) 2015 by Lionel D. Hummel.\n\n\nRoadmap\n=======\n\nI put ``counterparts`` up on GitHub to give me a bite-sized (but\nmeaningful) sample with which to explore the site's features such as\ncontinuous integration and documentation. So this is what I've got\nfor its roadmap so far:\n\n* More tests and documentation are needed.\n\nI'm glad to discuss an expanded roadmap if ``counterparts`` proves\nuseful to any contributors besides myself.\n\n\n\nContributing\n============\n\n``counterparts`` is meant to be a solid, idiomatic, and readable\nexample of Python code. I can think of several ways it is not quite\nthere yet in this release. If you've got one in mind, please use the\nGitHub page to contact the author, ask questions, report bugs, suggest\npatches, receive updates, etc.::\n\n https://github.com/lionel/counterparts", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/lionel/counterparts", "keywords": null, "license": "GPLv2", "maintainer": null, "maintainer_email": null, "name": "counterparts", "package_url": "https://pypi.org/project/counterparts/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/counterparts/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/lionel/counterparts" }, "release_url": "https://pypi.org/project/counterparts/0.1/", "requires_dist": null, "requires_python": null, "summary": "Configuration file-driven values for shell and Python scripts", "version": "0.1" }, "last_serial": 1637280, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "54eb6bafd48c4f61a135aeaeee004278", "sha256": "3d76d39f91c37161b97086da9644947eadcc6f947a1c26921a096074579378a3" }, "downloads": -1, "filename": "counterparts-0.1.tar.gz", "has_sig": false, "md5_digest": "54eb6bafd48c4f61a135aeaeee004278", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11297, "upload_time": "2015-07-17T01:53:31", "url": "https://files.pythonhosted.org/packages/9e/30/c5ba46fec630aea7cf928bf3c4faf4a37e227ae478c26d3e94818546d57e/counterparts-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "54eb6bafd48c4f61a135aeaeee004278", "sha256": "3d76d39f91c37161b97086da9644947eadcc6f947a1c26921a096074579378a3" }, "downloads": -1, "filename": "counterparts-0.1.tar.gz", "has_sig": false, "md5_digest": "54eb6bafd48c4f61a135aeaeee004278", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11297, "upload_time": "2015-07-17T01:53:31", "url": "https://files.pythonhosted.org/packages/9e/30/c5ba46fec630aea7cf928bf3c4faf4a37e227ae478c26d3e94818546d57e/counterparts-0.1.tar.gz" } ] }