本文整理汇总了Python中gbp.config.GbpOptionParser.parse_args方法的典型用法代码示例。如果您正苦于以下问题:Python GbpOptionParser.parse_args方法的具体用法?Python GbpOptionParser.parse_args怎么用?Python GbpOptionParser.parse_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gbp.config.GbpOptionParser
的用法示例。
在下文中一共展示了GbpOptionParser.parse_args方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_args
# 需要导入模块: from gbp.config import GbpOptionParser [as 别名]
# 或者: from gbp.config.GbpOptionParser import parse_args [as 别名]
def parse_args (argv):
parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='',
usage='%prog [options] repository - clone a remote repository')
branch_group = GbpOptionGroup(parser, "branch options", "branch tracking and layout options")
parser.add_option_group(branch_group)
branch_group.add_option("--all", action="store_true", dest="all", default=False,
help="track all branches, not only debian and upstream")
branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
branch_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar")
branch_group.add_option("--depth", action="store", dest="depth", default=0,
help="git history depth (for creating shallow clones)")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
help="verbose command execution")
parser.add_config_file_option(option_name="color", dest="color", type='tristate')
(options, args) = parser.parse_args(argv)
gbp.log.setup(options.color, options.verbose)
return (options, args)
示例2: main
# 需要导入模块: from gbp.config import GbpOptionParser [as 别名]
# 或者: from gbp.config.GbpOptionParser import parse_args [as 别名]
def main(argv):
retval = 0
current = None
parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='',
usage='%prog [options] - safely update a repository from remote')
branch_group = GbpOptionGroup(parser, "branch options", "branch update and layout options")
parser.add_option_group(branch_group)
branch_group.add_boolean_config_file_option(option_name = "ignore-branch", dest="ignore_branch")
branch_group.add_option("--force", action="store_true", dest="force", default=False,
help="force a branch update even if it can't be fast forwarded")
branch_group.add_option("--redo-pq", action="store_true", dest="redo_pq", default=False,
help="redo the patch queue branch after a pull. Warning: this drops the old patch-queue branch")
branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
branch_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar")
branch_group.add_option("--depth", action="store", dest="depth", default=0,
help="git history depth (for deepening shallow clones)")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
help="verbose command execution")
parser.add_config_file_option(option_name="color", dest="color", type='tristate')
parser.add_config_file_option(option_name="color-scheme",
dest="color_scheme")
(options, args) = parser.parse_args(argv)
gbp.log.setup(options.color, options.verbose, options.color_scheme)
try:
repo = DebianGitRepository(os.path.curdir)
except GitRepositoryError:
gbp.log.err("%s is not a git repository" % (os.path.abspath('.')))
return 1
try:
branches = []
try:
current = repo.get_branch()
except GitRepositoryError:
# Not being on any branch is o.k. with --git-ignore-branch
if options.ignore_branch:
current = repo.head
gbp.log.info("Found detached head at '%s'" % current)
else:
raise
for branch in [ options.debian_branch, options.upstream_branch ]:
if repo.has_branch(branch):
branches += [ branch ]
if repo.has_pristine_tar_branch() and options.pristine_tar:
branches += [ repo.pristine_tar_branch ]
(ret, out) = repo.is_clean()
if not ret:
gbp.log.err("You have uncommitted changes in your source tree:")
gbp.log.err(out)
raise GbpError
repo.fetch(depth=options.depth)
repo.fetch(depth=options.depth, tags=True)
for branch in branches:
if not fast_forward_branch(branch, repo, options):
retval = 2
if options.redo_pq:
repo.set_branch(options.debian_branch)
Command("gbp-pq")(["drop"])
Command("gbp-pq")(["import"])
repo.set_branch(current)
except CommandExecFailed:
retval = 1
except (GbpError, GitRepositoryError) as err:
if len(err.__str__()):
gbp.log.err(err)
retval = 1
return retval