本文整理汇总了Python中view_collection.ViewCollection类的典型用法代码示例。如果您正苦于以下问题:Python ViewCollection类的具体用法?Python ViewCollection怎么用?Python ViewCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ViewCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_git_file
def update_git_file(self):
# the git repo won't change that often
# so we can easily wait 5 seconds
# between updates for performance
if ViewCollection.git_time(self.view) > 5:
open(self.git_temp_file.name, 'w').close()
if self.view.get_status('remote'):
base_path = self.view.file_name() + '.base'
if os.path.exists(base_path):
shutil.copyfile(base_path, self.git_temp_file.name)
return
args = [
self.git_binary_path,
'--git-dir=' + self.git_dir,
'--work-tree=' + self.git_tree,
'show',
ViewCollection.get_compare() + ':' + self.git_path,
]
try:
contents = self.run_command(args)
contents = contents.replace(b'\r\n', b'\n')
contents = contents.replace(b'\r', b'\n')
f = open(self.git_temp_file.name, 'wb')
f.write(contents)
f.close()
ViewCollection.update_git_time(self.view)
except Exception:
pass
示例2: update_git_file
def update_git_file(self):
# the git repo won't change that often
# so we can easily wait 5 seconds
# between updates for performance
if ViewCollection.git_time(self.view) > 5:
with open(self.git_temp_file, 'w'):
pass
args = [
self.git_binary_path,
'--git-dir=' + self.git_dir,
'--work-tree=' + self.git_tree,
'show',
ViewCollection.get_compare(self.view) + ':' + self.git_path,
]
try:
contents = self.run_command(args)
contents = contents.replace(b'\r\n', b'\n')
contents = contents.replace(b'\r', b'\n')
with open(self.git_temp_file, 'wb') as f:
f.write(contents)
ViewCollection.update_git_time(self.view)
except Exception:
pass
示例3: update_vcs_file
def update_vcs_file(self):
# the git repo won't change that often
# so we can easily wait 5 seconds
# between updates for performance
if ViewCollection.vcs_time(self.view) > 5:
open(self.vcs_temp_file.name, 'w').close()
status_args = self.get_status_args()
status = None
try:
contents, errors = self.run_command(status_args)
status = self.process_status_line(contents)
ViewCollection.update_vcs_status(self.view, status)
except Exception as e:
# print e
pass
args = self.get_diff_args()
try:
if status == 'M':
contents, errors = self.run_command(args)
contents = VcsGutterHandler._to_unix(contents)
VcsGutterHandler._write(self.vcs_temp_file.name, contents)
ViewCollection.update_vcs_time(self.view)
except Exception as e:
print ("Unable to write file for diff ", e)
示例4: __init__
def __init__(self, view):
self.load_settings()
self.view = view
self.git_temp_file = ViewCollection.git_tmp_file(self.view)
self.buf_temp_file = ViewCollection.buf_tmp_file(self.view)
self.git_tree = None
self.git_dir = None
self.git_path = None
示例5: __init__
def __init__(self, view):
self.view = view
self.git_temp_file = ViewCollection.git_tmp_file(self.view)
self.buf_temp_file = ViewCollection.buf_tmp_file(self.view)
if self.on_disk():
self.git_tree = git_helper.git_tree(self.view)
self.git_dir = git_helper.git_dir(self.git_tree)
self.git_path = git_helper.git_file_path(self.view, self.git_tree)
示例6: __init__
def __init__(self, view):
self.view = view
self.vcs_temp_file = ViewCollection.vcs_tmp_file(self.view)
self.buf_temp_file = ViewCollection.buf_tmp_file(self.view)
vcs_helper = self.get_vcs_helper()
if self.on_disk():
self.vcs_tree = vcs_helper.vcs_tree(self.view)
self.vcs_dir = vcs_helper.vcs_dir(self.vcs_tree)
self.vcs_path = vcs_helper.vcs_file_path(self.view, self.vcs_tree)
示例7: run
def run(self, force_refresh=False):
self.view = self.window.active_view()
if not self.view:
# View is not ready yet, try again later.
sublime.set_timeout(self.run, 1)
return
self.clear_all()
if ViewCollection.untracked(self.view):
self.bind_files('untracked')
elif ViewCollection.ignored(self.view):
self.bind_files('ignored')
else:
# If the file is untracked there is no need to execute the diff
# update
if force_refresh:
ViewCollection.clear_git_time(self.view)
inserted, modified, deleted = ViewCollection.diff(self.view)
self.lines_removed(deleted)
self.bind_icons('inserted', inserted)
self.bind_icons('changed', modified)
if(ViewCollection.show_status(self.view) != "none"):
if(ViewCollection.show_status(self.view) == 'all'):
branch = ViewCollection.current_branch(
self.view).decode("utf-8").strip()
else:
branch = ""
self.update_status(len(inserted),
len(modified),
len(deleted),
ViewCollection.get_compare(self.view), branch)
else:
self.update_status(0, 0, 0, "", "")
示例8: __init__
def __init__(self, view):
self.load_settings()
self.view = view
self.git_temp_file = ViewCollection.git_tmp_file(self.view)
self.buf_temp_file = ViewCollection.buf_tmp_file(self.view)
if self.on_disk():
self.git_tree = git_helper.git_tree(self.view)
self.git_dir = git_helper.git_dir(self.git_tree)
self.git_path = git_helper.git_file_path(self.view, self.git_tree)
if self.view.get_status('remote'):
self.git_path = self.view.get_status('remote')
示例9: update_git_file
def update_git_file(self):
# the git repo won't change that often
# so we can easily wait 5 seconds
# 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]
try:
subprocess.call(args, stdout=self.git_temp_file)
ViewCollection.update_git_time(self.view)
except Exception:
pass
示例10: run
def run(self):
self.view = self.window.active_view()
self.handler = ViewCollection.get_handler(self.view)
self.results = self.commit_list()
if self.results:
self.window.show_quick_panel(self.results, self.on_select)
示例11: on_modified
def on_modified(self, view):
if view.settings().get('git_gutter_live_mode', True):
# Sublime Text is very strict on the amount of time plugin
# uses in performance-critical events. Sometimes invoking plugin
# from this event causes Sublime warning to appear, so we need to
# schedule its run for future.
sublime.set_timeout(lambda: ViewCollection.add(view), 1)
示例12: run
def run(self):
self.view = self.window.active_view()
self.clear_all()
inserted, modified, deleted = ViewCollection.diff(self.view)
self.lines_removed(deleted)
self.lines_added(inserted)
self.lines_modified(modified)
示例13: update_vcs_file
def update_vcs_file(self):
# the git repo won't change that often
# so we can easily wait 5 seconds
# between updates for performance
if ViewCollection.vcs_time(self.view) > 5:
open(self.vcs_temp_file.name, "w").close()
args = self.get_diff_args()
try:
contents = self.run_command(args)
contents = contents.replace(b"\r\n", b"\n")
contents = contents.replace(b"\r", b"\n")
f = open(self.vcs_temp_file.name, "wb")
f.write(contents)
f.close()
ViewCollection.update_vcs_time(self.view)
except Exception as e:
print("Unable to write file for diff ", e)
示例14: bind_files
def bind_files(self, event):
lines = []
lineCount = ViewCollection.total_lines(self.view)
i = 0
while i < lineCount:
lines += [i + 1]
i = i + 1
self.bind_icons(event, lines)
示例15: update_vcs_file
def update_vcs_file(self):
# the git repo won't change that often
# so we can easily wait 5 seconds
# between updates for performance
if ViewCollection.vcs_time(self.view) > 5:
open(self.vcs_temp_file.name, 'w').close()
args = self.get_diff_args()
try:
contents = self.run_command(args)
contents = contents.replace('\r\n', '\n')
contents = contents.replace('\r', '\n')
f = open(self.vcs_temp_file.name, 'w')
f.write(contents)
f.close()
ViewCollection.update_vcs_time(self.view)
except Exception:
pass