diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2012-02-08 14:26:24 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2012-05-01 22:28:19 +0200 |
commit | 082679da5004790d5d5bf19ede8a657f6c2b8769 (patch) | |
tree | da2955c480d6bb3b27ff4f3e6dc7bd5d6b558cf2 /gbp/deb | |
parent | 3308868a275d3ba96e411dab469367f14c767683 (diff) |
Refactor deb helpers: move build_tarball_name()
from UpstreamSource class to DebianPkgPolicy.
Diffstat (limited to 'gbp/deb')
-rw-r--r-- | gbp/deb/__init__.py | 62 | ||||
-rw-r--r-- | gbp/deb/pristinetar.py | 10 |
2 files changed, 36 insertions, 36 deletions
diff --git a/gbp/deb/__init__.py b/gbp/deb/__init__.py index 0b5168e..c0919c3 100644 --- a/gbp/deb/__init__.py +++ b/gbp/deb/__init__.py @@ -60,6 +60,34 @@ class DebianPkgPolicy(PkgPolicy): letters (a-z), digits (0-9), full stops (.), plus signs (+), minus signs (-), colons (:) and tildes (~)""" + @staticmethod + def build_tarball_name(name, version, compression, dir=None): + """ + Given a source package's I{name}, I{version} and I{compression} + return the name of the corresponding upstream tarball. + + >>> DebianPkgPolicy.build_tarball_name('foo', '1.0', 'bzip2') + 'foo_1.0.orig.tar.bz2' + >>> DebianPkgPolicy.build_tarball_name('bar', '0.0~git1234', 'xz') + 'bar_0.0~git1234.orig.tar.xz' + + @param name: the source package's name + @type name: C{str} + @param version: the upstream version + @type version: C{str} + @param compression: the desired compression + @type compression: C{str} + @param dir: a directory to prepend + @type dir: C{str} + @return: the tarballs name corresponding to the input parameters + @rtype: C{str} + """ + ext = compressor_opts[compression][1] + tarball = "%s_%s.orig.tar.%s" % (name, version, ext) + if dir: + tarball = os.path.join(dir, tarball) + return tarball + class DpkgCompareVersions(gbpc.Command): cmd='/usr/bin/dpkg' @@ -290,34 +318,6 @@ class UpstreamSource(object): if m: return (m.group('package'), m.group('version')) - @staticmethod - def build_tarball_name(name, version, compression, dir=None): - """ - Given a source package's I{name}, I{version} and I{compression} - return the name of the corresponding upstream tarball. - - >>> UpstreamSource.build_tarball_name('foo', '1.0', 'bzip2') - 'foo_1.0.orig.tar.bz2' - >>> UpstreamSource.build_tarball_name('bar', '0.0~git1234', 'xz') - 'bar_0.0~git1234.orig.tar.xz' - - @param name: the source package's name - @type name: C{str} - @param version: the upstream version - @type version: C{str} - @param compression: the desired compression - @type compression: C{str} - @param dir: a directory to prepend - @type dir: C{str} - @return: the tarballs name corresponding to the input parameters - @rtype: C{str} - """ - ext = compressor_opts[compression][1] - tarball = "%s_%s.orig.tar.%s" % (name, version, ext) - if dir: - tarball = os.path.join(dir, tarball) - return tarball - class DscFile(object): """Keeps all needed data read from a dscfile""" @@ -438,9 +438,9 @@ def orig_file(cp, compression): >>> orig_file({'Source': 'bar', 'Upstream-Version': '0.0~git1234'}, "xz") 'bar_0.0~git1234.orig.tar.xz' """ - return UpstreamSource.build_tarball_name(cp['Source'], - cp['Upstream-Version'], - compression) + return DebianPkgPolicy.build_tarball_name(cp['Source'], + cp['Upstream-Version'], + compression) def parse_uscan(out): diff --git a/gbp/deb/pristinetar.py b/gbp/deb/pristinetar.py index 2ac82ef..a2f191f 100644 --- a/gbp/deb/pristinetar.py +++ b/gbp/deb/pristinetar.py @@ -20,7 +20,7 @@ import os, re import gbp.log from gbp.command_wrappers import Command from gbp.pkg import compressor_opts -from gbp.deb import UpstreamSource +from gbp.deb import DebianPkgPolicy class PristineTar(Command): """The pristine-tar branch in a git repository""" @@ -91,10 +91,10 @@ class PristineTar(Command): @param output_dir: the directory to put the tarball into @type output_dir: C{str} """ - name = UpstreamSource.build_tarball_name(package, - version, - comp_type, - output_dir) + name = DebianPkgPolicy.build_tarball_name(package, + version, + comp_type, + output_dir) self._checkout(name) def commit(self, archive, upstream): |