{ "info": { "author": "Valentin Lab", "author_email": "valentin.lab@kalysto.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Topic :: Software Development", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "=========================\r\nkids.data\r\n=========================\r\n\r\n.. image:: http://img.shields.io/pypi/v/kids.data.svg?style=flat\r\n :target: https://pypi.python.org/pypi/kids.data/\r\n :alt: Latest PyPI version\r\n\r\n.. image:: http://img.shields.io/pypi/dm/kids.data.svg?style=flat\r\n :target: https://pypi.python.org/pypi/kids.data/\r\n :alt: Number of PyPI downloads\r\n\r\n.. image:: http://img.shields.io/travis/0k/kids.data/master.svg?style=flat\r\n :target: https://travis-ci.org/0k/kids.data/\r\n :alt: Travis CI build status\r\n\r\n.. image:: http://img.shields.io/coveralls/0k/kids.data/master.svg?style=flat\r\n :target: https://coveralls.io/r/0k/kids.data\r\n :alt: Test coverage\r\n\r\n\r\n``kids.data`` is a Python library providing helpers to manage data.\r\n\r\nIt's part of 'Kids' (for Keep It Dead Simple) library.\r\n\r\n\r\nMaturity\r\n========\r\n\r\nThis code is in alpha stage. It wasn't tested on Windows. API may change.\r\nThis is more a draft for an ongoing reflection.\r\n\r\nAnd I should add this is probably not ready to show. Although, a lot of these\r\nfunction are used everyday in my projects and I got sick rewritting them for\r\nevery project.\r\n\r\n\r\nFeatures\r\n========\r\n\r\nusing ``kids.data``:\r\n\r\n- You'll have a matching library to fuzzy match elements\r\n- a formatter concept to help you format any type of data to another type\r\n- a way to display tables of records on command line\r\n- some everyday missing function for manipulating sets of elements\r\n\r\n\r\nInstallation\r\n============\r\n\r\nYou don't need to download the GIT version of the code as ``kids.data`` is\r\navailable on the PyPI. So you should be able to run::\r\n\r\n pip install kids.data\r\n\r\nIf you have downloaded the GIT sources, then you could add install\r\nthe current version via traditional::\r\n\r\n python setup.py install\r\n\r\nAnd if you don't have the GIT sources but would like to get the latest\r\nmaster or branch from github, you could also::\r\n\r\n pip install git+https://github.com/0k/kids.data\r\n\r\nOr even select a specific revision (branch/tag/commit)::\r\n\r\n pip install git+https://github.com/0k/kids.data@master\r\n\r\n\r\nUsage\r\n=====\r\n\r\n\r\nmdict\r\n-----\r\n\r\n``mdict`` are nested dicts access in one go thanks to interpreting the key,\r\ncheck this::\r\n\r\n >>> from pprint import pprint as pp\r\n >>> from kids.data.mdict import mdict\r\n\r\n >>> d = mdict({'a': {'b': {'y': 0}}, 'x': 1})\r\n >>> d['a.b.y']\r\n 0\r\n >>> d.get('a.b.z', 3)\r\n 3\r\n >>> d['a.b']\r\n m{'y': 0}\r\n\r\nYou can configure your mdict to use '/' instead, and if you want more you could\r\nbuild your own key tokenizer to break your string into token::\r\n\r\n >>> from kids.data.mdict import CharTokenizer\r\n\r\n >>> d = mdict({'a': {'b': {'y': 0}}, 'x': 1}, CharTokenizer('/'))\r\n >>> d['a/b/y']\r\n 0\r\n\r\nOf course setting item works the same::\r\n\r\n >>> d['a/b/z'] = 2\r\n >>> d\r\n m{'a': {'b': {'y': 0, 'z': 2}}, 'x': 1}\r\n\r\nAnd deleting items::\r\n\r\n >>> del d['a/b']\r\n >>> d\r\n m{'a': {}, 'x': 1}\r\n\r\nPlease note that the tokenizer is quite stable even with backslashed\r\nor empty keys::\r\n\r\n >>> d[r'a/b\\/c//d'] = 9\r\n >>> d\r\n m{'a': {'b/c': {'': {'d': 9}}}, 'x': 1}\r\n\r\nAnd flattening back the key/values is done through ``flat`` property::\r\n\r\n >>> pp(d.flat)\r\n {'a/b\\\\/c//d': 9, 'x': 1}\r\n\r\nIf you just want to use it once on a nested dict, all the function are\r\nready for use::\r\n\r\n >>> from kids.data.mdict import mset, mget, mdel\r\n\r\n >>> dct = {'a': {'b': {'y': 0}}, 'x': 1}\r\n >>> mget(dct, 'a.b.y')\r\n 0\r\n >>> mset(dct, 'a.b.z', 2)\r\n >>> pp(dct)\r\n {'a': {'b': {'y': 0, 'z': 2}}, 'x': 1}\r\n\r\n >>> mdel(dct, 'a.b')\r\n >>> pp(dct)\r\n {'a': {}, 'x': 1}\r\n\r\n\r\ngraph\r\n-----\r\n\r\n``graph`` provide a bunch of function to work with graph. In a\r\nagnostic way, this means you can store your graph in whatever the form\r\nyou want. All you need to do it to provide a function to get the\r\nrelated nodes from their related nodes.\r\n\r\nExample with the ``cycle_exists`` function::\r\n\r\n >>> from kids.data.graph import cycle_exists\r\n\r\n >>> graph = {1: [2, 3], 2: [1]}\r\n >>> get_children = lambda n: graph.get(n, [])\r\n\r\n >>> cycle_exists(1, get_children)\r\n True\r\n\r\n >>> cycle_exists(3, get_children)\r\n False\r\n\r\nAs node ``3`` is a leaf there are no cycle starting from him.\r\n\r\nYou could get the ``leafage`` of a set of elements (a leaf is a final\r\nnode without children). The ``leafage`` is all the ``leaf`` that can\r\nbe reached from given elements::\r\n\r\n >>> from kids.data.graph import leafage\r\n\r\n >>> list(leafage([1, 4], get_children))\r\n [3, 4]\r\n\r\nThe nice one is ``reorder``, which will try to do the minimum change\r\nto a given list, but will swap element to garanty no dependency\r\nissues, this means that the children will appear before the\r\nparents. This is very handy when loading modules that depends to\r\nother modules::\r\n\r\n >>> from kids.data.graph import reorder\r\n\r\n >>> graph = {2: [1], 3: [2]}\r\n >>> reorder([1, 3, 2], get_children)\r\n [1, 2, 3]\r\n\r\n\r\ndct\r\n---\r\n\r\nMerging dicts is something that should be in base python and is missing a lot of \r\npeople (see this `stackoverflow question about merging dict non-inplace`_).\r\n\r\n.. _stackoverflow question about merging dict non-inplace: http://stackoverflow.com/q/38987\r\n\r\nYou can use ``merge`` to merge several dicts into one::\r\n\r\n >>> from pprint import pprint\r\n >>> from kids.data.dct import merge\r\n\r\n >>> pp(merge({'a': 1}, {'a': 2, 'b': 1}, {'c': 3}))\r\n {'a': 2, 'b': 1, 'c': 3}\r\n\r\n\r\nContributing\r\n============\r\n\r\nAny suggestion or issue is welcome. Push request are very welcome,\r\nplease check out the guidelines.\r\n\r\n\r\nPush Request Guidelines\r\n-----------------------\r\n\r\nYou can send any code. I'll look at it and will integrate it myself in\r\nthe code base and leave you as the author. This process can take time and\r\nit'll take less time if you follow the following guidelines:\r\n\r\n- check your code with PEP8 or pylint. Try to stick to 80 columns wide.\r\n- separate your commits per smallest concern.\r\n- each commit should pass the tests (to allow easy bisect)\r\n- each functionality/bugfix commit should contain the code, tests,\r\n and doc.\r\n- prior minor commit with typographic or code cosmetic changes are\r\n very welcome. These should be tagged in their commit summary with\r\n ``!minor``.\r\n- the commit message should follow gitchangelog rules (check the git\r\n log to get examples)\r\n- if the commit fixes an issue or finished the implementation of a\r\n feature, please mention it in the summary.\r\n\r\nIf you have some questions about guidelines which is not answered here,\r\nplease check the current ``git log``, you might find previous commit that\r\nwould show you how to deal with your issue.\r\n\r\n\r\nLicense\r\n=======\r\n\r\nCopyright (c) 2015 Valentin Lab.\r\n\r\nLicensed under the `BSD License`_.\r\n\r\n.. _BSD License: http://raw.github.com/0k/kids.data/master/LICENSE\r\n\r\nChangelog\r\n=========\r\n\r\n0.0.5 (2015-03-04)\r\n------------------\r\n\r\nNew\r\n~~~\r\n\r\n- Added ``MultiDictReader`` class to allow reading from several dicts.\r\n [Valentin Lab]\r\n\r\n This provides an interesting lazy evaluated way to merge\r\n dicts. Additionaly multi-depth dicts are conveniently merged.\r\n\r\n\r\n- Added ``AttrDictAbstract`` to help creating attr-dict patterns from a\r\n small method subset. [Valentin Lab]\r\n\r\n- Introduce ``DictLikeAbstract`` to write quickly full dict like API\r\n from a small subset. [Valentin Lab]\r\n\r\n- Added ``untokenize`` notion, it'll undo ``tokenize`` job. [Valentin\r\n Lab]\r\n\r\n- ``.items()`` is not flattening anymore, use ``.flat`` for that.\r\n [Valentin Lab]\r\n\r\n Replaced the flattening of the items done by ``.items()`` to remove it\r\n towards the ``.flat`` property.\r\n\r\n In the process, the ``.keys()`` was added.\r\n\r\n\r\n- Dict is now passed by reference and mdict is offering a extended API\r\n to it. [Valentin Lab]\r\n\r\n- [mdict] cleaned code a give a more coherent API. [Valentin Lab]\r\n\r\nFix\r\n~~~\r\n\r\n- When iterating through keys of mdict, those weren't appropriately\r\n quoted. [Valentin Lab]\r\n\r\n\r\n0.0.4 (2015-02-06)\r\n------------------\r\n\r\nNew\r\n~~~\r\n\r\n- [dct] added ``deep_copy`` shortcut. [Valentin Lab]\r\n\r\n This is to get all usefull dict related stuff without having to know\r\n all package required. And to follow pep8 convention on variable/function\r\n names (aka: deep_copy instead of deepcopy).\r\n\r\n\r\n- [dct] added ``merge`` to merge dicts. [Valentin Lab]\r\n\r\n0.0.3 (2015-02-05)\r\n------------------\r\n\r\nNew\r\n~~~\r\n\r\n- [graph] added ``graph`` functions. [Valentin Lab]\r\n\r\n- [mdict] added ``mdict`` pattern. [Valentin Lab]\r\n\r\n- [lib] ``half_split_on_predicate`` added. [Valentin Lab]\r\n\r\n- [lib] added ``default`` arguments to ``first``. [Valentin Lab]\r\n\r\n0.0.2 (2015-01-20)\r\n------------------\r\n\r\nNew\r\n~~~\r\n\r\n- Python3 support and added tests for better coverage. [Valentin Lab]\r\n\r\n- [match] added matching and fuzzy matching library. [Valentin Lab]\r\n\r\n- [fmt] remove all trailing whitespace on record line display. [Valentin\r\n Lab]\r\n\r\n0.0.1 (2014-05-23)\r\n------------------\r\n\r\n- First import. [Valentin Lab]", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/0k/kids.data", "keywords": "", "license": "UNKNOWN", "maintainer": "", "maintainer_email": "", "name": "kids.data", "package_url": "https://pypi.org/project/kids.data/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/kids.data/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/0k/kids.data" }, "release_url": "https://pypi.org/project/kids.data/0.0.5/", "requires_dist": null, "requires_python": null, "summary": "Kids data manipulation helpers.", "version": "0.0.5" }, "last_serial": 1447355, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "b246f47438a8e71da18d1bd9c20ed49e", "sha256": "4dd2a22fb8da2e1541dabf91115e70b434624295f0e013664da10cb60a9d5b3f" }, "downloads": -1, "filename": "kids.data-0.0.2.tar.gz", "has_sig": false, "md5_digest": "b246f47438a8e71da18d1bd9c20ed49e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16616, "upload_time": "2015-01-20T10:50:18", "url": "https://files.pythonhosted.org/packages/4e/fd/2fac09846c6d8f78d2ca09d43c433eabafc632f905d20f43f1bc7f2d711b/kids.data-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "029cbe19a4f8c350b8d7ac689404bb99", "sha256": "42240d3ddecb62e6e28a5b58b46181baa68dcdf0647bd2d336b6f1dc8ec56b74" }, "downloads": -1, "filename": "kids.data-0.0.3.tar.gz", "has_sig": false, "md5_digest": "029cbe19a4f8c350b8d7ac689404bb99", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21811, "upload_time": "2015-02-05T02:10:13", "url": "https://files.pythonhosted.org/packages/59/9b/d999dde64d02fbb54ac5350ef351e398d6e51bb860ac2fbeb2c1580ca76f/kids.data-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "cb925174c848e5844ed0376a9055f783", "sha256": "d6cd7945600acde9015f3aec3fd7cb9f32a3c16cc21c78abc96867618977b233" }, "downloads": -1, "filename": "kids.data-0.0.4.tar.gz", "has_sig": false, "md5_digest": "cb925174c848e5844ed0376a9055f783", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22375, "upload_time": "2015-02-06T08:50:23", "url": "https://files.pythonhosted.org/packages/0d/0b/9fb6a0868445222e72475bf984ab98776eed96de59399b57f5ef0792e0ad/kids.data-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "d00725103a34fc7dda0ca98c1b255d5f", "sha256": "6e431b718093f775fb13787d6cd04974a687301d8ca2d5c1c6c567c4827c11b6" }, "downloads": -1, "filename": "kids.data-0.0.5.tar.gz", "has_sig": false, "md5_digest": "d00725103a34fc7dda0ca98c1b255d5f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26871, "upload_time": "2015-03-04T09:45:15", "url": "https://files.pythonhosted.org/packages/e4/a3/727f94643bd68c068f2f4fbd22c08042c83c8eb457df850c13f42d747bdf/kids.data-0.0.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d00725103a34fc7dda0ca98c1b255d5f", "sha256": "6e431b718093f775fb13787d6cd04974a687301d8ca2d5c1c6c567c4827c11b6" }, "downloads": -1, "filename": "kids.data-0.0.5.tar.gz", "has_sig": false, "md5_digest": "d00725103a34fc7dda0ca98c1b255d5f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26871, "upload_time": "2015-03-04T09:45:15", "url": "https://files.pythonhosted.org/packages/e4/a3/727f94643bd68c068f2f4fbd22c08042c83c8eb457df850c13f42d747bdf/kids.data-0.0.5.tar.gz" } ] }