{ "info": { "author": "Said Ali", "author_email": "said.ali@msn.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5" ], "description": "Iterable_orm\n============\n\n.. image:: https://img.shields.io/pypi/v/iterable_orm.svg\n :target: https://pypi.python.org/pypi/iterable_orm\n :alt: Latest PyPI version\n\n.. image:: https://travis-ci.org/Said007/iterable_orm.svg?branch=master\n :target: https://travis-ci.org/Said007/iterable_orm\n :alt: Latest Travis CI build status\n\n\nIterable_orm allows you to filter, exclude and sort data using similer API provided by Django ORM. The data needs to be a list of objects or dictionary. Python 2 & 3 is supported.\n\nIterable_orm gives you the following API\n\nfilter - Returns a new list of objects or dictionaries that match the given lookup parameters\n\nexclude - Returns a new list of objects or dictionaries that do not match the given lookup parameters\n\nget - Returns a single object or dictionary if there's two matches returns an exception \n\norder_by - Returns a list ordered objects or dictionaries\n\nfirst - Returns the first object or dictionary of filtered or exlcude data\n\nlast - Returns the first object or dictionary of filtered or exlcude data\n\ncount - Returns a lenth of filtered or exlcude or dictionaries\n\n*Please note that Iterable_orm does not support Q like objects offered by Django ORM, but offers a way around by passing anonymous function to filter or exclude function e.g manager.filter(age=lambda x: x >= 20 and x <= 30)*\n\n\nBasic Usage\n-----------\n\nPass a list of objects or dictionary to Queryset\n\n.. code:: python\n\n from iterable_orm import QuerySet\n Accounts = [ A list of account objects that have attrubtes such as name, email, age, gender ect ]\n manager = Queryset(Accounts)\n\n\nFiltering and Excluding\n-----------------------\n\nYou can filter and exclude data by value or lookups, such as gt, gte, lt, lte, startswith, istartswith, endswith, contains, icontains, value_in, value_not_in, value_range, date_range(expects a datetime object) or anonymous function.\n\niterable_orm also allows you to filter related objects using the standard double-underscore notation to separate related fields, e.g manager.filter(parent__name='John'), this filters by parent.child == 'John'.\n\nAll filtering and exlcuding are lazy so you can construct as many filtering as you like and its only evaluated on iterating, calling count, first, last and order_by. \n\nBelow are code examples of filtering and excluding, \n\n.. code:: python\n\n from iterable_orm import QuerySet\n Accounts = [A list of account objects that have attrubtes such as name, email, age, gender ect ]\n manager = Queryset(Accounts)\n\n # Filter accounts with age greater than 25 and exclude if gender is male\n data = manager.filter(age__gt=20).exclude(gender='male')\n \n # Filter using lamda \n data = manager.filter(age=lambda x: x >= 20 and x <= 30).exclude(gender='male')\n\n # Filter accounts with the name starting with letter 's' and gender is female\n data = manager.filter(name__istartswith='s').exclude(gender='female')\n \n # Filter accounts who have registred from 2014 till 2016 of current date and who are a female\n data = manager.filter(registered__date_range=(datetime.today().replace(year=2014), datetime.today().replace(year=2016))).exclude(gender='female')\n\n # Filter accounts who have registred from 01-01-2015 till 2016 and who are a female if date is string object\n data = manager.filter(registered__date_range=('01-01-2015', '01-01-2016')).exclude(gender='female')\n\n\nFiltering\n---------\n\nYou can filter data by value or lookups, such as gt, gte ect.\n\nBelow are code examples of filtering, \n\n.. code:: python\n\n from iterable_orm import QuerySet\n Accounts = [A list of account objects that have attrubtes such as name, email, age, gender ect ]\n manager = Queryset(Accounts)\n\n # Filter accounts with age greater that 25 \n data = manager.filter(age__gt=20)\n\n # Filter accounts with age less that 25 and who are a male\n data = manager.filter(age__lt=20, gender='male')\n\n # Get number of accounts with age 20 and who are a female\n data = manager.filter(age__gt=20, gender='female').count()\n \n # Filter accounts with name starting with letter 's'\n data = manager.filter(name__istartswith='s')\n \n # Filter accounts who have registred from 01-01-2015 till 2016\n data = manager.filter(registered__date_range=('01-01-2015', '01-01-2016')) \n \n # Filter accounts who have friends who are a male\n data = manager.filter(friends__gender='male')\n \n # Filter accounts with date range\n data = manager.filter(registered__value_range=('2015-11-15', '2015-11-16')\n\n # chain filter e.g\n data = manager.filter(name__istartswith='s').filter(gender='male')\n\n\nExcluding\n---------\n\nYou can Exclude data by value or lookups such as gt, gte ect.\nBelow are code examples of exlcude function:\n\n.. code:: python\n\n from iterable_orm import QuerySet\n Accounts = [A list of account objects that have attrubtes such as name, email, age, gender ect ]\n manager = Queryset(Accounts)\n\n # Exclude accounts with age greater that 25\n data = manager.exclude(age__gt=20)\n\n # Exclude accounts with age less then 25 and who are a male\n data = manager.exclude(age__lt=20, gender='male')\n\n # Exclude accounts with name starting with letter 's'\n data = manager.filter(name__istartswith='s')\n \n # Exclude accounts who have registred from 01-01-2015 till 2016\n data = manager.exclude(registered__date_range=('01-01-2015', '01-01-2016'))\n \n # Exclude accounts who have friends who are a male\n data = manager.filter(friends__gender='male')\n\n # Chain exclude e.g.\n data = manager.exclude(name__istartswith='s').exclude(gender='male')\n\n\nOrdering\n--------\n\nYou can order data by any value of object or dictionary :\n\n.. code:: python\n\n from iterable_orm import QuerySet\n Accounts = [A list of account objects that have attrubtes such as name, email, age, gender ect ]\n manager = Queryset(Accounts)\n\n # Order by name \n data = manager.order_by('name)\n\n # Order name by descending\n data = manager.order_by('-name)\n \n # Ordering by related lookup of friends name\n data = manager.order_by('friends__name')\n \n # Ordering by related lookup of friends name descending\n data = manager.order_by('-friends__name')\n\n\nUnit Test\n---------\n\nUnit test inlcudes full example usage of the API\n\nTo tun unit test run:\n\n.. code:: python\n\n python test.py\n\n\nInstallation\n============\n\nInstall the latest release with:\n\n::\n\n pip install iterable_orm\n\n\nCompatibility\n-------------\n\nPython 2.7, 3.0 to 3.5", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Said007/iterable_orm", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "iterable_orm", "package_url": "https://pypi.org/project/iterable_orm/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/iterable_orm/", "project_urls": { "Homepage": "https://github.com/Said007/iterable_orm" }, "release_url": "https://pypi.org/project/iterable_orm/0.4/", "requires_dist": null, "requires_python": "", "summary": "Query API similar to Django for Python objects and dictionaries", "version": "0.4" }, "last_serial": 2427217, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "d955b3fbe2a3c2b12216bc29195c8927", "sha256": "6c2ef6f43bcda01c56ad3d58deca3760c1f2f96c1c037abd6a8ef9b83a2842b7" }, "downloads": -1, "filename": "iterable_orm-0.1.tar.gz", "has_sig": false, "md5_digest": "d955b3fbe2a3c2b12216bc29195c8927", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6592, "upload_time": "2016-05-24T22:25:38", "url": "https://files.pythonhosted.org/packages/85/f5/d0329ab167dac376171bfdd1b1087e1a467a9671e43c5d827e10b24b90b6/iterable_orm-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "19b8b91c4841624e162f78750c9e38aa", "sha256": "a1abe5c38fa03504e863ea4391624e7941cc140b6842a8117c5d155d07d93074" }, "downloads": -1, "filename": "iterable_orm-0.2.tar.gz", "has_sig": false, "md5_digest": "19b8b91c4841624e162f78750c9e38aa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6594, "upload_time": "2016-05-24T22:36:15", "url": "https://files.pythonhosted.org/packages/93/de/fff0bc530159875bac0836e6412f7a52466c59dc7b12a14ab179504b949e/iterable_orm-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "16a9d9a0537b7875edd2f09038b052bc", "sha256": "4e5031ae638dad9cc30658984700fbd2af07847b1f9adc8f79d59c0682a62872" }, "downloads": -1, "filename": "iterable_orm-0.3.tar.gz", "has_sig": false, "md5_digest": "16a9d9a0537b7875edd2f09038b052bc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6666, "upload_time": "2016-05-26T09:10:52", "url": "https://files.pythonhosted.org/packages/03/ea/2b16110af6600a48197def8723aab99983731bc44c64600554e8603a1aba/iterable_orm-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "e923402177fc3420ea5c597409dc9c7f", "sha256": "32c28f9a4b1526c9e1b4cb23c65a85428fde5ba117eac7fc8394ec5d0a9b411f" }, "downloads": -1, "filename": "iterable_orm-0.4.tar.gz", "has_sig": false, "md5_digest": "e923402177fc3420ea5c597409dc9c7f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6683, "upload_time": "2016-10-27T21:26:01", "url": "https://files.pythonhosted.org/packages/88/da/828f2170c170b5bd3f338fa2bf49dc8a962039970c5ed583a0207cd6bfdb/iterable_orm-0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e923402177fc3420ea5c597409dc9c7f", "sha256": "32c28f9a4b1526c9e1b4cb23c65a85428fde5ba117eac7fc8394ec5d0a9b411f" }, "downloads": -1, "filename": "iterable_orm-0.4.tar.gz", "has_sig": false, "md5_digest": "e923402177fc3420ea5c597409dc9c7f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6683, "upload_time": "2016-10-27T21:26:01", "url": "https://files.pythonhosted.org/packages/88/da/828f2170c170b5bd3f338fa2bf49dc8a962039970c5ed583a0207cd6bfdb/iterable_orm-0.4.tar.gz" } ] }