aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido G√ľnther <agx@sigxcpu.org>2008-11-15 15:59:08 +0100
committerGuido Guenther <agx@sigxcpu.org>2008-11-15 16:49:04 +0100
commit77a875c4920a352d9a307f0dd5c1e6741182b624 (patch)
treeb42dea73e8c095df17a8a27170e82520610433f2
parent45541febead4781f7814800a922d9f1dc69e579a (diff)
move common help messages into config.py
-rw-r--r--gbp/config.py29
-rwxr-xr-xgit-buildpackage22
-rwxr-xr-xgit-dch9
-rwxr-xr-xgit-import-dsc25
-rwxr-xr-xgit-import-orig22
5 files changed, 52 insertions, 55 deletions
diff --git a/gbp/config.py b/gbp/config.py
index 2235f34..20bb4a9 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -20,6 +20,8 @@ class GbpOptionParser(OptionParser):
@cvar defaults: defaults value of an option if not in the config file or
given on the command line
@type defaults: dict
+ @cvar help: help messages
+ @type help: dict
@cvar config_files: list of config files we parse
@type config_files: list
"""
@@ -45,12 +47,31 @@ class GbpOptionParser(OptionParser):
'id-length' : '0',
'no-dch' : 'False',
}
+ help = {
+ 'debian-branch':
+ "branch the Debian package is being developed on, default is '%(debian-branch)s'",
+ 'upstream-branch':
+ "upstream branch, default is '%(upstream-branch)s'",
+ 'debian-tag':
+ "format string for debian tags, default is '%(debian-tag)s'",
+ 'upstream-tag':
+ "format string for upstream tags, default is '%(upstream-tag)s'",
+ 'sign-tags':
+ "sign tags, default is '%(sign-tags)s'",
+ 'keyid':
+ "GPG keyid to sign tags with, default is '%(keyid)s'",
+ 'pristine-tar':
+ "use pristine-tar to create .orig.tar.gz, default is '%(pristine-tar)s'",
+ 'filter':
+ "files to filter out during import (can be given multiple times)",
+ }
config_files = [ '/etc/git-buildpackage/gbp.conf',
os.path.expanduser('~/.gbp.conf'),
'.gbp.conf',
'debian/gbp.conf',
'.git/gbp.conf' ]
+
def __parse_config_files(self):
"""parse the possible config files and set appropriate values default values"""
parser = SafeConfigParser(self.defaults)
@@ -83,7 +104,7 @@ class GbpOptionParser(OptionParser):
raise ValueError, "Boolean options must be True or False"
return default
- def add_config_file_option(self, option_name, dest, help, **kwargs):
+ def add_config_file_option(self, option_name, dest, help=None, **kwargs):
"""
set a option for the command line parser, the default is read from the config file
@var option_name: name of the option
@@ -93,12 +114,14 @@ class GbpOptionParser(OptionParser):
@var help: help text
@type help: string
"""
+ if not help:
+ help = self.help[option_name]
OptionParser.add_option(self, "--%s%s" % (self.prefix, option_name), dest=dest,
default=self.get_default(option_name, **kwargs),
help=help % self.config, **kwargs)
class GbpOptionGroup(OptionGroup):
- def add_config_file_option(self, option_name, dest, help, **kwargs):
+ def add_config_file_option(self, option_name, dest, help=None, **kwargs):
"""
set a option for the command line parser, the default is read from the config file
@var option_name: name of the option
@@ -108,6 +131,8 @@ class GbpOptionGroup(OptionGroup):
@var help: help text
@type help: string
"""
+ if not help:
+ help = self.parser.help[option_name]
OptionGroup.add_option(self, "--%s%s" % (self.parser.prefix, option_name), dest=dest,
default=self.parser.get_default(option_name, **kwargs),
help=help % self.parser.config, **kwargs)
diff --git a/git-buildpackage b/git-buildpackage
index a9f00b1..4324902 100755
--- a/git-buildpackage
+++ b/git-buildpackage
@@ -155,25 +155,17 @@ def main(argv):
help="create a tag after a successful build")
tag_group.add_option("--git-tag-only", action="store_true", dest="tag_only", default=False,
help="don't build, only tag and run the posttag hook")
- tag_group.add_config_file_option(option_name="sign-tags", dest="sign_tags",
- help="sign tags, default is '%(sign-tags)s'", action="store_true")
- tag_group.add_config_file_option(option_name="keyid", dest="keyid",
- help="GPG keyid to sign tags with, default is '%(keyid)s'")
- tag_group.add_config_file_option(option_name="debian-tag", dest="debian_tag",
- help="format string for debian tags, default is '%(debian-tag)s'")
- tag_group.add_config_file_option(option_name="upstream-tag", dest="upstream_tag",
- help="format string for upstream tags, default is '%(upstream-tag)s'")
- orig_group.add_config_file_option(option_name="pristine-tar", dest="pristine_tar",
- help="use pristine-tar to create .orig.tar.gz, default is '%(pristine-tar)s'",
- action="store_true")
+ tag_group.add_config_file_option(option_name="sign-tags", dest="sign_tags", action="store_true")
+ tag_group.add_config_file_option(option_name="keyid", dest="keyid")
+ tag_group.add_config_file_option(option_name="debian-tag", dest="debian_tag")
+ tag_group.add_config_file_option(option_name="upstream-tag", dest="upstream_tag")
+ orig_group.add_config_file_option(option_name="pristine-tar", dest="pristine_tar", action="store_true")
orig_group.add_config_file_option(option_name="no-create-orig", dest="no_create_orig",
help="don't create orig.tar.gz", action="store_true")
orig_group.add_config_file_option(option_name="tarball-dir", dest="tarball_dir",
help="location to look for external tarballs")
- branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch",
- help="upstream branch, default is '%(upstream-branch)s'")
- branch_group.add_config_file_option(option_name="debian-branch", dest='debian_branch',
- help="branch the Debian package is being developed on, default is '%(debian-branch)s'")
+ 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")
cmd_group.add_config_file_option(option_name="builder", dest="builder",
help="command to build the Debian package, default is '%(builder)s'")
cmd_group.add_config_file_option(option_name="cleaner", dest="cleaner",
diff --git a/git-dch b/git-dch
index 30785c1..69a3937 100755
--- a/git-dch
+++ b/git-dch
@@ -263,12 +263,9 @@ def main(argv):
parser.add_option_group(commit_group)
parser.add_option_group(naming_group)
- naming_group.add_config_file_option(option_name="debian-branch", dest='debian_branch',
- help="branch the debian patch is being developed on, default is '%(debian-branch)s'")
- naming_group.add_config_file_option(option_name="upstream-tag", dest="upstream_tag",
- help="format string for upstream tags, default is '%(upstream-tag)s'")
- naming_group.add_config_file_option(option_name="debian-tag", dest="debian_tag",
- help="format string for debian tags, default is '%(debian-tag)s'")
+ naming_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
+ naming_group.add_config_file_option(option_name="upstream-tag", dest="upstream_tag")
+ naming_group.add_config_file_option(option_name="debian-tag", dest="debian_tag")
naming_group.add_config_file_option(option_name="snapshot-number", dest="snapshot_number",
help="expression to determine the next snapshot number, default is '%(snapshot-number)s'")
parser.add_config_file_option(option_name="git-log", dest="git_log",
diff --git a/git-import-dsc b/git-import-dsc
index e0cd5ec..ff1b827 100755
--- a/git-import-dsc
+++ b/git-import-dsc
@@ -143,25 +143,16 @@ def main(argv):
parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
help="verbose command execution")
- parser.add_config_file_option(option_name="debian-branch", dest='debian_branch',
- help="branch the debian patch is being developed on, default is '%(debian-branch)s'")
- parser.add_config_file_option(option_name="upstream-branch", dest="upstream_branch",
- help="upstream branch, default is '%(upstream-branch)s'")
+ parser.add_config_file_option(option_name="debian-branch", dest="debian_branch")
+ parser.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
parser.add_option("--no-merge", dest='merge', action="store_false", default=True,
help="after import dont do any merging to another branch")
- parser.add_config_file_option(option_name="sign-tags", dest="sign_tags",
- help="sign git tags", action="store_true")
- parser.add_config_file_option(option_name="keyid", dest="keyid",
- help="GPG keyid to sign tags with")
- parser.add_config_file_option(option_name="debian-tag", dest="debian_tag",
- help="Format string for debian tags, default is '%(debian-tag)s'")
- parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag",
- help="Format string for upstream tags, default is '%(upstream-tag)s'")
- parser.add_config_file_option(option_name="filter", dest="filters",
- help="files to filter out during import (can be given multiple times)",
- action="append")
- parser.add_config_file_option(option_name="pristine-tar", dest="pristine_tar",
- help="Use pristine-tar to import the tarball", action="store_true")
+ parser.add_config_file_option(option_name="sign-tags", dest="sign_tags", action="store_true")
+ parser.add_config_file_option(option_name="keyid", dest="keyid")
+ parser.add_config_file_option(option_name="debian-tag", dest="debian_tag")
+ parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag")
+ parser.add_config_file_option(option_name="filter", dest="filters", action="append")
+ parser.add_config_file_option(option_name="pristine-tar", dest="pristine_tar", action="store_true")
(options, args) = parser.parse_args(argv[1:])
if options.verbose:
diff --git a/git-import-orig b/git-import-orig
index fac26b3..1a91738 100755
--- a/git-import-orig
+++ b/git-import-orig
@@ -109,25 +109,17 @@ def main(argv):
help="Upstream Version")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
help="verbose command execution")
+ parser.add_config_file_option(option_name="debian-branch", dest="debian_branch")
+ parser.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
parser.add_option("--no-merge", dest='merge', action="store_false", default=True,
help="after import dont do any merging to another branch")
parser.add_config_file_option(option_name="no-dch", dest='no_dch',
help="don't call dch after the import", action="store_true")
- parser.add_config_file_option(option_name="debian-branch", dest='debian_branch',
- help="branch the debian patch is being developed on, default is '%(debian-branch)s'")
- parser.add_config_file_option(option_name="upstream-branch", dest="upstream_branch",
- help="upstream branch, default is '%(upstream-branch)s'")
- parser.add_config_file_option(option_name="sign-tags", dest="sign_tags",
- help="sign git tags", action="store_true")
- parser.add_config_file_option(option_name="keyid", dest="keyid",
- help="GPG keyid to sign tags with")
- parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag",
- help="format string for upstream tags, default is '%(upstream-tag)s'")
- parser.add_config_file_option(option_name="filter", dest="filters",
- help="files to filter out during import (can be given multiple times)",
- action="append")
- parser.add_config_file_option(option_name="pristine-tar", dest="pristine_tar",
- help="run pristine-tar to import the tarball", action="store_true")
+ parser.add_config_file_option(option_name="sign-tags", dest="sign_tags", action="store_true")
+ parser.add_config_file_option(option_name="keyid", dest="keyid")
+ parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag")
+ parser.add_config_file_option(option_name="filter", dest="filters", action="append")
+ parser.add_config_file_option(option_name="pristine-tar", dest="pristine_tar", action="store_true")
(options, args) = parser.parse_args(argv[1:])
if options.verbose: