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


Python Git.module_name方法代码示例

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


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

示例1: Attach

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import module_name [as 别名]
class Attach():
	def __init__(self):
		self.git = Git()
		self.parser = OptionParser()
		self.parser.set_usage("mgit attach <subproject name>")

	def print_usage(self):
		self.parser.print_usage()

	def run(self, args):
		options, args = self.parser.parse_args(args[1:])
		if len(args) <= 0:
			self.parser.print_usage()
			return
	
		if len(args) > 1:
			module = args[1]
		else:
			module = self.git.module_name(args[0])
		if module == None or len(module) <= 0:
			return

		if not os.path.exists(module):
			print("module %s not exists." % module)
			return

		project = Project()
		project.append(module)
开发者ID:cpsoft,项目名称:mgit,代码行数:30,代码来源:attach.py

示例2: Clone

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import module_name [as 别名]
class Clone():
	def __init__(self):
		self.git = Git()
		self.parser = OptionParser()
		self.parser.add_option("-b", "--branch", dest="branch", help="with checkout branch")
		self.parser.add_option("-C", "--repo-dir", dest="repodir", help="repo directory")
		self.parser.add_option("-R", "--recursive", dest="recursive", help="clone project and subproject recursively")
		self.parser.set_usage("mgit clone <url> [-b <branch>]")

	def print_usage(self):
		self.parser.print_usage()
	
	def run(self, orig_args):
		options,args = self.parser.parse_args(orig_args)
		args = args[1:]
		if len(args) <= 0:
			self.print_usage()
			return
		project_dir = self.git.module_name(args[0])
		if project_dir == None or len(project_dir) <= 0:
			print("Unknow project name.Please use git clone, then use mgit sync in the project dir.")
			return
		cmd = ['git', 'clone'] + args
		if options.branch != None:
			cmd += ["-b", options.branch]
		if 0 != os.system(" ".join(cmd)):
			return
		cwd = os.getcwd()
		os.chdir("/".join([cwd, project_dir]))
		sync = Sync()
		sync.run(['sync'] + orig_args[1:])
		os.chdir(cwd)
开发者ID:cpsoft,项目名称:mgit,代码行数:34,代码来源:clone.py


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