mandrake


Namemandrake JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/estaleiroweb/mandrake
SummaryAll Magic Methods Implement. You can easyly to implement all magic methods or part of them
upload_time2023-03-18 21:22:23
maintainer
docs_urlNone
authorHelbert Braga Fernandes
requires_python>=2.0
licenseMIT License
keywords magic methods class
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Description

> Version: 0.0.1
> python 2.x,3.x

All Magic Methods Implement.

You can easyly to implement all magic methods or part of them

## Donate

**PIX**: +55 31 99101-8619

## Contact

**URL**: [http://estaleiroweb.com.br](http://estaleiroweb.com.br)

**GIT**: [https://github.com/estaleiroweb/mandrake](https://github.com/HelbertFernandes/mandrake)

# Instalation

> pip install mandrake

# Upgrade

> pip install mandrake -upgrade

# Use

```python
from mandrake import AllMethods

class MyClass(AllMethods): ...
```

```python
from mandrake import AttributeMethods

class MyClass(AttributeMethods):
   def __init__(self):
      super().__init__()
      self._start_init()
      self.attr1 = 1
      self._end_init()

   def _set_value(self,val):
      self.__dict__['value']=val * 2

   def _set_attr2(self,val):
      self.__dict__['attr2']=val * 3

c = MyClass()
c.value = 2
c.attr1 = 2
c.attr2 = 2
c.attr3 = 2
print({'value': {'check': hasattr(c, 'value'), 'val': c.value}})
print({'attr1': {'check': hasattr(c, 'attr1'), 'val': c.attr1}})
print({'attr2': {'check': hasattr(c, 'attr2'), 'val': c.attr2}})
print({'attr3': {'check': hasattr(c, 'attr3')}})

'''Response: 
{'value': {'check': True, 'val': 4}}
{'attr1': {'check': True, 'val': 2}}
{'attr2': {'check': True, 'val': 6}}
{'attr3': {'check': False}}
'''
```

## MainMethods

Any classes bellow will inherit this class.

It implement then `__init__` method this `value` attribute.

The children classes must be the methods `_start_init()` and `_end_init()` to define attributes of class or if wish, you can not use `_end_init()` permiting add any attribute to this object

## MathMethods

Implement all Math magic methods

## FunctionMethods

Implement all Function magic methods

## LogicMethods

Implement all Logic magic methods

## BinaryMethods

Implement all Binary magic methods

## StringMethods

Implement all String magic methods

## CastMethods

Implement all Cast magic methods

## AttributeMethods

You can creating `_set_<attr>` methods to assure the correct value

## AllMethods

The same all classes above



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/estaleiroweb/mandrake",
    "name": "mandrake",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=2.0",
    "maintainer_email": "",
    "keywords": "magic methods class",
    "author": "Helbert Braga Fernandes",
    "author_email": "helbertfernandes@gmail.com",
    "download_url": "",
    "platform": null,
    "description": "# Description\r\n\r\n> Version: 0.0.1\r\n> python 2.x,3.x\r\n\r\nAll Magic Methods Implement.\r\n\r\nYou can easyly to implement all magic methods or part of them\r\n\r\n## Donate\r\n\r\n**PIX**: +55 31 99101-8619\r\n\r\n## Contact\r\n\r\n**URL**: [http://estaleiroweb.com.br](http://estaleiroweb.com.br)\r\n\r\n**GIT**: [https://github.com/estaleiroweb/mandrake](https://github.com/HelbertFernandes/mandrake)\r\n\r\n# Instalation\r\n\r\n> pip install mandrake\r\n\r\n# Upgrade\r\n\r\n> pip install mandrake -upgrade\r\n\r\n# Use\r\n\r\n```python\r\nfrom mandrake import AllMethods\r\n\r\nclass MyClass(AllMethods): ...\r\n```\r\n\r\n```python\r\nfrom mandrake import AttributeMethods\r\n\r\nclass MyClass(AttributeMethods):\r\n   def __init__(self):\r\n      super().__init__()\r\n      self._start_init()\r\n      self.attr1 = 1\r\n      self._end_init()\r\n\r\n   def _set_value(self,val):\r\n      self.__dict__['value']=val * 2\r\n\r\n   def _set_attr2(self,val):\r\n      self.__dict__['attr2']=val * 3\r\n\r\nc = MyClass()\r\nc.value = 2\r\nc.attr1 = 2\r\nc.attr2 = 2\r\nc.attr3 = 2\r\nprint({'value': {'check': hasattr(c, 'value'), 'val': c.value}})\r\nprint({'attr1': {'check': hasattr(c, 'attr1'), 'val': c.attr1}})\r\nprint({'attr2': {'check': hasattr(c, 'attr2'), 'val': c.attr2}})\r\nprint({'attr3': {'check': hasattr(c, 'attr3')}})\r\n\r\n'''Response: \r\n{'value': {'check': True, 'val': 4}}\r\n{'attr1': {'check': True, 'val': 2}}\r\n{'attr2': {'check': True, 'val': 6}}\r\n{'attr3': {'check': False}}\r\n'''\r\n```\r\n\r\n## MainMethods\r\n\r\nAny classes bellow will inherit this class.\r\n\r\nIt implement then `__init__` method this `value` attribute.\r\n\r\nThe children classes must be the methods `_start_init()` and `_end_init()` to define attributes of class or if wish, you can not use `_end_init()` permiting add any attribute to this object\r\n\r\n## MathMethods\r\n\r\nImplement all Math magic methods\r\n\r\n## FunctionMethods\r\n\r\nImplement all Function magic methods\r\n\r\n## LogicMethods\r\n\r\nImplement all Logic magic methods\r\n\r\n## BinaryMethods\r\n\r\nImplement all Binary magic methods\r\n\r\n## StringMethods\r\n\r\nImplement all String magic methods\r\n\r\n## CastMethods\r\n\r\nImplement all Cast magic methods\r\n\r\n## AttributeMethods\r\n\r\nYou can creating `_set_<attr>` methods to assure the correct value\r\n\r\n## AllMethods\r\n\r\nThe same all classes above\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "All Magic Methods Implement. You can easyly to implement all magic methods or part of them",
    "version": "0.0.2",
    "split_keywords": [
        "magic",
        "methods",
        "class"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1946f5b41bee6e58709b2752f875ff08f58975ba4066df208aecb1868f8a638d",
                "md5": "3e2942b07969aeee572f7c3977813376",
                "sha256": "cf862f3746fa87c7802e1eaa76ae25f1bf47069f1b1c61a8fcbd3e4cef7894a4"
            },
            "downloads": -1,
            "filename": "mandrake-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3e2942b07969aeee572f7c3977813376",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=2.0",
            "size": 5290,
            "upload_time": "2023-03-18T21:22:23",
            "upload_time_iso_8601": "2023-03-18T21:22:23.553873Z",
            "url": "https://files.pythonhosted.org/packages/19/46/f5b41bee6e58709b2752f875ff08f58975ba4066df208aecb1868f8a638d/mandrake-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-18 21:22:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "estaleiroweb",
    "github_project": "mandrake",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "mandrake"
}
        
Elapsed time: 0.05133s