From 941b6c7eff72de618bb34eeb5983ed2795988a32 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Mon, 24 Oct 2016 13:52:45 +0200 Subject: feat(src): subst `reduce` with `sum` for size calcs + fix(loose-db): fix bad-attr in ex-message --- gitdb/db/base.py | 3 +-- gitdb/db/loose.py | 4 ++-- gitdb/db/pack.py | 2 -- 3 files changed, 3 insertions(+), 6 deletions(-) (limited to 'gitdb/db') diff --git a/gitdb/db/base.py b/gitdb/db/base.py index 2d7b9fa..6dbee21 100644 --- a/gitdb/db/base.py +++ b/gitdb/db/base.py @@ -16,7 +16,6 @@ from gitdb.exc import ( ) from itertools import chain -from functools import reduce __all__ = ('ObjectDBR', 'ObjectDBW', 'FileDBBase', 'CompoundDB', 'CachingDB') @@ -209,7 +208,7 @@ class CompoundDB(ObjectDBR, LazyMixin, CachingDB): def size(self): """:return: total size of all contained databases""" - return reduce(lambda x, y: x + y, (db.size() for db in self._dbs), 0) + return sum(db.size() for db in self._dbs) def sha_iter(self): return chain(*(db.sha_iter() for db in self._dbs)) diff --git a/gitdb/db/loose.py b/gitdb/db/loose.py index 192c524..374cdc7 100644 --- a/gitdb/db/loose.py +++ b/gitdb/db/loose.py @@ -57,7 +57,7 @@ import tempfile import os -__all__ = ('LooseObjectDB', ) +__all__ = ('LooseObjectDB',) class LooseObjectDB(FileDBBase, ObjectDBR, ObjectDBW): @@ -150,7 +150,7 @@ class LooseObjectDB(FileDBBase, ObjectDBR, ObjectDBW): def set_ostream(self, stream): """:raise TypeError: if the stream does not support the Sha1Writer interface""" if stream is not None and not isinstance(stream, Sha1Writer): - raise TypeError("Output stream musst support the %s interface" % Sha1Writer.__name__) + raise TypeError("Output stream must support the %s interface" % Sha1Writer) return super(LooseObjectDB, self).set_ostream(stream) def info(self, sha): diff --git a/gitdb/db/pack.py b/gitdb/db/pack.py index 6b03d83..12ec43a 100644 --- a/gitdb/db/pack.py +++ b/gitdb/db/pack.py @@ -20,8 +20,6 @@ from gitdb.exc import ( from gitdb.pack import PackEntity from gitdb.utils.compat import xrange -from functools import reduce - import os import glob -- cgit v1.2.1