Skip to content

Commit be34ec2

Browse files
committed
pep8 linting (blank lines expectations)
E301 expected 1 blank line, found 0 E302 expected 2 blank lines, found 1 E303 too many blank lines (n)
1 parent f5d11b7 commit be34ec2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+245
-96
lines changed

git/cmd.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323

2424
__all__ = ('Git', )
2525

26+
2627
def dashify(string):
2728
return string.replace('_', '-')
2829

2930

3031
class Git(LazyMixin):
32+
3133
"""
3234
The Git class manages communication with the Git binary.
3335
@@ -59,8 +61,8 @@ class Git(LazyMixin):
5961
_git_exec_env_var = "GIT_PYTHON_GIT_EXECUTABLE"
6062
GIT_PYTHON_GIT_EXECUTABLE = os.environ.get(_git_exec_env_var, git_exec_name)
6163

62-
6364
class AutoInterrupt(object):
65+
6466
"""Kill/Interrupt the stored process instance once this instance goes out of scope. It is
6567
used to prevent processes piling up in case iterators stop reading.
6668
Besides all attributes are wired through to the contained process object.
@@ -114,6 +116,7 @@ def wait(self):
114116
# END auto interrupt
115117

116118
class CatFileContentStream(object):
119+
117120
"""Object representing a sized read-only stream returning the contents of
118121
an object.
119122
It behaves like a stream, but counts the data read and simulates an empty
@@ -213,7 +216,6 @@ def __del__(self):
213216
self._stream.read(bytes_left + 1)
214217
# END handle incomplete read
215218

216-
217219
def __init__(self, working_dir=None):
218220
"""Initialize this instance with:
219221
@@ -247,7 +249,6 @@ def _set_cache_(self, attr):
247249
super(Git, self)._set_cache_(attr)
248250
#END handle version info
249251

250-
251252
@property
252253
def working_dir(self):
253254
""":return: Git directory we are working on"""

git/config.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717

1818
__all__ = ('GitConfigParser', 'SectionConstraint')
1919

20+
2021
class MetaParserBuilder(type):
22+
2123
"""Utlity class wrapping base-class methods into decorators that assure read-only properties"""
2224
def __new__(metacls, name, bases, clsdict):
2325
"""
@@ -45,20 +47,22 @@ def __new__(metacls, name, bases, clsdict):
4547
return new_type
4648

4749

48-
4950
def needs_values(func):
5051
"""Returns method assuring we read values (on demand) before we try to access them"""
52+
5153
def assure_data_present(self, *args, **kwargs):
5254
self.read()
5355
return func(self, *args, **kwargs)
5456
# END wrapper method
5557
assure_data_present.__name__ = func.__name__
5658
return assure_data_present
5759

60+
5861
def set_dirty_and_flush_changes(non_const_func):
5962
"""Return method that checks whether given non constant function may be called.
6063
If so, the instance will be set dirty.
6164
Additionally, we flush the changes right to disk"""
65+
6266
def flush_changes(self, *args, **kwargs):
6367
rval = non_const_func(self, *args, **kwargs)
6468
self.write()
@@ -69,6 +73,7 @@ def flush_changes(self, *args, **kwargs):
6973

7074

7175
class SectionConstraint(object):
76+
7277
"""Constrains a ConfigParser to only option commands which are constrained to
7378
always use the section we have been initialized with.
7479
@@ -98,6 +103,7 @@ def config(self):
98103

99104

100105
class GitConfigParser(cp.RawConfigParser, object):
106+
101107
"""Implements specifics required to read git style configuration files.
102108
103109
This variation behaves much like the git.config command such that the configuration
@@ -114,7 +120,6 @@ class GitConfigParser(cp.RawConfigParser, object):
114120
must match perfectly."""
115121
__metaclass__ = MetaParserBuilder
116122

117-
118123
#{ Configuration
119124
# The lock type determines the type of lock to use in new configuration readers.
120125
# They must be compatible to the LockFile interface.
@@ -172,7 +177,6 @@ def __init__(self, file_or_files, read_only=True):
172177
self._lock._obtain_lock()
173178
# END read-only check
174179

175-
176180
def __del__(self):
177181
"""Write pending changes if required and release locks"""
178182
# checking for the lock here makes sure we do not raise during write()
@@ -261,7 +265,6 @@ def _read(self, fp, fpname):
261265
if e:
262266
raise e
263267

264-
265268
def read(self):
266269
"""Reads the data stored in the files we have been initialized with. It will
267270
ignore files that cannot be read, possibly leaving an empty configuration
@@ -311,7 +314,6 @@ def write_section(name, section_dict):
311314
write_section(cp.DEFAULTSECT, self._defaults)
312315
map(lambda t: write_section(t[0],t[1]), self._sections.items())
313316

314-
315317
@needs_values
316318
def write(self):
317319
"""Write changes to our file, if there are changes at all

git/db.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,18 @@
2020
__all__ = ('GitCmdObjectDB', 'GitDB' )
2121

2222
#class GitCmdObjectDB(CompoundDB, ObjectDBW):
23+
24+
2325
class GitCmdObjectDB(LooseObjectDB):
26+
2427
"""A database representing the default git object store, which includes loose
2528
objects, pack files and an alternates file
2629
2730
It will create objects only in the loose object database.
2831
:note: for now, we use the git command to do all the lookup, just until he
2932
have packs and the other implementations
3033
"""
34+
3135
def __init__(self, root_path, git):
3236
"""Initialize this instance with the root and a git command"""
3337
super(GitCmdObjectDB, self).__init__(root_path)
@@ -42,7 +46,6 @@ def stream(self, sha):
4246
hexsha, typename, size, stream = self._git.stream_object_data(bin_to_hex(sha))
4347
return OStream(hex_to_bin(hexsha), typename, size, stream)
4448

45-
4649
# { Interface
4750

4851
def partial_to_complete_sha_hex(self, partial_hexsha):

git/diff.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515
__all__ = ('Diffable', 'DiffIndex', 'Diff')
1616

17+
1718
class Diffable(object):
19+
1820
"""Common interface for all object that can be diffed against another object of compatible type.
1921
2022
:note:
@@ -109,6 +111,7 @@ def diff(self, other=Index, paths=None, create_patch=False, **kwargs):
109111

110112

111113
class DiffIndex(list):
114+
112115
"""Implements an Index for diffs, allowing a list of Diffs to be queried by
113116
the diff properties.
114117
@@ -120,7 +123,6 @@ class DiffIndex(list):
120123
# M = modified
121124
change_type = ("A", "D", "R", "M")
122125

123-
124126
def iter_change_type(self, change_type):
125127
"""
126128
:return:
@@ -149,6 +151,7 @@ def iter_change_type(self, change_type):
149151

150152

151153
class Diff(object):
154+
152155
"""A Diff contains diff information between two Trees.
153156
154157
It contains two sides a and b of the diff, members are prefixed with
@@ -228,7 +231,6 @@ def __init__(self, repo, a_path, b_path, a_blob_id, b_blob_id, a_mode,
228231

229232
self.diff = diff
230233

231-
232234
def __eq__(self, other):
233235
for name in self.__slots__:
234236
if getattr(self, name) != getattr(other, name):

git/exc.py

+10
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,21 @@
77

88
from gitdb.exc import *
99

10+
1011
class InvalidGitRepositoryError(Exception):
12+
1113
""" Thrown if the given repository appears to have an invalid format. """
1214

1315

1416
class NoSuchPathError(OSError):
17+
1518
""" Thrown if a path could not be access by the system. """
1619

1720

1821
class GitCommandError(Exception):
22+
1923
""" Thrown if execution of the git command fails with non-zero status code. """
24+
2025
def __init__(self, command, status, stderr=None, stdout=None):
2126
self.stderr = stderr
2227
self.stdout = stdout
@@ -32,6 +37,7 @@ def __str__(self):
3237

3338

3439
class CheckoutError( Exception ):
40+
3541
"""Thrown if a file could not be checked out from the index as it contained
3642
changes.
3743
@@ -44,6 +50,7 @@ class CheckoutError( Exception ):
4450
The .valid_files attribute contains a list of relative paths to files that
4551
were checked out successfully and hence match the version stored in the
4652
index"""
53+
4754
def __init__(self, message, failed_files, valid_files, failed_reasons):
4855
Exception.__init__(self, message)
4956
self.failed_files = failed_files
@@ -55,8 +62,11 @@ def __str__(self):
5562

5663

5764
class CacheError(Exception):
65+
5866
"""Base for all errors related to the git index, which is called cache internally"""
5967

68+
6069
class UnmergedEntriesError(CacheError):
70+
6171
"""Thrown if an operation cannot proceed as there are still unmerged
6272
entries in the cache"""

git/index/base.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171

7272

7373
class IndexFile(LazyMixin, diff.Diffable, Serializable):
74+
7475
"""
7576
Implements an Index that can be manipulated using a native implementation in
7677
order to save git command function calls wherever possible.
@@ -174,7 +175,6 @@ def _serialize(self, stream, ignore_tree_extension_data=False):
174175
(ignore_tree_extension_data and None) or self._extension_data)
175176
return self
176177

177-
178178
#} END serializable interface
179179

180180
def write(self, file_path = None, ignore_tree_extension_data=False):
@@ -273,7 +273,6 @@ def new(cls, repo, *tree_sha):
273273
inst.entries = entries
274274
return inst
275275

276-
277276
@classmethod
278277
def from_tree(cls, repo, *treeish, **kwargs):
279278
"""Merge the given treeish revisions into a new index which is returned.
@@ -519,7 +518,6 @@ def write_tree(self):
519518
# copy changed trees only
520519
mdb.stream_copy(mdb.sha_iter(), self.repo.odb)
521520

522-
523521
# note: additional deserialization could be saved if write_tree_from_cache
524522
# would return sorted tree entries
525523
root_tree = Tree(self.repo, binsha, path='')
@@ -664,7 +662,6 @@ def add(self, items, force=True, fprogress=lambda *args: None, path_rewriter=Non
664662
del(paths[:])
665663
# END rewrite paths
666664

667-
668665
def store_path(filepath):
669666
"""Store file at filepath in the database and return the base index entry"""
670667
st = os.lstat(filepath) # handles non-symlinks as well
@@ -681,7 +678,6 @@ def store_path(filepath):
681678
istream.binsha, 0, to_native_path_linux(filepath)))
682679
# END utility method
683680

684-
685681
# HANDLE PATHS
686682
if paths:
687683
assert len(entries_added) == 0
@@ -691,7 +687,6 @@ def store_path(filepath):
691687
# END for each filepath
692688
# END path handling
693689

694-
695690
# HANDLE ENTRIES
696691
if entries:
697692
null_mode_entries = [ e for e in entries if e.mode == 0 ]
@@ -866,7 +861,6 @@ def move(self, items, skip_errors=False, **kwargs):
866861
return out
867862
# END handle dryrun
868863

869-
870864
# now apply the actual operation
871865
kwargs.pop('dry_run')
872866
self.repo.git.mv(args, paths, **kwargs)
@@ -989,7 +983,6 @@ def handle_stderr(proc, iter_checked_out_files):
989983
raise CheckoutError("Some files could not be checked out from the index due to local modifications", failed_files, valid_files, failed_reasons)
990984
# END stderr handler
991985

992-
993986
if paths is None:
994987
args.append("--all")
995988
kwargs['as_process'] = 1

git/index/fun.py

+6
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def write_cache(entries, stream, extension_data=None, ShaStreamCls=IndexFileSHA1
9999
# write the sha over the content
100100
stream.write_sha()
101101

102+
102103
def read_header(stream):
103104
"""Return tuple(version_long, num_entries) from the given stream"""
104105
type_id = stream.read(4)
@@ -110,6 +111,7 @@ def read_header(stream):
110111
assert version in (1, 2)
111112
return version, num_entries
112113

114+
113115
def entry_key(*entry):
114116
""":return: Key suitable to be used for the index.entries dictionary
115117
:param entry: One instance of type BaseIndexEntry or the path and the stage"""
@@ -119,6 +121,7 @@ def entry_key(*entry):
119121
return tuple(entry)
120122
# END handle entry
121123

124+
122125
def read_cache(stream):
123126
"""Read a cache file from the given stream
124127
:return: tuple(version, entries_dict, extension_data, content_sha)
@@ -166,6 +169,7 @@ def read_cache(stream):
166169

167170
return (version, entries, extension_data, content_sha)
168171

172+
169173
def write_tree_from_cache(entries, odb, sl, si=0):
170174
"""Create a tree from the given sorted list of entries and put the respective
171175
trees into the given object database
@@ -221,9 +225,11 @@ def write_tree_from_cache(entries, odb, sl, si=0):
221225
istream = odb.store(IStream(str_tree_type, len(sio.getvalue()), sio))
222226
return (istream.binsha, tree_items)
223227

228+
224229
def _tree_entry_to_baseindexentry(tree_entry, stage):
225230
return BaseIndexEntry((tree_entry[1], tree_entry[0], stage << CE_STAGESHIFT, tree_entry[2]))
226231

232+
227233
def aggressive_tree_merge(odb, tree_shas):
228234
"""
229235
:return: list of BaseIndexEntries representing the aggressive merge of the given

git/index/typ.py

+4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121

2222
#} END invariants
2323

24+
2425
class BlobFilter(object):
26+
2527
"""
2628
Predicate to be used by iter_blobs allowing to filter only return blobs which
2729
match the given list of directories or files.
@@ -47,6 +49,7 @@ def __call__(self, stage_blob):
4749

4850

4951
class BaseIndexEntry(tuple):
52+
5053
"""Small Brother of an index entry which can be created to describe changes
5154
done to the index in which case plenty of additional information is not requried.
5255
@@ -109,6 +112,7 @@ def to_blob(self, repo):
109112

110113

111114
class IndexEntry(BaseIndexEntry):
115+
112116
"""Allows convenient access to IndexEntry data without completely unpacking it.
113117
114118
Attributes usully accessed often are cached in the tuple whereas others are

0 commit comments

Comments
 (0)