makeobj


Namemakeobj JSON
Version 0.9 PyPI version JSON
download
home_pageNone
SummaryPowerful Enumeration System
upload_time2024-12-14 19:57:40
maintainerNone
docs_urlNone
authorNone
requires_python>=2.6
licenseBSD-3-Clause
keywords enum language enum enumeration
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            MakeObj - Powerful Enumeration System
=====================================

* Author:    João Bernardo Oliveira ([@jbvsmo](http://twitter.com/jbvsmo))
* Version:   0.9
* GitHub:    <https://github.com/jbvsmo/makeobj>
* Wiki:      <https://github.com/jbvsmo/makeobj/wiki>

MakeObj is a module to help create powerful enumeration classes with support
to attributes specific for each element.

This module is compatible with Python versions 2.6+ and 3.0+

Using it
========

MakeObj lets you create enumerations with a simple language like that:

```python
@obj RGBColors =:
    @keys = 'red', 'green', 'blue'

    @attr hex = 'ff0000', '00ff00', '0000ff'

    @attr is_nice =:
        @default = False
        @set => 'blue': True
```

Then you can use like this:

```python
RGBColors = makeobj.parse(text)

if RGBColors.blue.is_nice:
    print('I like blue')

print('The hex value of {0.name} is #{0.hex}'.format(RGBColors.red))
```


If you have simple enums, you can use like this:

```python
RGBColors = makeobj.make('RGBColors', ['red', 'green', 'blue'])
```

or, with some more data, one may want to write a class:

```python
class RGBColors(makeobj.Obj):
    red, green, blue = makeobj.keys(3)
    hex = makeobj.attr('ff0000', '00ff00', '0000ff')
```

Status
======

This project is in test stage and some issues are expected mainly in the parsing language.
It will parse conformant code, but still may not show all the errors and may load an invalid
file skipping some data when it should raise an error.

The `make` function works fine but it may be easier to write a class instead. The
`SubObj` machinery (see the [Wiki](https://github.com/jbvsmo/makeobj/wiki/Enum-Language) entry)
only works in the Enum Language. Yet!



Features
========

 * Enumerations with simple attributes, methods or even small objects with their own attributes.
 * An Enumeration Language for easy creation of objects.
 * The enumeration by default use the values 0 to N-1 but you may specify your own values.
 * The elements of the class are really instances of it and can take advantage of the `isinstance`
   function. Because of a metaclass factory, the classes do not share unwanted attributes with
   the instances.
 * The elements come with two attributes by default: `name` and `value` (also `_name` and `_value`
   in case you want to override them).
 * Elements can (and should!) be checked with the `is` comparison and can be retrieved by name in string
   form or value from their class: `RGBColors('red')` or `RGBColors[0]` or `RGBColors.red` result in the
   same object.
 * Enum values must be integer for simplicity and to help usability.
 * Subclassing is great!

TODO
====

 * Finalize the specs of MakeObj Enum Language v1.0.
 * Change the `@method` property to allow better function/method support
 * Create a helper function to load a directory of `.makeobj` files as they
   were a python module.
 * Better suport on subclassing: multiple inheritance, parent default attributes
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "makeobj",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=2.6",
    "maintainer_email": null,
    "keywords": "Enum Language, enum, enumeration",
    "author": null,
    "author_email": "Jo\u00e3o Bernardo Oliveira <jbvsmo@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/8d/9d/85fb20b55e5f9e076c16d7f3de2e54745f0c3c4df79e6e684413bd51a4cd/makeobj-0.9.tar.gz",
    "platform": null,
    "description": "MakeObj - Powerful Enumeration System\n=====================================\n\n* Author:    Jo\u00e3o Bernardo Oliveira ([@jbvsmo](http://twitter.com/jbvsmo))\n* Version:   0.9\n* GitHub:    <https://github.com/jbvsmo/makeobj>\n* Wiki:      <https://github.com/jbvsmo/makeobj/wiki>\n\nMakeObj is a module to help create powerful enumeration classes with support\nto attributes specific for each element.\n\nThis module is compatible with Python versions 2.6+ and 3.0+\n\nUsing it\n========\n\nMakeObj lets you create enumerations with a simple language like that:\n\n```python\n@obj RGBColors =:\n    @keys = 'red', 'green', 'blue'\n\n    @attr hex = 'ff0000', '00ff00', '0000ff'\n\n    @attr is_nice =:\n        @default = False\n        @set => 'blue': True\n```\n\nThen you can use like this:\n\n```python\nRGBColors = makeobj.parse(text)\n\nif RGBColors.blue.is_nice:\n    print('I like blue')\n\nprint('The hex value of {0.name} is #{0.hex}'.format(RGBColors.red))\n```\n\n\nIf you have simple enums, you can use like this:\n\n```python\nRGBColors = makeobj.make('RGBColors', ['red', 'green', 'blue'])\n```\n\nor, with some more data, one may want to write a class:\n\n```python\nclass RGBColors(makeobj.Obj):\n    red, green, blue = makeobj.keys(3)\n    hex = makeobj.attr('ff0000', '00ff00', '0000ff')\n```\n\nStatus\n======\n\nThis project is in test stage and some issues are expected mainly in the parsing language.\nIt will parse conformant code, but still may not show all the errors and may load an invalid\nfile skipping some data when it should raise an error.\n\nThe `make` function works fine but it may be easier to write a class instead. The\n`SubObj` machinery (see the [Wiki](https://github.com/jbvsmo/makeobj/wiki/Enum-Language) entry)\nonly works in the Enum Language. Yet!\n\n\n\nFeatures\n========\n\n * Enumerations with simple attributes, methods or even small objects with their own attributes.\n * An Enumeration Language for easy creation of objects.\n * The enumeration by default use the values 0 to N-1 but you may specify your own values.\n * The elements of the class are really instances of it and can take advantage of the `isinstance`\n   function. Because of a metaclass factory, the classes do not share unwanted attributes with\n   the instances.\n * The elements come with two attributes by default: `name` and `value` (also `_name` and `_value`\n   in case you want to override them).\n * Elements can (and should!) be checked with the `is` comparison and can be retrieved by name in string\n   form or value from their class: `RGBColors('red')` or `RGBColors[0]` or `RGBColors.red` result in the\n   same object.\n * Enum values must be integer for simplicity and to help usability.\n * Subclassing is great!\n\nTODO\n====\n\n * Finalize the specs of MakeObj Enum Language v1.0.\n * Change the `@method` property to allow better function/method support\n * Create a helper function to load a directory of `.makeobj` files as they\n   were a python module.\n * Better suport on subclassing: multiple inheritance, parent default attributes",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "Powerful Enumeration System",
    "version": "0.9",
    "project_urls": null,
    "split_keywords": [
        "enum language",
        " enum",
        " enumeration"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "796324b029f3ebae4f3936ecf6eef211f18900bc26c2314b089853d7b985b48e",
                "md5": "a7ab3c5479fdae372834977db668947a",
                "sha256": "85e0235c731120dd5a7d967ec687f3704161e2825ddaf2b36e134790ae7a506f"
            },
            "downloads": -1,
            "filename": "makeobj-0.9-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a7ab3c5479fdae372834977db668947a",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=2.6",
            "size": 14414,
            "upload_time": "2024-12-14T19:57:38",
            "upload_time_iso_8601": "2024-12-14T19:57:38.320096Z",
            "url": "https://files.pythonhosted.org/packages/79/63/24b029f3ebae4f3936ecf6eef211f18900bc26c2314b089853d7b985b48e/makeobj-0.9-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8d9d85fb20b55e5f9e076c16d7f3de2e54745f0c3c4df79e6e684413bd51a4cd",
                "md5": "23efbf3cbb70f9202391d7fcaaad0ec4",
                "sha256": "e3fbd41ad671151953e9479ef107bf3949cb37d1c7089c3c9b2986d07b5be719"
            },
            "downloads": -1,
            "filename": "makeobj-0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "23efbf3cbb70f9202391d7fcaaad0ec4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=2.6",
            "size": 16604,
            "upload_time": "2024-12-14T19:57:40",
            "upload_time_iso_8601": "2024-12-14T19:57:40.877508Z",
            "url": "https://files.pythonhosted.org/packages/8d/9d/85fb20b55e5f9e076c16d7f3de2e54745f0c3c4df79e6e684413bd51a4cd/makeobj-0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-14 19:57:40",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "makeobj"
}
        
Elapsed time: 5.07091s