Permalink
Browse files

PEP-8 Formatting: spaces between operators

  • Loading branch information...
1 parent 3659c73 commit 565ed928feef68bd5764f54ccf10e93eebc8b8ae @fogleman fogleman committed Dec 14, 2012
Showing with 26 additions and 26 deletions.
  1. +4 −6 git_gutter.py
  2. +0 −1 git_gutter_events.py
  3. +21 −16 git_gutter_handler.py
  4. +1 −3 git_helper.py
View
@@ -5,9 +5,7 @@
class GitGutterCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.clear_all()
-
- (inserted, modified, deleted) = ViewCollection.diff(self.view)
-
+ inserted, modified, deleted = ViewCollection.diff(self.view)
self.lines_removed(deleted)
self.lines_added(inserted)
self.lines_modified(modified)
@@ -21,16 +19,16 @@ def clear_all(self):
def lines_to_regions(self, lines):
regions = []
for line in lines:
- position = self.view.text_point(line-1, 0)
+ position = self.view.text_point(line - 1, 0)
region = sublime.Region(position,position)
regions.append(region)
return regions
def lines_removed(self, lines):
bottom_lines = []
for line in lines:
- if not line == 1:
- bottom_lines.append(line-1)
+ if line != 1:
+ bottom_lines.append(line - 1)
self.lines_removed_top(lines)
self.lines_removed_bottom(bottom_lines)
View
@@ -3,7 +3,6 @@
from view_collection import ViewCollection
class GitGutterEvents(sublime_plugin.EventListener):
-
def on_load(self, view):
ViewCollection.add(view)
View
@@ -16,7 +16,7 @@ def __init__(self, view):
def on_disk(self):
# if the view is saved to disk
- return self.view.file_name() != None
+ return self.view.file_name() is not None
def reset(self):
if self.on_disk() and self.git_path:
@@ -27,11 +27,11 @@ def get_git_path(self):
def update_buf_file(self):
chars = self.view.size()
- region = sublime.Region(0,chars)
+ region = sublime.Region(0, chars)
contents = self.view.substr(region).encode('utf-8')
contents = contents.replace('\r\n', '\n')
contents = contents.replace('\r', '\n')
- f = open(self.buf_temp_file.name,'w')
+ f = open(self.buf_temp_file.name, 'w')
f.write(contents)
f.close()
@@ -41,24 +41,29 @@ def update_git_file(self):
# between updates for performance
if ViewCollection.git_time(self.view) > 5:
self.git_temp_file.truncate()
- args = ['git','--git-dir='+self.git_dir,'--work-tree='+self.git_tree,'show','HEAD:'+self.git_path]
+ args = [
+ 'git',
+ '--git-dir=' + self.git_dir,
+ '--work-tree=' + self.git_tree,
+ 'show',
+ 'HEAD:' + self.git_path
+ ]
try:
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
contents = proc.stdout.read()
contents = contents.replace('\r\n', '\n')
contents = contents.replace('\r', '\n')
- f = open(self.git_temp_file.name,'w')
+ f = open(self.git_temp_file.name, 'w')
f.write(contents)
f.close()
ViewCollection.update_git_time(self.view)
except Exception:
pass
- def process_diff(self,diff_str):
+ def process_diff(self, diff_str):
inserted = []
modified = []
deleted = []
-
lines = diff_str.splitlines()
for line in lines:
m = re.match('(\d+),?(\d*)(.)(\d+),?(\d*)', line)
@@ -75,28 +80,28 @@ def process_diff(self,diff_str):
line_end = int(m.group(5))
else:
line_end = line_start
-
if kind == 'c':
- modified += range(line_start,line_end+1)
+ modified += range(line_start,line_end + 1)
elif kind == 'a':
- inserted += range(line_start,line_end+1)
+ inserted += range(line_start,line_end + 1)
elif kind == 'd':
if line == 1:
deleted.append(line_start)
else:
- deleted.append(line_start+1)
-
+ deleted.append(line_start + 1)
return (inserted, modified, deleted)
def diff(self):
if self.on_disk() and self.git_path:
self.update_git_file()
self.update_buf_file()
-
- args = ['diff',self.git_temp_file.name,self.buf_temp_file.name]
+ args = [
+ 'diff',
+ self.git_temp_file.name,
+ self.buf_temp_file.name
+ ]
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
results = proc.stdout.read()
-
return self.process_diff(results)
else:
- return ([],[],[])
+ return ([], [], [])
View
@@ -4,11 +4,9 @@ def git_file_path(view, git_path):
if not git_path:
return False
full_file_path = os.path.realpath(view.file_name())
- git_path_to_file = full_file_path.replace(git_path,'')
-
+ git_path_to_file = full_file_path.replace(git_path, '')
if git_path_to_file[0] == '/':
git_path_to_file = git_path_to_file[1:]
-
return git_path_to_file
def git_root(directory):

0 comments on commit 565ed92

Please sign in to comment.