• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python common.normalized_rel_path函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中vcstools.common.normalized_rel_path函数的典型用法代码示例。如果您正苦于以下问题:Python normalized_rel_path函数的具体用法?Python normalized_rel_path怎么用?Python normalized_rel_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: get_status

 def get_status(self, basepath=None, untracked=False):
     response = None
     if basepath is None:
         basepath = self._path
     if self.path_exists():
         rel_path = normalized_rel_path(self._path, basepath)
         # git command only works inside repo
         # self._path is safe against command injection, as long as we check path.exists
         command = "git status -s "
         if not untracked:
             command += " -uno"
         _, response, _ = run_shell_command(command, shell=True, cwd=self._path)
         response_processed = ""
         for line in response.split("\n"):
             if len(line.strip()) > 0:
                 # prepend relative path
                 response_processed += "%s%s/%s\n" % (line[0:3], rel_path, line[3:])
         if LooseVersion(self.gitversion) > LooseVersion("1.7"):
             command = "git submodule foreach --recursive git status -s"
             if not untracked:
                 command += " -uno"
             _, response2, _ = run_shell_command(command, shell=True, cwd=self._path)
             for line in response2.split("\n"):
                 if line.startswith("Entering"):
                     continue
                 if len(line.strip()) > 0:
                     # prepend relative path
                     response_processed += line[0:3] + rel_path + "/" + line[3:] + "\n"
         response = response_processed
     return response
开发者ID:btubbs,项目名称:vcstools,代码行数:30,代码来源:git.py


示例2: test_normalized_rel_path

 def test_normalized_rel_path(self):
     self.assertEqual(None, normalized_rel_path(None, None))
     self.assertEqual('foo', normalized_rel_path(None, 'foo'))
     self.assertEqual('/foo', normalized_rel_path(None, '/foo'))
     self.assertEqual('../bar', normalized_rel_path('/bar', '/foo'))
     self.assertEqual('../bar', normalized_rel_path('/bar', '/foo/baz/..'))
     self.assertEqual('../bar', normalized_rel_path('/bar/bam/foo/../..', '/foo/baz/..'))
     self.assertEqual('bar', normalized_rel_path('bar/bam/foo/../..', '/foo/baz/..'))
开发者ID:cottsay,项目名称:vcstools,代码行数:8,代码来源:test_base.py


示例3: get_diff

 def get_diff(self, basepath=None):
     response = None
     if basepath is None:
         basepath = self._path
     if self.path_exists():
         rel_path = normalized_rel_path(self._path, basepath)
         command = "hg diff -g %(path)s --repository %(path)s" % {'path': sanitized(rel_path)}
         _, response, _ = run_shell_command(command, shell=True, cwd=basepath)
         response = _hg_diff_path_change(response, rel_path)
     return response
开发者ID:jbohren-forks,项目名称:vcstools,代码行数:10,代码来源:hg.py


示例4: get_diff

 def get_diff(self, basepath=None):
     response = None
     if basepath is None:
         basepath = self._path
     if self.path_exists():
         rel_path = sanitized(normalized_rel_path(self._path, basepath))
         command = "bzr diff %s" % rel_path
         command += " -p1 --prefix %s/:%s/" % (rel_path, rel_path)
         _, response, _ = run_shell_command(command, shell=True, cwd=basepath)
     return response
开发者ID:btubbs,项目名称:vcstools,代码行数:10,代码来源:bzr.py


示例5: get_diff

 def get_diff(self, basepath=None):
     response = None
     if basepath is None:
         basepath = self._path
     if self.path_exists():
         rel_path = normalized_rel_path(self._path, basepath)
         command = 'svn diff %s' % sanitized(rel_path)
         _, response, _ = run_shell_command(command,
                                            shell=True,
                                            cwd=basepath)
     return response
开发者ID:btubbs,项目名称:vcstools,代码行数:11,代码来源:svn.py


示例6: get_diff

 def get_diff(self, basepath=None):
     response = ''
     if basepath is None:
         basepath = self._path
     if self.path_exists():
         rel_path = normalized_rel_path(self._path, basepath)
         # git needs special treatment as it only works from inside
         # use HEAD to also show staged changes. Maybe should be option?
         # injection should be impossible using relpath, but to be sure, we check
         cmd = "git diff HEAD --src-prefix=%s/ --dst-prefix=%s/ ."%(sanitized(rel_path), sanitized(rel_path))
         _, response, _ = run_shell_command(cmd, shell=True, cwd=self._path)
         if LooseVersion(self.gitversion) > LooseVersion('1.7'):
             cmd = 'git submodule foreach --recursive git diff HEAD'
             _, output, _ = run_shell_command(cmd, shell=True, cwd=self._path)
             response += _git_diff_path_submodule_change(output, rel_path)
     return response
开发者ID:tkruse,项目名称:vcstools,代码行数:16,代码来源:git.py


示例7: get_status

 def get_status(self, basepath=None, untracked=False):
     response = None
     if basepath is None:
         basepath = self._path
     if self.path_exists():
         rel_path = normalized_rel_path(self._path, basepath)
         command = "bzr status %s -S" % sanitized(rel_path)
         if not untracked:
             command += " -V"
         _, response, _ = run_shell_command(command, shell=True, cwd=basepath)
         response_processed = ""
         for line in response.split('\n'):
             if len(line.strip()) > 0:
                 response_processed += line[0:4] + rel_path + '/'
                 response_processed += line[4:] + '\n'
         response = response_processed
     return response
开发者ID:btubbs,项目名称:vcstools,代码行数:17,代码来源:bzr.py


示例8: get_status

 def get_status(self, basepath=None, untracked=False):
     response = None
     if basepath is None:
         basepath = self._path
     if self.path_exists():
         rel_path = normalized_rel_path(self._path, basepath)
         # protect against shell injection
         command = "hg status %(path)s --repository %(path)s" % {"path": sanitized(rel_path)}
         if not untracked:
             command += " -mard"
         _, response, _ = run_shell_command(command, shell=True, cwd=basepath)
         if response is not None:
             if response.startswith("abort"):
                 raise VcsError("Probable Bug; Could not call %s, cwd=%s" % (command, basepath))
             if len(response) > 0 and response[-1] != "\n":
                 response += "\n"
     return response
开发者ID:wkentaro,项目名称:vcstools,代码行数:17,代码来源:hg.py


示例9: get_status

 def get_status(self, basepath=None, untracked=False):
     response = None
     if basepath is None:
         basepath = self._path
     if self.path_exists():
         rel_path = normalized_rel_path(self._path, basepath)
         # protect against shell injection
         command = 'svn status %s' % sanitized(rel_path)
         if not untracked:
             command += " -q"
         _, response, _ = run_shell_command(command,
                                            shell=True,
                                            cwd=basepath)
         if response is not None and \
            len(response) > 0 and \
            response[-1] != '\n':
             response += '\n'
     return response
开发者ID:btubbs,项目名称:vcstools,代码行数:18,代码来源:svn.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python common.run_shell_command函数代码示例发布时间:2022-05-26
下一篇:
Python bzr.BzrClient类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap