singleton-meta


Namesingleton-meta JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/centroid457/
Summarycreate perfect singletons
upload_time2024-05-22 13:49:03
maintainerNone
docs_urlNone
authorAndrei Starichenko
requires_python>=3.6
licenseNone
keywords singleton singleton meta singleton call singleton new
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # singleton_meta (v0.1.3)

## 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/76/5f/7be94390a563cdbf2ae62fb867a013663a5c9ed8aa60e786387f1438485d/singleton_meta-0.1.3.tar.gz",
    "platform": null,
    "description": "# singleton_meta (v0.1.3)\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.3",
    "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": "e430e2015d2c55cbe141e268e0fb20b1498f236d0acb8b88b5de9f972f9f2eda",
                "md5": "521c4d2b0a9ac8ed55e41793502fe38c",
                "sha256": "5948702b1d9cd6c3cb0c6dce83f620f4ff658532bfec47d2bb464f50a0daba2b"
            },
            "downloads": -1,
            "filename": "singleton_meta-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "521c4d2b0a9ac8ed55e41793502fe38c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 5660,
            "upload_time": "2024-05-22T13:49:01",
            "upload_time_iso_8601": "2024-05-22T13:49:01.828970Z",
            "url": "https://files.pythonhosted.org/packages/e4/30/e2015d2c55cbe141e268e0fb20b1498f236d0acb8b88b5de9f972f9f2eda/singleton_meta-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "765f7be94390a563cdbf2ae62fb867a013663a5c9ed8aa60e786387f1438485d",
                "md5": "65ce726f7e9703f35eb1e1c18b074312",
                "sha256": "68eb788b9c3a43b39a68e5f9fdbf0ef0466e31c45c6c6a118bfea84780eee413"
            },
            "downloads": -1,
            "filename": "singleton_meta-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "65ce726f7e9703f35eb1e1c18b074312",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 5483,
            "upload_time": "2024-05-22T13:49:03",
            "upload_time_iso_8601": "2024-05-22T13:49:03.009327Z",
            "url": "https://files.pythonhosted.org/packages/76/5f/7be94390a563cdbf2ae62fb867a013663a5c9ed8aa60e786387f1438485d/singleton_meta-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-22 13:49:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "centroid457",
    "github_project": "singleton_meta",
    "github_not_found": true,
    "lcname": "singleton-meta"
}
        
Elapsed time: 0.46470s