[git-buildpackage] [PATCH 03/11] gbp.format: rename format_msg() to format_str()

Guido Günther agx at sigxcpu.org
Wed Apr 1 21:04:30 CEST 2015


On Tue, Feb 03, 2015 at 04:00:24PM +0200, Markus Lehtonen wrote:
> The new name more precisely describes it as it can be used to format any
> strings (e.g. tag names) and not only messages.
> 
> Signed-off-by: Markus Lehtonen <markus.lehtonen at linux.intel.com>
> ---
>  gbp/deb/git.py              | 4 ++--
>  gbp/format.py               | 8 ++++----
>  gbp/scripts/buildpackage.py | 4 ++--
>  gbp/scripts/import_orig.py  | 4 ++--
>  4 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/gbp/deb/git.py b/gbp/deb/git.py
> index a85e4d4..87df84e 100644
> --- a/gbp/deb/git.py
> +++ b/gbp/deb/git.py
> @@ -19,7 +19,7 @@
>  import re
>  from gbp.git import GitRepository, GitRepositoryError
>  from gbp.deb.pristinetar import DebianPristineTar
> -from gbp.format import format_msg
> +from gbp.format import format_str
>  
>  class DebianGitRepository(GitRepository):
>      """A git repository that holds the source of a Debian package"""
> @@ -114,7 +114,7 @@ class DebianGitRepository(GitRepository):
>          'libfoo-1-8-1'
>  
>          """
> -        return format_msg(format, dict(version=DebianGitRepository._sanitize_version(version),
> +        return format_str(format, dict(version=DebianGitRepository._sanitize_version(version),
>                                         hversion=DebianGitRepository._sanitize_version(version).replace('.','-')))
>  
>      @staticmethod
> diff --git a/gbp/format.py b/gbp/format.py
> index 9c37bb1..c367dc5 100644
> --- a/gbp/format.py
> +++ b/gbp/format.py
> @@ -18,20 +18,20 @@
>  
>  from gbp.errors import GbpError
>  
> -def format_msg(msg, args):
> +def format_str(msg, args):
>      """
>      Format a string with the given dict. Be a bit more verbose than
>      default python about the error cause.
>  
> -    >>> format_msg("%(foo)", {})
> +    >>> format_str("%(foo)", {})
>      Traceback (most recent call last):
>      ...
>      GbpError: Failed to format %(foo): Missing value 'foo' in {}
> -    >>> format_msg("%(foo)", {'foo': 'bar'})
> +    >>> format_str("%(foo)", {'foo': 'bar'})
>      Traceback (most recent call last):
>      ...
>      GbpError: Failed to format %(foo) with {'foo': 'bar'}: incomplete format
> -    >>> format_msg("A %(foo)s is a %(bar)s", {'foo': 'dog', 'bar': 'mamal'})
> +    >>> format_str("A %(foo)s is a %(bar)s", {'foo': 'dog', 'bar': 'mamal'})
>      'A dog is a mamal'
>      """
>      try:
> diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py
> index 4aac21b..18b8907 100755
> --- a/gbp/scripts/buildpackage.py
> +++ b/gbp/scripts/buildpackage.py
> @@ -29,7 +29,7 @@ from gbp.command_wrappers import (Command,
>  from gbp.config import (GbpOptionParserDebian, GbpOptionGroup)
>  from gbp.deb.git import (GitRepositoryError, DebianGitRepository)
>  from gbp.deb.source import DebianSource, DebianSourceError
> -from gbp.format import format_msg
> +from gbp.format import format_str
>  from gbp.git.vfs import GitVfs
>  from gbp.deb.upstreamsource import DebianUpstreamSource
>  from gbp.errors import GbpError
> @@ -605,7 +605,7 @@ def main(argv):
>              gbp.log.info("Tagging %s as %s" % (source.changelog.version, tag))
>              if options.retag and repo.has_tag(tag):
>                  repo.delete_tag(tag)
> -            tag_msg = format_msg(options.debian_tag_msg,
> +            tag_msg = format_str(options.debian_tag_msg,
>                                   dict(pkg=source.sourcepkg,
>                                        version=source.changelog.version))
>              repo.create_tag(name=tag,
> diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py
> index d95c08f..ca98459 100644
> --- a/gbp/scripts/import_orig.py
> +++ b/gbp/scripts/import_orig.py
> @@ -29,7 +29,7 @@ from gbp.deb.changelog import ChangeLog, NoChangeLogError
>  from gbp.deb.git import (GitRepositoryError, DebianGitRepository)
>  from gbp.config import GbpOptionParserDebian, GbpOptionGroup, no_upstream_branch_msg
>  from gbp.errors import GbpError
> -from gbp.format import format_msg
> +from gbp.format import format_str
>  import gbp.log
>  from gbp.scripts.common.import_orig import (orig_needs_repack, cleanup_tmp_tree,
>                                              ask_package_name, ask_package_version,
> @@ -400,7 +400,7 @@ def main(argv):
>                              epoch = '%s:' % cp.epoch
>                      info = { 'version': "%s%s-1" % (epoch, version) }
>                      env = { 'GBP_BRANCH': options.debian_branch }
> -                    gbpc.Command(format_msg(options.postimport, info), extra_env=env, shell=True)()
> +                    gbpc.Command(format_str(options.postimport, info), extra_env=env, shell=True)()
>              # Update working copy and index if we've possibly updated the
>              # checked out branch
>              current_branch = repo.get_branch()

Applied. Thanks.
 -- Guido


More information about the git-buildpackage mailing list