diff options
author | Michał Górny <mgorny@gentoo.org> | 2017-10-28 23:45:50 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2017-10-28 23:45:50 +0200 |
commit | cedf103b0abe2d760d05ba83a29af16ee3f7ae44 (patch) | |
tree | 46fd765c58d176b4a4505304f938cf788ba0a482 | |
parent | 3b16e92628986dc7fae3bc666f6c2d42125ec132 (diff) | |
download | gemato-cedf103b0abe2d760d05ba83a29af16ee3f7ae44.tar.gz |
Declare __slots__ for classes
-rw-r--r-- | gemato/compression.py | 2 | ||||
-rw-r--r-- | gemato/exceptions.py | 8 | ||||
-rw-r--r-- | gemato/hash.py | 2 | ||||
-rw-r--r-- | gemato/manifest.py | 8 | ||||
-rw-r--r-- | gemato/openpgp.py | 2 | ||||
-rw-r--r-- | gemato/recursiveloader.py | 5 |
6 files changed, 27 insertions, 0 deletions
diff --git a/gemato/compression.py b/gemato/compression.py index f3854fb..51850f7 100644 --- a/gemato/compression.py +++ b/gemato/compression.py @@ -70,6 +70,8 @@ class FileStack(object): all on exit. """ + __slots__ = ['files'] + def __init__(self, files=[]): self.files = files diff --git a/gemato/exceptions.py b/gemato/exceptions.py index cbbcb12..b4fa29b 100644 --- a/gemato/exceptions.py +++ b/gemato/exceptions.py @@ -21,6 +21,8 @@ class ManifestSyntaxError(Exception): class ManifestIncompatibleEntry(Exception): + __slots__ = ['e1', 'e2', 'diff'] + def __init__(self, e1, e2, diff): msg = "Incompatible Manifest entries for {}".format(e1.path) for k, d1, d2 in diff: @@ -36,6 +38,8 @@ class ManifestMismatch(Exception): An exception raised for verification failure. """ + __slots__ = ['path', 'entry', 'diff'] + def __init__(self, path, entry, diff): msg = "Manifest mismatch for {}".format(path) for k, exp, got in diff: @@ -51,6 +55,8 @@ class ManifestCrossDevice(Exception): An exception caused by attempting to cross filesystem boundaries. """ + __slots__ = ['path'] + def __init__(self, path): self.path = path super(ManifestCrossDevice, self).__init__( @@ -106,6 +112,8 @@ class ManifestInvalidPath(Exception): Manifest. """ + __slots__ = ['path', 'detail'] + def __init__(self, path, detail): self.path = path self.detail = detail diff --git a/gemato/hash.py b/gemato/hash.py index a5b3074..3b4eb44 100644 --- a/gemato/hash.py +++ b/gemato/hash.py @@ -17,6 +17,8 @@ class SizeHash(object): A cheap wrapper to count file size via hashlib-like interface. """ + __slots__ = ['size'] + def __init__(self): self.size = 0 diff --git a/gemato/manifest.py b/gemato/manifest.py index f0438e9..b6d6652 100644 --- a/gemato/manifest.py +++ b/gemato/manifest.py @@ -17,6 +17,7 @@ class ManifestEntryTIMESTAMP(object): ISO-8601 timestamp. """ + __slots__ = ['ts'] tag = 'TIMESTAMP' def __init__(self, ts): @@ -45,6 +46,8 @@ class ManifestPathEntry(object): Base class for entries using a path. """ + __slots__ = ['path'] + def __init__(self, path): assert path[0] != '/' self.path = path @@ -102,6 +105,8 @@ class ManifestFileEntry(ManifestPathEntry): Base class for entries providing checksums for a path. """ + __slots__ = ['checksums', 'size'] + def __init__(self, path, size, checksums): super(ManifestFileEntry, self).__init__(path) self.size = size @@ -241,6 +246,7 @@ class ManifestEntryAUX(ManifestFileEntry): Deprecated AUX file reference (DATA with 'files/' prepended). """ + __slots__ = ['aux_path'] tag = 'AUX' def __init__(self, aux_path, size, checksums): @@ -301,6 +307,8 @@ class ManifestFile(object): from files and writing to them. """ + __slots__ = ['entries', 'openpgp_signed'] + def __init__(self, f=None): """ Create a new instance. If @f is provided, reads the entries diff --git a/gemato/openpgp.py b/gemato/openpgp.py index 123f3fc..83044b6 100644 --- a/gemato/openpgp.py +++ b/gemato/openpgp.py @@ -41,6 +41,8 @@ class OpenPGPEnvironment(object): or use as a context manager (via 'with'). """ + __slots__ = ['_home'] + def __init__(self): self._home = tempfile.mkdtemp() diff --git a/gemato/recursiveloader.py b/gemato/recursiveloader.py index 9e1ac61..be3b738 100644 --- a/gemato/recursiveloader.py +++ b/gemato/recursiveloader.py @@ -19,6 +19,10 @@ class ManifestRecursiveLoader(object): and provides methods to access the entries in them. """ + __slots__ = ['root_directory', 'loaded_manifests', 'verify_openpgp', + 'openpgp_env', 'sign_openpgp', 'openpgp_keyid', 'hashes', + 'openpgp_signed', 'updated_manifests', 'manifest_device'] + def __init__(self, top_manifest_path, verify_openpgp=True, openpgp_env=None, sign_openpgp=None, openpgp_keyid=None, @@ -45,6 +49,7 @@ class ManifestRecursiveLoader(object): subsequent update*() calls that do not specify another set of hashes explicitly. """ + self.root_directory = os.path.dirname(top_manifest_path) self.loaded_manifests = {} self.verify_openpgp = verify_openpgp |