]> Cypherpunks.ru repositories - pygost.git/blob - pygost/iface.py
2.3 release is ready
[pygost.git] / pygost / iface.py
1 from abc import ABCMeta
2 from abc import abstractmethod
3
4
5 # This function is taken from six package as is
6 def add_metaclass(metaclass):
7     """Class decorator for creating a class with a metaclass."""
8     def wrapper(cls):
9         orig_vars = cls.__dict__.copy()
10         slots = orig_vars.get('__slots__')
11         if slots is not None:
12             if isinstance(slots, str):
13                 slots = [slots]
14             for slots_var in slots:
15                 orig_vars.pop(slots_var)
16         orig_vars.pop('__dict__', None)
17         orig_vars.pop('__weakref__', None)
18         return metaclass(cls.__name__, cls.__bases__, orig_vars)
19     return wrapper
20
21
22 @add_metaclass(ABCMeta)
23 class PEP247(object):
24     @property
25     @abstractmethod
26     def digest_size(self):
27         """The size of the digest produced by the hashing objects.
28         """
29
30     @abstractmethod
31     def copy(self):
32         """Return a separate copy of this hashing object.
33         """
34
35     @abstractmethod
36     def update(self, data):
37         """Hash data into the current state of the hashing object.
38         """
39
40     @abstractmethod
41     def digest(self):
42         """Return the hash value as a string containing 8-bit data.
43         """
44
45     @abstractmethod
46     def hexdigest(self):
47         """Return the hash value as a string containing hexadecimal digits.
48         """