cobble


Namecobble JSON
Version 0.1.4 PyPI version JSON
download
home_pagehttp://github.com/mwilliamson/python-cobble
SummaryCreate data objects
upload_time2024-06-01 18:11:09
maintainerNone
docs_urlNone
authorMichael Williamson
requires_python>=3.5
licenseNone
keywords data object case class
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Cobble
======

Cobble is a Python library that allows easy creation of data objects,
including implementations of common methods such as ``__eq__`` and ``__repr__``.

Examples
--------

.. code-block:: python

    import cobble

    @cobble.data
    class Song(object):
        name = cobble.field()
        artist = cobble.field()
        album = cobble.field(default=None)


    song = Song("MFEO", artist="Jack's Mannequin")

    print(song) # Prints "Song(name='MFEO', artist="Jack's Mannequin", album=None)"

.. code-block:: python

    class Expression(object):
        pass

    @cobble.data
    class Literal(Expression):
        value = cobble.field()

    @cobble.data
    class Add(Expression):
        left = cobble.field()
        right = cobble.field()
    
    class Evaluator(cobble.visitor(Expression)):
        def visit_literal(self, literal):
            return literal.value
        
        def visit_add(self, add):
            return self.visit(add.left) + self.visit(add.right)

    Evaluator().visit(Add(Literal(2), Literal(4))) # 6

.. code-block:: python

    class Expression(object):
        pass

    @cobble.visitable
    class Literal(Expression):
        def __init__(self, value):
            self.value = value

    @cobble.visitable
    class Add(Expression):
        def __init__(self, left, right):
            self.left = left
            self.right = right
    
    class Evaluator(cobble.visitor(Expression)):
        def visit_literal(self, literal):
            return literal.value
        
        def visit_add(self, add):
            return self.visit(add.left) + self.visit(add.right)

    Evaluator().visit(Add(Literal(2), Literal(4))) # 6

License
-------

`2-Clause BSD <http://opensource.org/licenses/BSD-2-Clause>`_

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/mwilliamson/python-cobble",
    "name": "cobble",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": null,
    "keywords": "data object case class",
    "author": "Michael Williamson",
    "author_email": "mike@zwobble.org",
    "download_url": "https://files.pythonhosted.org/packages/54/7a/a507c709be2c96e1bb6102eb7b7f4026c5e5e223ef7d745a17d239e9d844/cobble-0.1.4.tar.gz",
    "platform": null,
    "description": "Cobble\n======\n\nCobble is a Python library that allows easy creation of data objects,\nincluding implementations of common methods such as ``__eq__`` and ``__repr__``.\n\nExamples\n--------\n\n.. code-block:: python\n\n    import cobble\n\n    @cobble.data\n    class Song(object):\n        name = cobble.field()\n        artist = cobble.field()\n        album = cobble.field(default=None)\n\n\n    song = Song(\"MFEO\", artist=\"Jack's Mannequin\")\n\n    print(song) # Prints \"Song(name='MFEO', artist=\"Jack's Mannequin\", album=None)\"\n\n.. code-block:: python\n\n    class Expression(object):\n        pass\n\n    @cobble.data\n    class Literal(Expression):\n        value = cobble.field()\n\n    @cobble.data\n    class Add(Expression):\n        left = cobble.field()\n        right = cobble.field()\n    \n    class Evaluator(cobble.visitor(Expression)):\n        def visit_literal(self, literal):\n            return literal.value\n        \n        def visit_add(self, add):\n            return self.visit(add.left) + self.visit(add.right)\n\n    Evaluator().visit(Add(Literal(2), Literal(4))) # 6\n\n.. code-block:: python\n\n    class Expression(object):\n        pass\n\n    @cobble.visitable\n    class Literal(Expression):\n        def __init__(self, value):\n            self.value = value\n\n    @cobble.visitable\n    class Add(Expression):\n        def __init__(self, left, right):\n            self.left = left\n            self.right = right\n    \n    class Evaluator(cobble.visitor(Expression)):\n        def visit_literal(self, literal):\n            return literal.value\n        \n        def visit_add(self, add):\n            return self.visit(add.left) + self.visit(add.right)\n\n    Evaluator().visit(Add(Literal(2), Literal(4))) # 6\n\nLicense\n-------\n\n`2-Clause BSD <http://opensource.org/licenses/BSD-2-Clause>`_\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Create data objects",
    "version": "0.1.4",
    "project_urls": {
        "Homepage": "http://github.com/mwilliamson/python-cobble"
    },
    "split_keywords": [
        "data",
        "object",
        "case",
        "class"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d5e13714a2f371985215c219c2a70953d38e3eed81ef165aed061d21de0e998b",
                "md5": "a3a42ef8ac625f78c17cd1a2f493f50d",
                "sha256": "36c91b1655e599fd428e2b95fdd5f0da1ca2e9f1abb0bc871dec21a0e78a2b44"
            },
            "downloads": -1,
            "filename": "cobble-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a3a42ef8ac625f78c17cd1a2f493f50d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5",
            "size": 3984,
            "upload_time": "2024-06-01T18:11:07",
            "upload_time_iso_8601": "2024-06-01T18:11:07.911036Z",
            "url": "https://files.pythonhosted.org/packages/d5/e1/3714a2f371985215c219c2a70953d38e3eed81ef165aed061d21de0e998b/cobble-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "547aa507c709be2c96e1bb6102eb7b7f4026c5e5e223ef7d745a17d239e9d844",
                "md5": "375872d0e07f30b38b72c0aa2cc4a741",
                "sha256": "de38be1539992c8a06e569630717c485a5f91be2192c461ea2b220607dfa78aa"
            },
            "downloads": -1,
            "filename": "cobble-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "375872d0e07f30b38b72c0aa2cc4a741",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 3805,
            "upload_time": "2024-06-01T18:11:09",
            "upload_time_iso_8601": "2024-06-01T18:11:09.528772Z",
            "url": "https://files.pythonhosted.org/packages/54/7a/a507c709be2c96e1bb6102eb7b7f4026c5e5e223ef7d745a17d239e9d844/cobble-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-01 18:11:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mwilliamson",
    "github_project": "python-cobble",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "tox": true,
    "lcname": "cobble"
}
        
Elapsed time: 0.43515s