Metadata-Version: 1.1
Name: constant2
Version: 0.0.1
Summary: provide extensive way of managing your constant variable.
Home-page: https://github.com/MacHu-GWU/constant2-project
Author: Sanhe Hu
Author-email: husanhe@gmail.com
License: MIT
Download-URL: https://github.com/MacHu-GWU/constant2-project/tarball/2017-05-19
Description: .. image:: https://travis-ci.org/MacHu-GWU/constant2-project.svg?branch=master

        

        .. image:: https://img.shields.io/pypi/v/constant2.svg

        

        .. image:: https://img.shields.io/pypi/l/constant2.svg

        

        .. image:: https://img.shields.io/pypi/pyversions/constant2.svg

        

        

        Welcome to constant2 Documentation

        ==================================

        If you have lots of constant2 value widely used across your development. A better way is to define ``Constantant Variable`` rather than using the raw value. This can improve the readability.

        

        ``constant2`` is a library provide extensive way of managing your constant2 variable.

        

        Example:

        

        .. code-block:: python

        

           from constant2 import Constant

        

        

           class Food(Constant):

        

               class Fruit:

                   id = 1

                   name = "fruit"

        

                   class Apple:

                       id = 1

                       name = "apple"

        

                       class RedApple:

                           id = 1

                           name = "red apple"

        

                       class GreenApple:

                           id = 2

                           name = "green apple"

        

                   class Banana:

                       id = 2

                       name = "banana"

        

                       class YellowBanana:

                           id = 1

                           name = "yellow banana"

        

                       class GreenBanana:

                           id = 2

                           name = "green banana"

        

               class Meat:

                   id = 2

                   name = "meat"

        

                   class Pork:

                       id = 1

                       name = "pork"

        

                   class Meat:

                       id = 2

                       name = "meat"

        

        

        You can visit it's data or child class data in these way.

        

        

        .. code-block:: python

        

            >>> Fruit.items() # .items() return it's    data

            [('id', 1), ('name', 'fruit')]

        

            >>> Fruit.keys() # .keys() return keys

            ['id', 'name']

        

            >>> Fruit.values() # .values() return values

            [1, 'fruit']

        

            >>> Fruit.to_dict() # return data in a dict

            {'id': 1, 'name': 'fruit'}

        

            # iterate on all nested class

            >>> Fruit.nested(sort_by='id')

            [class Apple, class Banana]

        

            # get first nested class that kls.id == 1

            # useful when you need reverse lookup

            >>> Fruit.get_first('id', 1)

            class Apple

        

            # get all child class that kls.id == 1

            >>> Fruit.get_all('id', 1)

            [class Apple, ]    

        

        

        **Quick Links**

        ---------------

        - `GitHub Homepage <https://github.com/MacHu-GWU/constant2-project>`_

        - `Online Documentation <http://pythonhosted.org/constant2>`_

        - `PyPI download <https://pypi.python.org/pypi/constant2>`_

        - `Install <install_>`_

        - `Issue submit and feature request <https://github.com/MacHu-GWU/constant2-project/issues>`_

        - `API reference and source code <http://pythonhosted.org/constant2/py-modindex.html>`_

        

        

        .. _install:

        

        Install

        -------

        

        ``constant2`` is released on PyPI, so all you need is:

        

        .. code-block:: console

        

            $ pip install constant2

        

        To upgrade to latest version:

        

        .. code-block:: console

        

            $ pip install --upgrade constant2
Platform: Windows
Platform: MacOS
Platform: Unix
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: MacOS
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
