Skip to content
This repository was archived by the owner on Apr 14, 2024. It is now read-only.

Commit ff76153

Browse files
committed
Applied autopep8
autopep8 -v -j 8 --max-line-length 120 --in-place --recursive
1 parent 8b49396 commit ff76153

36 files changed

+460
-372
lines changed

‎doc/source/conf.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
# All configuration values have a default; values that are commented out
1212
# serve to show the default.
1313

14-
import sys, os
14+
import sys
15+
import os
1516

1617
# If extensions (or modules to document with autodoc) are in another directory,
1718
# add these directories to sys.path here. If the directory is relative to the
@@ -171,8 +172,8 @@
171172
# Grouping the document tree into LaTeX files. List of tuples
172173
# (source start file, target name, title, author, documentclass [howto/manual]).
173174
latex_documents = [
174-
('index', 'GitDB.tex', u'GitDB Documentation',
175-
u'Sebastian Thiel', 'manual'),
175+
('index', 'GitDB.tex', u'GitDB Documentation',
176+
u'Sebastian Thiel', 'manual'),
176177
]
177178

178179
# The name of an image file (relative to this directory) to place at the top of

‎gitdb/__init__.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import os
99

1010
#{ Initialization
11+
12+
1113
def _init_externals():
1214
"""Initialize external projects by putting them into the path"""
1315
for module in ('smmap',):
@@ -17,8 +19,8 @@ def _init_externals():
1719
__import__(module)
1820
except ImportError:
1921
raise ImportError("'%s' could not be imported, assure it is located in your PYTHONPATH" % module)
20-
#END verify import
21-
#END handel imports
22+
# END verify import
23+
# END handel imports
2224

2325
#} END initialization
2426

‎gitdb/base.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
)
1212

1313
__all__ = ('OInfo', 'OPackInfo', 'ODeltaPackInfo',
14-
'OStream', 'OPackStream', 'ODeltaPackStream',
15-
'IStream', 'InvalidOInfo', 'InvalidOStream' )
14+
'OStream', 'OPackStream', 'ODeltaPackStream',
15+
'IStream', 'InvalidOInfo', 'InvalidOStream')
1616

1717
#{ ODB Bases
1818

19+
1920
class OInfo(tuple):
21+
2022
"""Carries information about an object in an ODB, provding information
2123
about the binary sha of the object, the type_string as well as the uncompressed size
2224
in bytes.
@@ -62,6 +64,7 @@ def size(self):
6264

6365

6466
class OPackInfo(tuple):
67+
6568
"""As OInfo, but provides a type_id property to retrieve the numerical type id, and
6669
does not include a sha.
6770
@@ -71,7 +74,7 @@ class OPackInfo(tuple):
7174
__slots__ = tuple()
7275

7376
def __new__(cls, packoffset, type, size):
74-
return tuple.__new__(cls, (packoffset,type, size))
77+
return tuple.__new__(cls, (packoffset, type, size))
7578

7679
def __init__(self, *args):
7780
tuple.__init__(self)
@@ -98,6 +101,7 @@ def size(self):
98101

99102

100103
class ODeltaPackInfo(OPackInfo):
104+
101105
"""Adds delta specific information,
102106
Either the 20 byte sha which points to some object in the database,
103107
or the negative offset from the pack_offset, so that pack_offset - delta_info yields
@@ -115,6 +119,7 @@ def delta_info(self):
115119

116120

117121
class OStream(OInfo):
122+
118123
"""Base for object streams retrieved from the database, providing additional
119124
information about the stream.
120125
Generally, ODB streams are read-only as objects are immutable"""
@@ -124,7 +129,6 @@ def __new__(cls, sha, type, size, stream, *args, **kwargs):
124129
"""Helps with the initialization of subclasses"""
125130
return tuple.__new__(cls, (sha, type, size, stream))
126131

127-
128132
def __init__(self, *args, **kwargs):
129133
tuple.__init__(self)
130134

@@ -141,6 +145,7 @@ def stream(self):
141145

142146

143147
class ODeltaStream(OStream):
148+
144149
"""Uses size info of its stream, delaying reads"""
145150

146151
def __new__(cls, sha, type, size, stream, *args, **kwargs):
@@ -157,6 +162,7 @@ def size(self):
157162

158163

159164
class OPackStream(OPackInfo):
165+
160166
"""Next to pack object information, a stream outputting an undeltified base object
161167
is provided"""
162168
__slots__ = tuple()
@@ -176,13 +182,13 @@ def stream(self):
176182

177183

178184
class ODeltaPackStream(ODeltaPackInfo):
185+
179186
"""Provides a stream outputting the uncompressed offset delta information"""
180187
__slots__ = tuple()
181188

182189
def __new__(cls, packoffset, type, size, delta_info, stream):
183190
return tuple.__new__(cls, (packoffset, type, size, delta_info, stream))
184191

185-
186192
#{ Stream Reader Interface
187193
def read(self, size=-1):
188194
return self[4].read(size)
@@ -194,6 +200,7 @@ def stream(self):
194200

195201

196202
class IStream(list):
203+
197204
"""Represents an input content stream to be fed into the ODB. It is mutable to allow
198205
the ODB to record information about the operations outcome right in this instance.
199206
@@ -246,7 +253,6 @@ def _binsha(self):
246253

247254
binsha = property(_binsha, _set_binsha)
248255

249-
250256
def _type(self):
251257
return self[1]
252258

@@ -275,6 +281,7 @@ def _set_stream(self, stream):
275281

276282

277283
class InvalidOInfo(tuple):
284+
278285
"""Carries information about a sha identifying an object which is invalid in
279286
the queried database. The exception attribute provides more information about
280287
the cause of the issue"""
@@ -301,6 +308,7 @@ def error(self):
301308

302309

303310
class InvalidOStream(InvalidOInfo):
311+
304312
"""Carries information about an invalid ODB stream"""
305313
__slots__ = tuple()
306314

‎gitdb/db/base.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
from functools import reduce
2020

2121

22-
2322
__all__ = ('ObjectDBR', 'ObjectDBW', 'FileDBBase', 'CompoundDB', 'CachingDB')
2423

2524

2625
class ObjectDBR(object):
26+
2727
"""Defines an interface for object database lookup.
2828
Objects are identified either by their 20 byte bin sha"""
2929

@@ -61,6 +61,7 @@ def sha_iter(self):
6161

6262

6363
class ObjectDBW(object):
64+
6465
"""Defines an interface to create objects in the database"""
6566

6667
def __init__(self, *args, **kwargs):
@@ -100,6 +101,7 @@ def store(self, istream):
100101

101102

102103
class FileDBBase(object):
104+
103105
"""Provides basic facilities to retrieve files of interest, including
104106
caching facilities to help mapping hexsha's to objects"""
105107

@@ -113,7 +115,6 @@ def __init__(self, root_path):
113115
super(FileDBBase, self).__init__()
114116
self._root_path = root_path
115117

116-
117118
#{ Interface
118119
def root_path(self):
119120
""":return: path at which this db operates"""
@@ -128,6 +129,7 @@ def db_path(self, rela_path):
128129

129130

130131
class CachingDB(object):
132+
131133
"""A database which uses caches to speed-up access"""
132134

133135
#{ Interface
@@ -143,8 +145,6 @@ def update_cache(self, force=False):
143145
# END interface
144146

145147

146-
147-
148148
def _databases_recursive(database, output):
149149
"""Fill output list with database from db, in order. Deals with Loose, Packed
150150
and compound databases."""
@@ -159,10 +159,12 @@ def _databases_recursive(database, output):
159159

160160

161161
class CompoundDB(ObjectDBR, LazyMixin, CachingDB):
162+
162163
"""A database which delegates calls to sub-databases.
163164
164165
Databases are stored in the lazy-loaded _dbs attribute.
165166
Define _set_cache_ to update it with your databases"""
167+
166168
def _set_cache_(self, attr):
167169
if attr == '_dbs':
168170
self._dbs = list()
@@ -207,7 +209,7 @@ def stream(self, sha):
207209

208210
def size(self):
209211
""":return: total size of all contained databases"""
210-
return reduce(lambda x,y: x+y, (db.size() for db in self._dbs), 0)
212+
return reduce(lambda x, y: x + y, (db.size() for db in self._dbs), 0)
211213

212214
def sha_iter(self):
213215
return chain(*(db.sha_iter() for db in self._dbs))

‎gitdb/db/git.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121

2222
class GitDB(FileDBBase, ObjectDBW, CompoundDB):
23+
2324
"""A git-style object database, which contains all objects in the 'objects'
2425
subdirectory"""
2526
# Configuration
@@ -41,8 +42,8 @@ def _set_cache_(self, attr):
4142
self._dbs = list()
4243
loose_db = None
4344
for subpath, dbcls in ((self.packs_dir, self.PackDBCls),
44-
(self.loose_dir, self.LooseDBCls),
45-
(self.alternates_dir, self.ReferenceDBCls)):
45+
(self.loose_dir, self.LooseDBCls),
46+
(self.alternates_dir, self.ReferenceDBCls)):
4647
path = self.db_path(subpath)
4748
if os.path.exists(path):
4849
self._dbs.append(dbcls(path))

‎gitdb/db/loose.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@
5757
import os
5858

5959

60-
__all__ = ( 'LooseObjectDB', )
60+
__all__ = ('LooseObjectDB', )
6161

6262

6363
class LooseObjectDB(FileDBBase, ObjectDBR, ObjectDBW):
64+
6465
"""A database which operates on loose object files"""
6566

6667
# CONFIGURATION
@@ -73,7 +74,6 @@ class LooseObjectDB(FileDBBase, ObjectDBR, ObjectDBW):
7374
if os.name == 'nt':
7475
new_objects_mode = int("644", 8)
7576

76-
7777
def __init__(self, root_path):
7878
super(LooseObjectDB, self).__init__(root_path)
7979
self._hexsha_to_file = dict()
@@ -164,7 +164,7 @@ def info(self, sha):
164164

165165
def stream(self, sha):
166166
m = self._map_loose_object(sha)
167-
type, size, stream = DecompressMemMapReader.new(m, close_on_deletion = True)
167+
type, size, stream = DecompressMemMapReader.new(m, close_on_deletion=True)
168168
return OStream(sha, type, size, stream)
169169

170170
def has_object(self, sha):
@@ -199,7 +199,7 @@ def store(self, istream):
199199
else:
200200
# write object with header, we have to make a new one
201201
write_object(istream.type, istream.size, istream.read, writer.write,
202-
chunk_size=self.stream_chunk_size)
202+
chunk_size=self.stream_chunk_size)
203203
# END handle direct stream copies
204204
finally:
205205
if tmp_path:

‎gitdb/db/mem.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828

2929
__all__ = ("MemoryDB", )
3030

31+
3132
class MemoryDB(ObjectDBR, ObjectDBW):
33+
3234
"""A memory database stores everything to memory, providing fast IO and object
3335
retrieval. It should be used to buffer results and obtain SHAs before writing
3436
it to the actual physical storage, as it allows to query whether object already
@@ -85,7 +87,6 @@ def sha_iter(self):
8587
except AttributeError:
8688
return self._cache.keys()
8789

88-
8990
#{ Interface
9091
def stream_copy(self, sha_iter, odb):
9192
"""Copy the streams as identified by sha's yielded by sha_iter into the given odb

‎gitdb/db/pack.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232

3333
class PackedDB(FileDBBase, ObjectDBR, CachingDB, LazyMixin):
34+
3435
"""A database operating on a set of object packs"""
3536

3637
# sort the priority list every N queries
@@ -113,7 +114,7 @@ def sha_iter(self):
113114

114115
def size(self):
115116
sizes = [item[1].index().size() for item in self._entities]
116-
return reduce(lambda x,y: x+y, sizes, 0)
117+
return reduce(lambda x, y: x + y, sizes, 0)
117118

118119
#} END object db read
119120

@@ -127,7 +128,6 @@ def store(self, istream):
127128

128129
#} END object db write
129130

130-
131131
#{ Interface
132132

133133
def update_cache(self, force=False):
@@ -177,7 +177,7 @@ def update_cache(self, force=False):
177177

178178
def entities(self):
179179
""":return: list of pack entities operated upon by this database"""
180-
return [ item[1] for item in self._entities ]
180+
return [item[1] for item in self._entities]
181181

182182
def partial_to_complete_sha(self, partial_binsha, canonical_length):
183183
""":return: 20 byte sha as inferred by the given partial binary sha

‎gitdb/db/ref.py

+2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
__all__ = ('ReferenceDB', )
1010

11+
1112
class ReferenceDB(CompoundDB):
13+
1214
"""A database consisting of database referred to in a file"""
1315

1416
# Configuration

0 commit comments

Comments
 (0)