-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae61f8c
commit 3119896
Showing
8 changed files
with
127 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Example configuration for Black. | ||
|
||
# NOTE: you have to use single-quoted strings in TOML for regular expressions. | ||
# It's the equivalent of r-strings in Python. Multiline strings are treated as | ||
# verbose regular expressions by Black. Use [ ] to denote a significant space | ||
# character. | ||
|
||
[tool.black] | ||
line-length = 79 | ||
target-version = ['py36', 'py37', 'py38', 'py39'] | ||
include = '\.pyi?$' | ||
extend-exclude = ''' | ||
/( | ||
# The following are specific to Black, you probably don't want those. | ||
| blib2to3 | ||
| tests/data | ||
| profiling | ||
| migrations | ||
)/ | ||
''' | ||
|
||
|
||
# Build system information below. | ||
# NOTE: You don't need this in your own Black configuration. | ||
|
||
[build-system] | ||
requires = ["setuptools>=41.0", "setuptools-scm", "wheel"] | ||
build-backend = "setuptools.build_meta" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,12 @@ | ||
from typing import Dict | ||
import warnings | ||
from .base import Registry | ||
|
||
__author__ = 'Artur Barseghyan' | ||
__copyright__ = '2013-2020 Artur Barseghyan' | ||
__license__ = 'MPL-1.1 OR GPL-2.0-only OR LGPL-2.1-or-later' | ||
__all__ = ( | ||
'Registry', | ||
) | ||
|
||
|
||
class Registry(type): | ||
|
||
REGISTRY = {} # type: Dict[str, Registry] | ||
|
||
def __new__(mcs, name, bases, attrs): | ||
new_cls = type.__new__(mcs, name, bases, attrs) | ||
# Here the name of the class is used as key but it could be any class | ||
# parameter. | ||
if getattr(new_cls, '_uid', None): | ||
mcs.REGISTRY[new_cls._uid] = new_cls | ||
return new_cls | ||
__author__ = "Artur Barseghyan" | ||
__copyright__ = "2013-2021 Artur Barseghyan" | ||
__license__ = "MPL-1.1 OR GPL-2.0-only OR LGPL-2.1-or-later" | ||
__all__ = ("Registry",) | ||
|
||
@property | ||
def _uid(cls) -> str: | ||
return getattr(cls, 'uid', cls.__name__) | ||
|
||
@classmethod | ||
def reset(mcs) -> None: | ||
mcs.REGISTRY = {} | ||
|
||
@classmethod | ||
def get(mcs, key, default=None): | ||
return mcs.REGISTRY.get(key, default) | ||
|
||
@classmethod | ||
def items(mcs): | ||
return mcs.REGISTRY.items() | ||
|
||
# @classmethod | ||
# def get_registry(mcs) -> Dict[str, Type]: | ||
# return dict(mcs.REGISTRY) | ||
# | ||
# @classmethod | ||
# def pop(mcs, uid) -> None: | ||
# mcs.REGISTRY.pop(uid) | ||
warnings.warn( | ||
"The `Registry` class is moved from `tld.registry` to `tld.base`.", | ||
DeprecationWarning, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters