Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/imh-pyth.../lib/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
class C(ABC):
[32] Fix | Delete
@classmethod
[33] Fix | Delete
@abstractmethod
[34] Fix | Delete
def my_abstract_classmethod(cls, ...):
[35] Fix | Delete
...
[36] Fix | Delete
[37] Fix | Delete
"""
[38] Fix | Delete
[39] Fix | Delete
__isabstractmethod__ = True
[40] Fix | Delete
[41] Fix | Delete
def __init__(self, callable):
[42] Fix | Delete
callable.__isabstractmethod__ = True
[43] Fix | Delete
super().__init__(callable)
[44] Fix | Delete
[45] Fix | Delete
[46] Fix | Delete
class abstractstaticmethod(staticmethod):
[47] Fix | Delete
"""A decorator indicating abstract staticmethods.
[48] Fix | Delete
[49] Fix | Delete
Deprecated, use 'staticmethod' with 'abstractmethod' instead:
[50] Fix | Delete
[51] Fix | Delete
class C(ABC):
[52] Fix | Delete
@staticmethod
[53] Fix | Delete
@abstractmethod
[54] Fix | Delete
def my_abstract_staticmethod(...):
[55] Fix | Delete
...
[56] Fix | Delete
[57] Fix | Delete
"""
[58] Fix | Delete
[59] Fix | Delete
__isabstractmethod__ = True
[60] Fix | Delete
[61] Fix | Delete
def __init__(self, callable):
[62] Fix | Delete
callable.__isabstractmethod__ = True
[63] Fix | Delete
super().__init__(callable)
[64] Fix | Delete
[65] Fix | Delete
[66] Fix | Delete
class abstractproperty(property):
[67] Fix | Delete
"""A decorator indicating abstract properties.
[68] Fix | Delete
[69] Fix | Delete
Deprecated, use 'property' with 'abstractmethod' instead:
[70] Fix | Delete
[71] Fix | Delete
class C(ABC):
[72] Fix | Delete
@property
[73] Fix | Delete
@abstractmethod
[74] Fix | Delete
def my_abstract_property(self):
[75] Fix | Delete
...
[76] Fix | Delete
[77] Fix | Delete
"""
[78] Fix | Delete
[79] Fix | Delete
__isabstractmethod__ = True
[80] Fix | Delete
[81] Fix | Delete
[82] Fix | Delete
try:
[83] Fix | Delete
from _abc import (get_cache_token, _abc_init, _abc_register,
[84] Fix | Delete
_abc_instancecheck, _abc_subclasscheck, _get_dump,
[85] Fix | Delete
_reset_registry, _reset_caches)
[86] Fix | Delete
except ImportError:
[87] Fix | Delete
from _py_abc import ABCMeta, get_cache_token
[88] Fix | Delete
ABCMeta.__module__ = 'abc'
[89] Fix | Delete
else:
[90] Fix | Delete
class ABCMeta(type):
[91] Fix | Delete
"""Metaclass for defining Abstract Base Classes (ABCs).
[92] Fix | Delete
[93] Fix | Delete
Use this metaclass to create an ABC. An ABC can be subclassed
[94] Fix | Delete
directly, and then acts as a mix-in class. You can also register
[95] Fix | Delete
unrelated concrete classes (even built-in classes) and unrelated
[96] Fix | Delete
ABCs as 'virtual subclasses' -- these and their descendants will
[97] Fix | Delete
be considered subclasses of the registering ABC by the built-in
[98] Fix | Delete
issubclass() function, but the registering ABC won't show up in
[99] Fix | Delete
their MRO (Method Resolution Order) nor will method
[100] Fix | Delete
implementations defined by the registering ABC be callable (not
[101] Fix | Delete
even via super()).
[102] Fix | Delete
"""
[103] Fix | Delete
def __new__(mcls, name, bases, namespace, **kwargs):
[104] Fix | Delete
cls = super().__new__(mcls, name, bases, namespace, **kwargs)
[105] Fix | Delete
_abc_init(cls)
[106] Fix | Delete
return cls
[107] Fix | Delete
[108] Fix | Delete
def register(cls, subclass):
[109] Fix | Delete
"""Register a virtual subclass of an ABC.
[110] Fix | Delete
[111] Fix | Delete
Returns the subclass, to allow usage as a class decorator.
[112] Fix | Delete
"""
[113] Fix | Delete
return _abc_register(cls, subclass)
[114] Fix | Delete
[115] Fix | Delete
def __instancecheck__(cls, instance):
[116] Fix | Delete
"""Override for isinstance(instance, cls)."""
[117] Fix | Delete
return _abc_instancecheck(cls, instance)
[118] Fix | Delete
[119] Fix | Delete
def __subclasscheck__(cls, subclass):
[120] Fix | Delete
"""Override for issubclass(subclass, cls)."""
[121] Fix | Delete
return _abc_subclasscheck(cls, subclass)
[122] Fix | Delete
[123] Fix | Delete
def _dump_registry(cls, file=None):
[124] Fix | Delete
"""Debug helper to print the ABC registry."""
[125] Fix | Delete
print(f"Class: {cls.__module__}.{cls.__qualname__}", file=file)
[126] Fix | Delete
print(f"Inv. counter: {get_cache_token()}", file=file)
[127] Fix | Delete
(_abc_registry, _abc_cache, _abc_negative_cache,
[128] Fix | Delete
_abc_negative_cache_version) = _get_dump(cls)
[129] Fix | Delete
print(f"_abc_registry: {_abc_registry!r}", file=file)
[130] Fix | Delete
print(f"_abc_cache: {_abc_cache!r}", file=file)
[131] Fix | Delete
print(f"_abc_negative_cache: {_abc_negative_cache!r}", file=file)
[132] Fix | Delete
print(f"_abc_negative_cache_version: {_abc_negative_cache_version!r}",
[133] Fix | Delete
file=file)
[134] Fix | Delete
[135] Fix | Delete
def _abc_registry_clear(cls):
[136] Fix | Delete
"""Clear the registry (for debugging or testing)."""
[137] Fix | Delete
_reset_registry(cls)
[138] Fix | Delete
[139] Fix | Delete
def _abc_caches_clear(cls):
[140] Fix | Delete
"""Clear the caches (for debugging or testing)."""
[141] Fix | Delete
_reset_caches(cls)
[142] Fix | Delete
[143] Fix | Delete
[144] Fix | Delete
class ABC(metaclass=ABCMeta):
[145] Fix | Delete
"""Helper class that provides a standard way to create an ABC using
[146] Fix | Delete
inheritance.
[147] Fix | Delete
"""
[148] Fix | Delete
__slots__ = ()
[149] Fix | Delete
[150] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function