Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib64/python3....
File: abc.py
# Copyright 2007 Google, Inc. All Rights Reserved.
[0] Fix | Delete
# Licensed to PSF under a Contributor Agreement.
[1] Fix | Delete
[2] Fix | Delete
"""Abstract Base Classes (ABCs) according to PEP 3119."""
[3] Fix | Delete
[4] Fix | Delete
[5] Fix | Delete
def abstractmethod(funcobj):
[6] Fix | Delete
"""A decorator indicating abstract methods.
[7] Fix | Delete
[8] Fix | Delete
Requires that the metaclass is ABCMeta or derived from it. A
[9] Fix | Delete
class that has a metaclass derived from ABCMeta cannot be
[10] Fix | Delete
instantiated unless all of its abstract methods are overridden.
[11] Fix | Delete
The abstract methods can be called using any of the normal
[12] Fix | Delete
'super' call mechanisms. abstractmethod() may be used to declare
[13] Fix | Delete
abstract methods for properties and descriptors.
[14] Fix | Delete
[15] Fix | Delete
Usage:
[16] Fix | Delete
[17] Fix | Delete
class C(metaclass=ABCMeta):
[18] Fix | Delete
@abstractmethod
[19] Fix | Delete
def my_abstract_method(self, ...):
[20] Fix | Delete
...
[21] Fix | Delete
"""
[22] Fix | Delete
funcobj.__isabstractmethod__ = True
[23] Fix | Delete
return funcobj
[24] Fix | Delete
[25] Fix | Delete
[26] Fix | Delete
class abstractclassmethod(classmethod):
[27] Fix | Delete
"""A decorator indicating abstract classmethods.
[28] Fix | Delete
[29] Fix | Delete
Deprecated, use 'classmethod' with 'abstractmethod' instead.
[30] Fix | Delete
"""
[31] Fix | Delete
[32] Fix | Delete
__isabstractmethod__ = True
[33] Fix | Delete
[34] Fix | Delete
def __init__(self, callable):
[35] Fix | Delete
callable.__isabstractmethod__ = True
[36] Fix | Delete
super().__init__(callable)
[37] Fix | Delete
[38] Fix | Delete
[39] Fix | Delete
class abstractstaticmethod(staticmethod):
[40] Fix | Delete
"""A decorator indicating abstract staticmethods.
[41] Fix | Delete
[42] Fix | Delete
Deprecated, use 'staticmethod' with 'abstractmethod' instead.
[43] Fix | Delete
"""
[44] Fix | Delete
[45] Fix | Delete
__isabstractmethod__ = True
[46] Fix | Delete
[47] Fix | Delete
def __init__(self, callable):
[48] Fix | Delete
callable.__isabstractmethod__ = True
[49] Fix | Delete
super().__init__(callable)
[50] Fix | Delete
[51] Fix | Delete
[52] Fix | Delete
class abstractproperty(property):
[53] Fix | Delete
"""A decorator indicating abstract properties.
[54] Fix | Delete
[55] Fix | Delete
Deprecated, use 'property' with 'abstractmethod' instead.
[56] Fix | Delete
"""
[57] Fix | Delete
[58] Fix | Delete
__isabstractmethod__ = True
[59] Fix | Delete
[60] Fix | Delete
[61] Fix | Delete
try:
[62] Fix | Delete
from _abc import (get_cache_token, _abc_init, _abc_register,
[63] Fix | Delete
_abc_instancecheck, _abc_subclasscheck, _get_dump,
[64] Fix | Delete
_reset_registry, _reset_caches)
[65] Fix | Delete
except ImportError:
[66] Fix | Delete
from _py_abc import ABCMeta, get_cache_token
[67] Fix | Delete
ABCMeta.__module__ = 'abc'
[68] Fix | Delete
else:
[69] Fix | Delete
class ABCMeta(type):
[70] Fix | Delete
"""Metaclass for defining Abstract Base Classes (ABCs).
[71] Fix | Delete
[72] Fix | Delete
Use this metaclass to create an ABC. An ABC can be subclassed
[73] Fix | Delete
directly, and then acts as a mix-in class. You can also register
[74] Fix | Delete
unrelated concrete classes (even built-in classes) and unrelated
[75] Fix | Delete
ABCs as 'virtual subclasses' -- these and their descendants will
[76] Fix | Delete
be considered subclasses of the registering ABC by the built-in
[77] Fix | Delete
issubclass() function, but the registering ABC won't show up in
[78] Fix | Delete
their MRO (Method Resolution Order) nor will method
[79] Fix | Delete
implementations defined by the registering ABC be callable (not
[80] Fix | Delete
even via super()).
[81] Fix | Delete
"""
[82] Fix | Delete
def __new__(mcls, name, bases, namespace, **kwargs):
[83] Fix | Delete
cls = super().__new__(mcls, name, bases, namespace, **kwargs)
[84] Fix | Delete
_abc_init(cls)
[85] Fix | Delete
return cls
[86] Fix | Delete
[87] Fix | Delete
def register(cls, subclass):
[88] Fix | Delete
"""Register a virtual subclass of an ABC.
[89] Fix | Delete
[90] Fix | Delete
Returns the subclass, to allow usage as a class decorator.
[91] Fix | Delete
"""
[92] Fix | Delete
return _abc_register(cls, subclass)
[93] Fix | Delete
[94] Fix | Delete
def __instancecheck__(cls, instance):
[95] Fix | Delete
"""Override for isinstance(instance, cls)."""
[96] Fix | Delete
return _abc_instancecheck(cls, instance)
[97] Fix | Delete
[98] Fix | Delete
def __subclasscheck__(cls, subclass):
[99] Fix | Delete
"""Override for issubclass(subclass, cls)."""
[100] Fix | Delete
return _abc_subclasscheck(cls, subclass)
[101] Fix | Delete
[102] Fix | Delete
def _dump_registry(cls, file=None):
[103] Fix | Delete
"""Debug helper to print the ABC registry."""
[104] Fix | Delete
print(f"Class: {cls.__module__}.{cls.__qualname__}", file=file)
[105] Fix | Delete
print(f"Inv. counter: {get_cache_token()}", file=file)
[106] Fix | Delete
(_abc_registry, _abc_cache, _abc_negative_cache,
[107] Fix | Delete
_abc_negative_cache_version) = _get_dump(cls)
[108] Fix | Delete
print(f"_abc_registry: {_abc_registry!r}", file=file)
[109] Fix | Delete
print(f"_abc_cache: {_abc_cache!r}", file=file)
[110] Fix | Delete
print(f"_abc_negative_cache: {_abc_negative_cache!r}", file=file)
[111] Fix | Delete
print(f"_abc_negative_cache_version: {_abc_negative_cache_version!r}",
[112] Fix | Delete
file=file)
[113] Fix | Delete
[114] Fix | Delete
def _abc_registry_clear(cls):
[115] Fix | Delete
"""Clear the registry (for debugging or testing)."""
[116] Fix | Delete
_reset_registry(cls)
[117] Fix | Delete
[118] Fix | Delete
def _abc_caches_clear(cls):
[119] Fix | Delete
"""Clear the caches (for debugging or testing)."""
[120] Fix | Delete
_reset_caches(cls)
[121] Fix | Delete
[122] Fix | Delete
[123] Fix | Delete
class ABC(metaclass=ABCMeta):
[124] Fix | Delete
"""Helper class that provides a standard way to create an ABC using
[125] Fix | Delete
inheritance.
[126] Fix | Delete
"""
[127] Fix | Delete
__slots__ = ()
[128] Fix | Delete
[129] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function