singleton-meta


Namesingleton-meta JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/centroid457/
Summarycreate perfect singletons
upload_time2024-03-27 08:40:56
maintainerNone
docs_urlNone
authorAndrei Starichenko
requires_python>=3.6
licenseNone
keywords singleton singleton meta singleton call singleton new
VCS
bugtrack_url
requirements pytest requirements-checker object-info funcs-aux
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # singleton_meta (v0.1.2)

## DESCRIPTION_SHORT
create perfect singletons

## DESCRIPTION_LONG
designed for singletons creation


## Features
1. perfect singleton (maybe thread safe!)  
2. collect all instances  
3. check correct instantiating singletons in tree project  


********************************************************************************
## License
See the [LICENSE](LICENSE) file for license rights and limitations (MIT).


## Release history
See the [HISTORY.md](HISTORY.md) file for release history.


## Installation
```commandline
pip install singleton-meta
```


## Import
```python
from singleton_meta import *
```


********************************************************************************
## USAGE EXAMPLES
See tests and sourcecode for other examples.

------------------------------
### 1. example1.py
```python
from singleton_meta import *

class MySingleton(SingletonByCallMeta):
    pass

class MySingleton2(SingletonByCallMeta):
    pass

class MySingleton(metaclass=SingletonMetaCallClass):
    pass


# ===============================
# 2. access to created instances
from singleton_meta import *

class Victim1(SingletonByCallMeta):
    attr = 1

class Victim2(SingletonByCallMeta):
    attr = 2

assert SingletonByCallMeta._SINGLETONS == []
Victim1()
assert SingletonByCallMeta._SINGLETONS == [Victim1(), ]
assert Victim1._SINGLETONS == [Victim1(), ]
assert Victim1()._SINGLETONS == [Victim1(), ]
Victim2()
assert SingletonByCallMeta._SINGLETONS == [Victim1(), Victim2(), ]


# ===============================
# 3. NOTICE: all your Singletons must be only last classes!
# don't use nesting from any Your Singletons!
from singleton_meta import *

class MySingleton(SingletonByCallMeta):  # OK
    pass

class MySingleton2(MySingleton):  # WRONG
    pass
```

********************************************************************************

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/centroid457/",
    "name": "singleton-meta",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "singleton, singleton meta, singleton call, singleton new",
    "author": "Andrei Starichenko",
    "author_email": "centroid@mail.ru",
    "download_url": "https://files.pythonhosted.org/packages/73/24/78ac5051dd50cf940acabc59aeff9676b6761ef6bec4ec3dde9fbc4b9cfd/singleton_meta-0.1.2.tar.gz",
    "platform": null,
    "description": "# singleton_meta (v0.1.2)\r\n\r\n## DESCRIPTION_SHORT\r\ncreate perfect singletons\r\n\r\n## DESCRIPTION_LONG\r\ndesigned for singletons creation\r\n\r\n\r\n## Features\r\n1. perfect singleton (maybe thread safe!)  \r\n2. collect all instances  \r\n3. check correct instantiating singletons in tree project  \r\n\r\n\r\n********************************************************************************\r\n## License\r\nSee the [LICENSE](LICENSE) file for license rights and limitations (MIT).\r\n\r\n\r\n## Release history\r\nSee the [HISTORY.md](HISTORY.md) file for release history.\r\n\r\n\r\n## Installation\r\n```commandline\r\npip install singleton-meta\r\n```\r\n\r\n\r\n## Import\r\n```python\r\nfrom singleton_meta import *\r\n```\r\n\r\n\r\n********************************************************************************\r\n## USAGE EXAMPLES\r\nSee tests and sourcecode for other examples.\r\n\r\n------------------------------\r\n### 1. example1.py\r\n```python\r\nfrom singleton_meta import *\r\n\r\nclass MySingleton(SingletonByCallMeta):\r\n    pass\r\n\r\nclass MySingleton2(SingletonByCallMeta):\r\n    pass\r\n\r\nclass MySingleton(metaclass=SingletonMetaCallClass):\r\n    pass\r\n\r\n\r\n# ===============================\r\n# 2. access to created instances\r\nfrom singleton_meta import *\r\n\r\nclass Victim1(SingletonByCallMeta):\r\n    attr = 1\r\n\r\nclass Victim2(SingletonByCallMeta):\r\n    attr = 2\r\n\r\nassert SingletonByCallMeta._SINGLETONS == []\r\nVictim1()\r\nassert SingletonByCallMeta._SINGLETONS == [Victim1(), ]\r\nassert Victim1._SINGLETONS == [Victim1(), ]\r\nassert Victim1()._SINGLETONS == [Victim1(), ]\r\nVictim2()\r\nassert SingletonByCallMeta._SINGLETONS == [Victim1(), Victim2(), ]\r\n\r\n\r\n# ===============================\r\n# 3. NOTICE: all your Singletons must be only last classes!\r\n# don't use nesting from any Your Singletons!\r\nfrom singleton_meta import *\r\n\r\nclass MySingleton(SingletonByCallMeta):  # OK\r\n    pass\r\n\r\nclass MySingleton2(MySingleton):  # WRONG\r\n    pass\r\n```\r\n\r\n********************************************************************************\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "create perfect singletons",
    "version": "0.1.2",
    "project_urls": {
        "Homepage": "https://github.com/centroid457/",
        "Source": "https://github.com/centroid457/singleton_meta"
    },
    "split_keywords": [
        "singleton",
        " singleton meta",
        " singleton call",
        " singleton new"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d7e3bec8d2c73f744a06674a81c8d5692e4d6808a8b5f94bb9b646dc8f9b8f56",
                "md5": "1ce75e80d679f8c5c8c0363912b25db1",
                "sha256": "8cf6bc9f142bcdc389536ee3664154e929d59009c9c5bca76131949a16114d4b"
            },
            "downloads": -1,
            "filename": "singleton_meta-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1ce75e80d679f8c5c8c0363912b25db1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 5354,
            "upload_time": "2024-03-27T08:40:54",
            "upload_time_iso_8601": "2024-03-27T08:40:54.755611Z",
            "url": "https://files.pythonhosted.org/packages/d7/e3/bec8d2c73f744a06674a81c8d5692e4d6808a8b5f94bb9b646dc8f9b8f56/singleton_meta-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "732478ac5051dd50cf940acabc59aeff9676b6761ef6bec4ec3dde9fbc4b9cfd",
                "md5": "61641f4b47c8b4565b876257181f5f2b",
                "sha256": "3d8c4726a69632da1c6b1980bb819f4bcb6927d1be35504ca9b02930e014183e"
            },
            "downloads": -1,
            "filename": "singleton_meta-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "61641f4b47c8b4565b876257181f5f2b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 5230,
            "upload_time": "2024-03-27T08:40:56",
            "upload_time_iso_8601": "2024-03-27T08:40:56.428193Z",
            "url": "https://files.pythonhosted.org/packages/73/24/78ac5051dd50cf940acabc59aeff9676b6761ef6bec4ec3dde9fbc4b9cfd/singleton_meta-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-27 08:40:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "centroid457",
    "github_project": "singleton_meta",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "pytest",
            "specs": []
        },
        {
            "name": "requirements-checker",
            "specs": []
        },
        {
            "name": "object-info",
            "specs": []
        },
        {
            "name": "funcs-aux",
            "specs": []
        }
    ],
    "lcname": "singleton-meta"
}
        
Elapsed time: 0.22122s