======
Thingy
======
.. image:: https://img.shields.io/pypi/v/thingy.svg
:target: https://pypi.python.org/pypi/Thingy
.. image:: https://img.shields.io/github/license/Refty/thingy.svg
:target: https://github.com/Refty/thingy/blob/master/LICENSE
.. image:: https://img.shields.io/travis/Refty/thingy.svg
:target: https://travis-ci.org/Refty/thingy
.. image:: https://img.shields.io/coveralls/Refty/thingy.svg
:target: https://coveralls.io/github/Refty/thingy
.. image:: https://readthedocs.org/projects/python-thingy/badge
:target: https://python-thingy.readthedocs.io
|
Dictionaries as objects, that can have different dictionary views!
Install
=======
.. code-block:: sh
$ pip install thingy
Examples
========
Dictionaries as objects...
--------------------------
.. code-block:: python
>>> class MyThingy(Thingy)
... @property
... def foobaz(self):
... return self.foo + self.baz
>>> thingy = MyThingy({"foo": "bar", "baz": "qux"})
>>> thingy.foo
"bar"
>>> thingy.foobaz
"barqux"
>>> thingy.foo = "BARRRR"
>>> thingy.view()
{"foo": "BARRRR", "baz": "qux"}
...that can have different dictionary views!
--------------------------------------------
.. code-block:: python
>>> MyThingy.add_view(name="fooz", include=["foo", "foobaz"])
>>> MyThingy.add_view(name="no_foo", defaults=True, exclude="foo")
>>> thingy = MyThingy({"foo": "bar", "baz": "qux"})
>>> thingy.view("fooz")
{"foo": "bar", "foobaz": "barqux"}
>>> thingy.view("no_foo")
{"baz": "qux"}
Why Thingy?
===========
Because it's much more enjoyable to write ``foo.bar`` than ``foo["bar"]``.
Thingy is mainly meant to be used inside other libraries to provide abstractions
over dictionaries, which can be useful for writing ORMs or similar utilities.
Thingy's views system is also particularly useful as-is when you intensively
manipulate dictionaries and often restrict those dictionaries to a few redundant
items.
Tests
=====
To run Thingy tests:
* install developers requirements with ``pip install -r requirements.txt``;
* run ``pytest``.
Sponsors
========
.. image:: https://raw.githubusercontent.com/Refty/thingy/master/img/numberly.png
:alt: Numberly
:align: center
:target: https://numberly.com/
|
.. image:: https://raw.githubusercontent.com/Refty/thingy/master/img/refty.png
:alt: Refty
:align: center
:target: https://refty.co/
License
=======
MIT
Raw data
{
"_id": null,
"home_page": "https://github.com/Refty/thingy",
"name": "Thingy",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Guillaume Gelin",
"author_email": "guillaume@refty.co",
"download_url": "https://files.pythonhosted.org/packages/8b/a8/17bd2539b6c8d0cc23c875e8af8691ed400dca178fc56946b37616a336c1/Thingy-0.10.0.tar.gz",
"platform": "any",
"description": "======\nThingy\n======\n\n.. image:: https://img.shields.io/pypi/v/thingy.svg\n :target: https://pypi.python.org/pypi/Thingy\n.. image:: https://img.shields.io/github/license/Refty/thingy.svg\n :target: https://github.com/Refty/thingy/blob/master/LICENSE\n.. image:: https://img.shields.io/travis/Refty/thingy.svg\n :target: https://travis-ci.org/Refty/thingy\n.. image:: https://img.shields.io/coveralls/Refty/thingy.svg\n :target: https://coveralls.io/github/Refty/thingy\n.. image:: https://readthedocs.org/projects/python-thingy/badge\n :target: https://python-thingy.readthedocs.io\n\n|\n\nDictionaries as objects, that can have different dictionary views!\n\n\nInstall\n=======\n\n.. code-block:: sh\n\n $ pip install thingy\n\n\nExamples\n========\n\nDictionaries as objects...\n--------------------------\n\n.. code-block:: python\n\n >>> class MyThingy(Thingy)\n ... @property\n ... def foobaz(self):\n ... return self.foo + self.baz\n\n >>> thingy = MyThingy({\"foo\": \"bar\", \"baz\": \"qux\"})\n >>> thingy.foo\n \"bar\"\n >>> thingy.foobaz\n \"barqux\"\n\n >>> thingy.foo = \"BARRRR\"\n >>> thingy.view()\n {\"foo\": \"BARRRR\", \"baz\": \"qux\"}\n\n\n...that can have different dictionary views!\n--------------------------------------------\n\n.. code-block:: python\n\n >>> MyThingy.add_view(name=\"fooz\", include=[\"foo\", \"foobaz\"])\n >>> MyThingy.add_view(name=\"no_foo\", defaults=True, exclude=\"foo\")\n\n >>> thingy = MyThingy({\"foo\": \"bar\", \"baz\": \"qux\"})\n >>> thingy.view(\"fooz\")\n {\"foo\": \"bar\", \"foobaz\": \"barqux\"}\n >>> thingy.view(\"no_foo\")\n {\"baz\": \"qux\"}\n\n\nWhy Thingy?\n===========\n\nBecause it's much more enjoyable to write ``foo.bar`` than ``foo[\"bar\"]``.\n\nThingy is mainly meant to be used inside other libraries to provide abstractions\nover dictionaries, which can be useful for writing ORMs or similar utilities.\n\nThingy's views system is also particularly useful as-is when you intensively\nmanipulate dictionaries and often restrict those dictionaries to a few redundant\nitems.\n\n\nTests\n=====\n\nTo run Thingy tests:\n\n* install developers requirements with ``pip install -r requirements.txt``;\n* run ``pytest``.\n\n\nSponsors\n========\n\n.. image:: https://raw.githubusercontent.com/Refty/thingy/master/img/numberly.png\n :alt: Numberly\n :align: center\n :target: https://numberly.com/\n\n|\n\n.. image:: https://raw.githubusercontent.com/Refty/thingy/master/img/refty.png\n :alt: Refty\n :align: center\n :target: https://refty.co/\n\n\nLicense\n=======\n\nMIT\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Dictionary as an object, that can have different views",
"version": "0.10.0",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "76774c999ef19be1eab8b3ffdcf2cde77426030a0f4763061f54e92a97738912",
"md5": "80ae2a763eca954a57e254abb02cc5ad",
"sha256": "438394e6bd415962f7558442a47680d9e87b661cbf3fa8831904205143a0459e"
},
"downloads": -1,
"filename": "Thingy-0.10.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "80ae2a763eca954a57e254abb02cc5ad",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4559,
"upload_time": "2023-04-18T12:46:14",
"upload_time_iso_8601": "2023-04-18T12:46:14.646597Z",
"url": "https://files.pythonhosted.org/packages/76/77/4c999ef19be1eab8b3ffdcf2cde77426030a0f4763061f54e92a97738912/Thingy-0.10.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8ba817bd2539b6c8d0cc23c875e8af8691ed400dca178fc56946b37616a336c1",
"md5": "f14d1e3a342690d4179a837cc09c3e77",
"sha256": "a372734da8e723ee5e2e6178dec5230b07195db8bf3121f23a44efb4d8aeac71"
},
"downloads": -1,
"filename": "Thingy-0.10.0.tar.gz",
"has_sig": false,
"md5_digest": "f14d1e3a342690d4179a837cc09c3e77",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4579,
"upload_time": "2023-04-18T12:46:17",
"upload_time_iso_8601": "2023-04-18T12:46:17.698093Z",
"url": "https://files.pythonhosted.org/packages/8b/a8/17bd2539b6c8d0cc23c875e8af8691ed400dca178fc56946b37616a336c1/Thingy-0.10.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-18 12:46:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "Refty",
"github_project": "thingy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "thingy"
}