diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2012-01-12 15:40:42 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2012-02-13 18:54:16 +0100 |
commit | bca9f76135c5b4975b261018f0c9013243f38846 (patch) | |
tree | 9047069f7ac0c33ae3e920412d2c489f28fe3e01 | |
parent | 24e772577b071cb4297a5ed4b807aab334027144 (diff) |
Refactor config.py as preparation for rpm support.
Split GbpOptionParser in to a common base class and a Debian
specific subclass, as a preparation for upcoming RPM support.
This allows having different default values (and help texts) for common
options between different package types, and, clearer separation of
package type specific options.
Signed-off-by: Guido Günther <agx@sigxcpu.org>
-rwxr-xr-x | examples/gbp-add-patch | 4 | ||||
-rw-r--r-- | gbp/config.py | 17 | ||||
-rwxr-xr-x | gbp/scripts/buildpackage.py | 4 | ||||
-rwxr-xr-x | gbp/scripts/clone.py | 6 | ||||
-rw-r--r-- | gbp/scripts/create_remote_repo.py | 6 | ||||
-rw-r--r-- | gbp/scripts/dch.py | 6 | ||||
-rw-r--r-- | gbp/scripts/import_dsc.py | 6 | ||||
-rw-r--r-- | gbp/scripts/import_orig.py | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | gbp/scripts/pq.py | 6 | ||||
-rwxr-xr-x | gbp/scripts/pull.py | 6 |
10 files changed, 38 insertions, 29 deletions
diff --git a/examples/gbp-add-patch b/examples/gbp-add-patch index 5a974cd..6af6bc4 100755 --- a/examples/gbp-add-patch +++ b/examples/gbp-add-patch @@ -38,7 +38,7 @@ import os, os.path from gbp.command_wrappers import (Command, CommandExecFailed, GitCommand) -from gbp.config import (GbpOptionParser, GbpOptionGroup) +from gbp.config import (GbpOptionParserDebian, GbpOptionGroup) from gbp.errors import GbpError from gbp.git import (GitRepositoryError, GitRepository) from gbp.patch_series import Patch @@ -70,7 +70,7 @@ def build_commit_msg(repo, patch, options): def main(argv): retval = 0 - parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', + parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='', usage='%prog [options] - add a new patch') parser.add_config_file_option(option_name="meta-closes", dest="meta_closes", help="Meta tags for the bts close commands, default is '%(meta-closes)s'") diff --git a/gbp/config.py b/gbp/config.py index e857b3e..87334f0 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -51,7 +51,7 @@ class GbpOption(Option): TYPE_CHECKER['path'] = expand_path TYPE_CHECKER['tristate'] = check_tristate -class GbpOptionParser(OptionParser): +class GbpOptionParserCommon(OptionParser): """ Handles commandline options and parsing of config files @ivar command: the gbp command we store the options for @@ -68,9 +68,7 @@ class GbpOptionParser(OptionParser): @cvar config_files: list of config files we parse @type config_files: list """ - defaults = { 'builder' : 'debuild -i -I', - 'cleaner' : 'debuild -d clean', - 'debian-branch' : 'master', + defaults = { 'debian-branch' : 'master', 'upstream-branch' : 'upstream', 'upstream-tree' : 'TAG', 'pristine-tar' : 'False', @@ -327,4 +325,15 @@ class GbpOptionGroup(OptionGroup): neg_help = "negates '--%s%s'" % (self.parser.prefix, option_name) self.add_config_file_option(option_name="no-%s" % option_name, dest=dest, help=neg_help, action="store_false") + +class GbpOptionParserDebian(GbpOptionParserCommon): + """ + Handles commandline options and parsing of config files for Debian tools + """ + defaults = dict(GbpOptionParserCommon.defaults) + defaults.update( { + 'builder' : 'debuild -i -I', + 'cleaner' : 'debuild -d clean', + } ) + # vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py index 327c398..3fd6917 100755 --- a/gbp/scripts/buildpackage.py +++ b/gbp/scripts/buildpackage.py @@ -29,7 +29,7 @@ import gbp.deb as du from gbp.command_wrappers import (Command, RunAtCommand, CommandExecFailed, RemoveTree, CatenateTarArchive) -from gbp.config import (GbpOptionParser, GbpOptionGroup) +from gbp.config import (GbpOptionParserDebian, GbpOptionGroup) from gbp.deb.git import (GitRepositoryError, DebianGitRepository) from gbp.deb.changelog import ChangeLog, NoChangeLogError, ParseChangeLogError from gbp.errors import GbpError @@ -465,7 +465,7 @@ def parse_args(argv, prefix): args.append(arg) try: - parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix=prefix) + parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix=prefix) except ConfigParser.ParsingError, err: gbp.log.err(err) return None, None, None diff --git a/gbp/scripts/clone.py b/gbp/scripts/clone.py index 5dffbd0..ab2fc97 100755 --- a/gbp/scripts/clone.py +++ b/gbp/scripts/clone.py @@ -21,7 +21,7 @@ import sys import os, os.path -from gbp.config import (GbpOptionParser, GbpOptionGroup) +from gbp.config import (GbpOptionParserCommon, GbpOptionGroup) from gbp.deb.git import DebianGitRepository from gbp.git import (GitRepository, GitRepositoryError) from gbp.command_wrappers import (Command, CommandExecFailed) @@ -30,8 +30,8 @@ import gbp.log def parse_args (argv): - parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', - usage='%prog [options] repository - clone a remote repository') + parser = GbpOptionParserCommon(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) diff --git a/gbp/scripts/create_remote_repo.py b/gbp/scripts/create_remote_repo.py index d00963c..d6174e3 100644 --- a/gbp/scripts/create_remote_repo.py +++ b/gbp/scripts/create_remote_repo.py @@ -28,7 +28,7 @@ import tty, termios import re from gbp.deb.changelog import ChangeLog, NoChangeLogError from gbp.command_wrappers import (CommandExecFailed, GitCommand) -from gbp.config import (GbpOptionParser, GbpOptionGroup) +from gbp.config import (GbpOptionParserDebian, GbpOptionGroup) from gbp.errors import GbpError from gbp.git import (GitRepositoryError, GitRepository) import gbp.log @@ -146,8 +146,8 @@ def main(argv): retval = 0 changelog = 'debian/changelog' - parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', - usage='%prog [options] - create a remote repository') + parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='', + usage='%prog [options] - create a remote repository') branch_group = GbpOptionGroup(parser, "branch options", "branch layout and tracking options") branch_group.add_config_file_option(option_name="remote-url-pattern", dest="remote_url") parser.add_option_group(branch_group) diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py index 2ee988d..3a4a02a 100644 --- a/gbp/scripts/dch.py +++ b/gbp/scripts/dch.py @@ -26,7 +26,7 @@ import subprocess import gbp.command_wrappers as gbpc import gbp.dch as dch import gbp.log -from gbp.config import GbpOptionParser, GbpOptionGroup +from gbp.config import GbpOptionParserDebian, GbpOptionGroup from gbp.errors import GbpError from gbp.deb import compare_versions from gbp.deb.git import GitRepositoryError, DebianGitRepository @@ -332,8 +332,8 @@ def main(argv): version_change = {} try: - parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', - usage='%prog [options] paths') + parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='', + usage='%prog [options] paths') except ConfigParser.ParsingError, err: gbp.log.errror(err) return 1 diff --git a/gbp/scripts/import_dsc.py b/gbp/scripts/import_dsc.py index 6aed3c2..c5093fc 100644 --- a/gbp/scripts/import_dsc.py +++ b/gbp/scripts/import_dsc.py @@ -32,7 +32,7 @@ from gbp.deb import (debian_version_chars, from gbp.deb.git import (DebianGitRepository, GitRepositoryError) from gbp.deb.changelog import ChangeLog from gbp.git import rfc822_date_to_git -from gbp.config import GbpOptionParser, GbpOptionGroup, no_upstream_branch_msg +from gbp.config import GbpOptionParserDebian, GbpOptionGroup, no_upstream_branch_msg from gbp.errors import GbpError import gbp.log @@ -160,8 +160,8 @@ def set_bare_repo_options(options): def parse_args(argv): try: - parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', - usage='%prog [options] /path/to/package.dsc') + parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='', + usage='%prog [options] /path/to/package.dsc') except ConfigParser.ParsingError, err: gbp.log.err(err) return None, None diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py index 0446fda..6693acd 100644 --- a/gbp/scripts/import_orig.py +++ b/gbp/scripts/import_orig.py @@ -32,7 +32,7 @@ from gbp.deb import (UpstreamSource, upstreamversion_msg) from gbp.deb.changelog import ChangeLog, NoChangeLogError from gbp.deb.git import (GitRepositoryError, DebianGitRepository) -from gbp.config import GbpOptionParser, GbpOptionGroup, no_upstream_branch_msg +from gbp.config import GbpOptionParserDebian, GbpOptionGroup, no_upstream_branch_msg from gbp.errors import (GbpError, GbpNothingImported) import gbp.log @@ -269,8 +269,8 @@ def set_bare_repo_options(options): def parse_args(argv): try: - parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', - usage='%prog [options] /path/to/upstream-version.tar.gz | --uscan') + parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='', + usage='%prog [options] /path/to/upstream-version.tar.gz | --uscan') except ConfigParser.ParsingError, err: gbp.log.err(err) return None, None diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py index 9193f2b..dbb4618 100644..100755 --- a/gbp/scripts/pq.py +++ b/gbp/scripts/pq.py @@ -24,7 +24,7 @@ import shutil import subprocess import sys import tempfile -from gbp.config import (GbpOptionParser, GbpOptionGroup) +from gbp.config import (GbpOptionParserDebian, GbpOptionGroup) from gbp.git import (GitRepositoryError, GitRepository) from gbp.command_wrappers import (Command, GitCommand, RunAtCommand, CommandExecFailed) @@ -337,8 +337,8 @@ def switch_pq(repo, current): def main(argv): retval = 0 - parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', - usage="%prog [options] action - maintain patches on a patch queue branch\n" + parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='', + usage="%prog [options] action - maintain patches on a patch queue branch\n" "Actions:\n" " export export the patch queue associated to the current branch\n" " into a quilt patch series in debian/patches/ and update the\n" diff --git a/gbp/scripts/pull.py b/gbp/scripts/pull.py index d50ffc2..9c6f2c5 100755 --- a/gbp/scripts/pull.py +++ b/gbp/scripts/pull.py @@ -22,7 +22,7 @@ import sys import os, os.path from gbp.command_wrappers import (Command, CommandExecFailed) -from gbp.config import (GbpOptionParser, GbpOptionGroup) +from gbp.config import (GbpOptionParserCommon, GbpOptionGroup) from gbp.errors import GbpError from gbp.git import GitRepositoryError from gbp.deb.git import DebianGitRepository @@ -70,8 +70,8 @@ def fast_forward_branch(branch, repo, options): def main(argv): retval = 0 - parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='', - usage='%prog [options] - safely update a repository from remote') + parser = GbpOptionParserCommon(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_option("--force", action="store_true", dest="force", default=False, |