当前位置: 首页>>代码示例>>Python>>正文


Python ViewCollection.vcs_status方法代码示例

本文整理汇总了Python中view_collection.ViewCollection.vcs_status方法的典型用法代码示例。如果您正苦于以下问题:Python ViewCollection.vcs_status方法的具体用法?Python ViewCollection.vcs_status怎么用?Python ViewCollection.vcs_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在view_collection.ViewCollection的用法示例。


在下文中一共展示了ViewCollection.vcs_status方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process_diff

# 需要导入模块: from view_collection import ViewCollection [as 别名]
# 或者: from view_collection.ViewCollection import vcs_status [as 别名]
 def process_diff(self, diff_str):
     inserted = []
     modified = []
     deleted = []
     pattern = re.compile(b'(\d+),?(\d*)(.)(\d+),?(\d*)')
     lines = diff_str.splitlines()
     for line in lines:
         m = pattern.match(line)
         if not m:
             continue
         kind = m.group(3)
         line_start = int(m.group(4))
         if len(m.group(5)) > 0:
             line_end = int(m.group(5))
         else:
             line_end = line_start
         if kind == b'c':
             modified += range(line_start, line_end + 1)
         elif kind == b'a':
             inserted += range(line_start, line_end + 1)
         elif kind == b'd':
             if line == 1:
                 deleted.append(line_start)
             else:
                 deleted.append(line_start + 1)
     if inserted == self.total_lines():
         # All lines are "inserted"
         # this means this file is either:
         # - New and not being tracked *yet*
         # - Or it is a *gitignored* file
         status = ViewCollection.vcs_status(self.view)
         if status == 'U':
             # use special region 'unknown'
             return ([], [], [], inserted, [])
         elif status == 'I':
             # use special region 'ignored'
             return ([], [], [], [], inserted)
         return (inserted, modified, deleted, [], [])
     else:
         return (inserted, modified, deleted, [], [])
开发者ID:dichlofos,项目名称:VcsGutter,代码行数:42,代码来源:gutter_handlers.py


注:本文中的view_collection.ViewCollection.vcs_status方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。