Metadata-Version: 2.0
Name: easy-class
Version: 1.0.0.dev1
Summary: Helpers for Generic Python Classes
Home-page: https://github.com/soheltarir/EasyClass
Author: Sohel Tarir
Author-email: sohel.tarir@gmail.com
License: BSD License
Keywords: development metaclass class generics
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Provides-Extra: dev
Requires-Dist: check-manifest; extra == 'dev'
Provides-Extra: test
Requires-Dist: coverage; extra == 'test'

==========
EASY Class
==========

EASY Class is a toolkit for creating generic classes in an elegant way.

-----
Usage
-----

.. code:: python

    from easy_class import EasyClass, StringVariable, IntegerVariable


    class MyClass(EasyClass):
        attr1 = IntegerVariable()
        attr2 = StringVariable()

The above code declares a class with two member variables **attr1** and
**attr2**, where **attr1** can only be an integer value and **attr2**
can only be a string. Hence, if you try to do the following

.. code:: python

    obj = MyClass()
    obj.attr1 = "Test"

it will raise the exception ``TypeError: attr1 expects int type, but received str.``

------------------------
Class Variable Reference
------------------------

All Variable types (i.e. IntegerVariable, StringVariable) are inherited
from the class **Variable** which represents a class attribute type.
Below contains all the API references of **Variable** including the
variable options and field types this package offers.

Variable options
----------------

The following arguments are available to all variable types. All are
optional.

null
----
Variable.null
~~~~~~~~~~~~~
If **False** the attribute cannot
be assigned a **NULL** variable. Default is **True**. You cannot also
instantiate a class which has any Non-nullable attributes without
specifying the correct arguments. Below is what I meant to say.

.. code:: python

    class MyClass(EasyClass):
        attr1 = IntegerVariable(null=False)
        attr2 = StringVariable(null=False)

    obj = MyClass()

The above will raise the exception ``ValueError: Following attributes cannot be null: [attr2, attr1]``

choices
-------

Variable.choices
~~~~~~~~~~~~~~~~

A list to use as choices for the attribute. Will raise exception if
value being is stored is not included in this list of choices.

default
-------

Variable.default
~~~~~~~~~~~~~~~~

The default value for the attribute. Right now, callables are not
supported.

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

Variable Types
--------------

IntegerVariable
---------------

An Integer Variable

StringVariable
--------------

A string variable, for small- to large-sized strings. **StringVariable**
has the following extra arguments

StringVariable.max\_length
~~~~~~~~~~~~~~~~~~~~~~~~~~

The maximum length (in characters) of the attribute. Defaults **255**.

StringVariable.min\_length
~~~~~~~~~~~~~~~~~~~~~~~~~~

The minimum length (in characters) of the attribute. Defaults **0**.

