From f5d11b750ecc982541d1f936488248f0b42d75d3 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 20:15:50 +0100 Subject: pep8 linting (whitespaces) W191 indentation contains tabs E221 multiple spaces before operator E222 multiple spaces after operator E225 missing whitespace around operator E271 multiple spaces after keyword W292 no newline at end of file W293 blank line contains whitespace W391 blank line at end of file --- git/repo/fun.py | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'git/repo/fun.py') diff --git a/git/repo/fun.py b/git/repo/fun.py index 2c49d836..fe26d8ce 100644 --- a/git/repo/fun.py +++ b/git/repo/fun.py @@ -53,8 +53,8 @@ def short_to_long(odb, hexsha): except BadObject: return None # END exception handling - - + + def name_to_object(repo, name, return_ref=False): """ :return: object specified by the given name, hexshas ( short and long ) @@ -63,7 +63,7 @@ def name_to_object(repo, name, return_ref=False): instead of the object. Otherwise it will raise BadObject """ hexsha = None - + # is it a hexsha ? Try the most common ones, which is 7 to 40 if repo.re_hexsha_shortened.match(name): if len(name) != 40: @@ -73,7 +73,7 @@ def name_to_object(repo, name, return_ref=False): hexsha = name # END handle short shas #END find sha if it matches - + # if we couldn't find an object for what seemed to be a short hexsha # try to find it as reference anyway, it could be named 'aaa' for instance if hexsha is None: @@ -98,7 +98,7 @@ def name_to_object(repo, name, return_ref=False): if hexsha is None: raise BadObject(name) # END assert hexsha was found - + return Object.new_from_sha(repo, hex_to_bin(hexsha)) def deref_tag(tag): @@ -115,7 +115,7 @@ def to_commit(obj): """Convert the given object to a commit if possible and return it""" if obj.type == 'tag': obj = deref_tag(obj) - + if obj.type != "commit": raise ValueError("Cannot convert object %r to type commit" % obj) # END verify type @@ -132,13 +132,13 @@ def rev_parse(repo, rev): :raise BadObject: if the given revision could not be found :raise ValueError: If rev couldn't be parsed :raise IndexError: If invalid reflog index is specified""" - + # colon search mode ? if rev.startswith(':/'): # colon search mode raise NotImplementedError("commit by message search ( regex )") # END handle search - + obj = None ref = None output_type = "commit" @@ -150,9 +150,9 @@ def rev_parse(repo, rev): start += 1 continue # END handle start - + token = rev[start] - + if obj is None: # token is a rev name if start == 0: @@ -164,22 +164,22 @@ def rev_parse(repo, rev): obj = name_to_object(repo, rev[:start]) #END handle token #END handle refname - + if ref is not None: obj = ref.commit #END handle ref # END initialize obj on first token - - + + start += 1 - + # try to parse {type} if start < lr and rev[start] == '{': end = rev.find('}', start) if end == -1: raise ValueError("Missing closing brace to define type in %s" % rev) output_type = rev[start+1:end] # exclude brace - + # handle type if output_type == 'commit': pass # default @@ -208,31 +208,31 @@ def rev_parse(repo, rev): # maybe raise NotImplementedError("Support for additional @{...} modes not implemented") #END handle revlog index - + try: entry = ref.log_entry(revlog_index) except IndexError: raise IndexError("Invalid revlog index: %i" % revlog_index) #END handle index out of bound - + obj = Object.new_from_sha(repo, hex_to_bin(entry.newhexsha)) - + # make it pass the following checks output_type = None else: - raise ValueError("Invalid output type: %s ( in %s )" % (output_type, rev)) + raise ValueError("Invalid output type: %s ( in %s )" % (output_type, rev)) # END handle output type - + # empty output types don't require any specific type, its just about dereferencing tags if output_type and obj.type != output_type: raise ValueError("Could not accomodate requested object type %r, got %s" % (output_type, obj.type)) # END verify ouput type - + start = end+1 # skip brace parsed_to = start continue # END parse type - + # try to parse a number num = 0 if token != ":": @@ -246,15 +246,15 @@ def rev_parse(repo, rev): break # END handle number # END number parse loop - + # no explicit number given, 1 is the default # It could be 0 though if not found_digit: num = 1 # END set default num # END number parsing only if non-blob mode - - + + parsed_to = start # handle hiererarchy walk try: @@ -281,17 +281,17 @@ def rev_parse(repo, rev): raise BadObject("Invalid Revision in %s" % rev) # END exception handling # END parse loop - + # still no obj ? Its probably a simple name if obj is None: obj = name_to_object(repo, rev) parsed_to = lr # END handle simple name - + if obj is None: raise ValueError("Revision specifier could not be parsed: %s" % rev) if parsed_to != lr: raise ValueError("Didn't consume complete rev spec %s, consumed part: %s" % (rev, rev[:parsed_to])) - + return obj -- cgit v1.2.3 From be34ec23c48d6d5d8fd2ef4491981f6fb4bab8e6 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 20:51:04 +0100 Subject: 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) --- git/repo/fun.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'git/repo/fun.py') diff --git a/git/repo/fun.py b/git/repo/fun.py index fe26d8ce..15c5762b 100644 --- a/git/repo/fun.py +++ b/git/repo/fun.py @@ -15,10 +15,12 @@ from string import digits __all__ = ('rev_parse', 'is_git_dir', 'touch') + def touch(filename): fp = open(filename, "a") fp.close() + def is_git_dir(d): """ This is taken from the git setup.c:is_git_directory function.""" @@ -101,6 +103,7 @@ def name_to_object(repo, name, return_ref=False): return Object.new_from_sha(repo, hex_to_bin(hexsha)) + def deref_tag(tag): """Recursively dereerence a tag and return the resulting object""" while True: @@ -111,6 +114,7 @@ def deref_tag(tag): # END dereference tag return tag + def to_commit(obj): """Convert the given object to a commit if possible and return it""" if obj.type == 'tag': @@ -121,6 +125,7 @@ def to_commit(obj): # END verify type return obj + def rev_parse(repo, rev): """ :return: Object at the given revision, either Commit, Tag, Tree or Blob @@ -170,7 +175,6 @@ def rev_parse(repo, rev): #END handle ref # END initialize obj on first token - start += 1 # try to parse {type} @@ -254,7 +258,6 @@ def rev_parse(repo, rev): # END set default num # END number parsing only if non-blob mode - parsed_to = start # handle hiererarchy walk try: -- cgit v1.2.3 From 614907b7445e2ed8584c1c37df7e466e3b56170f Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 20:56:53 +0100 Subject: pep8 linting (whitespace before/after) E201 whitespace after '(' E202 whitespace before ')' E203 whitespace before ':' E225 missing whitespace around operator E226 missing whitespace around arithmetic operator E227 missing whitespace around bitwise or shift operator E228 missing whitespace around modulo operator E231 missing whitespace after ',' E241 multiple spaces after ',' E251 unexpected spaces around keyword / parameter equals --- git/repo/fun.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'git/repo/fun.py') diff --git a/git/repo/fun.py b/git/repo/fun.py index 15c5762b..4cdaf3f4 100644 --- a/git/repo/fun.py +++ b/git/repo/fun.py @@ -182,7 +182,7 @@ def rev_parse(repo, rev): end = rev.find('}', start) if end == -1: raise ValueError("Missing closing brace to define type in %s" % rev) - output_type = rev[start+1:end] # exclude brace + output_type = rev[start + 1:end] # exclude brace # handle type if output_type == 'commit': @@ -206,7 +206,7 @@ def rev_parse(repo, rev): revlog_index = None try: # transform reversed index into the format of our revlog - revlog_index = -(int(output_type)+1) + revlog_index = -(int(output_type) + 1) except ValueError: # TODO: Try to parse the other date options, using parse_date # maybe @@ -232,7 +232,7 @@ def rev_parse(repo, rev): raise ValueError("Could not accomodate requested object type %r, got %s" % (output_type, obj.type)) # END verify ouput type - start = end+1 # skip brace + start = end + 1 # skip brace parsed_to = start continue # END parse type @@ -270,7 +270,7 @@ def rev_parse(repo, rev): obj = to_commit(obj) # must be n'th parent if num: - obj = obj.parents[num-1] + obj = obj.parents[num - 1] elif token == ":": if obj.type != "tree": obj = obj.tree -- cgit v1.2.3 From bed3b0989730cdc3f513884325f1447eb378aaee Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 21:06:57 +0100 Subject: pep8 linting (double spaces before comment) E261 at least two spaces before inline comment --- git/repo/fun.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git/repo/fun.py') diff --git a/git/repo/fun.py b/git/repo/fun.py index 4cdaf3f4..1e131b0f 100644 --- a/git/repo/fun.py +++ b/git/repo/fun.py @@ -186,7 +186,7 @@ def rev_parse(repo, rev): # handle type if output_type == 'commit': - pass # default + pass # default elif output_type == 'tree': try: obj = to_commit(obj).tree -- cgit v1.2.3 From c8e70749887370a99adeda972cc3503397b5f9a7 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 21:09:47 +0100 Subject: pep8 linting (trailing whitespace) W291 trailing whitespace --- git/repo/fun.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'git/repo/fun.py') diff --git a/git/repo/fun.py b/git/repo/fun.py index 1e131b0f..9dfc00ea 100644 --- a/git/repo/fun.py +++ b/git/repo/fun.py @@ -5,10 +5,10 @@ from git.refs import SymbolicReference from git.objects import Object from gitdb.util import ( join, - isdir, + isdir, isfile, dirname, - hex_to_bin, + hex_to_bin, bin_to_hex ) from string import digits @@ -76,7 +76,7 @@ def name_to_object(repo, name, return_ref=False): # END handle short shas #END find sha if it matches - # if we couldn't find an object for what seemed to be a short hexsha + # if we couldn't find an object for what seemed to be a short hexsha # try to find it as reference anyway, it could be named 'aaa' for instance if hexsha is None: for base in ('%s', 'refs/%s', 'refs/tags/%s', 'refs/heads/%s', 'refs/remotes/%s', 'refs/remotes/%s/HEAD'): @@ -184,7 +184,7 @@ def rev_parse(repo, rev): raise ValueError("Missing closing brace to define type in %s" % rev) output_type = rev[start + 1:end] # exclude brace - # handle type + # handle type if output_type == 'commit': pass # default elif output_type == 'tree': @@ -252,7 +252,7 @@ def rev_parse(repo, rev): # END number parse loop # no explicit number given, 1 is the default - # It could be 0 though + # It could be 0 though if not found_digit: num = 1 # END set default num -- cgit v1.2.3