diff options
author | Guido Günther <agx@sigxcpu.org> | 2012-02-07 22:55:48 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2012-02-07 23:23:49 +0100 |
commit | ddbc17404620d35f0f3ba801184d7cb93bbeb539 (patch) | |
tree | c656df02b98e16497e5be61ad4316de93937b814 /gbp | |
parent | cc6ee3b56a1ad9967c9d92dfcf1159a2a30e007d (diff) |
UpstreamSource: turn is_* vars and properties into methods
since this is more consistent with the other is_* methods in other
classes.
Diffstat (limited to 'gbp')
-rw-r--r-- | gbp/deb/__init__.py | 24 | ||||
-rw-r--r-- | gbp/scripts/import_orig.py | 8 |
2 files changed, 20 insertions, 12 deletions
diff --git a/gbp/deb/__init__.py b/gbp/deb/__init__.py index b02c5fa8..cd413af0 100644 --- a/gbp/deb/__init__.py +++ b/gbp/deb/__init__.py @@ -94,8 +94,6 @@ class UpstreamSource(object): Upstream source. Can be either an unpacked dir, a tarball or another type of archive - @cvar is_dir: are the upstream sources an unpacked dir - @type is_dir: boolean @cvar _orig: are the upstream sources already suitable as an upstream tarball @type _orig: boolean @@ -105,19 +103,17 @@ class UpstreamSource(object): @type _unpacked: string """ def __init__(self, name, unpacked=None): - self.is_dir = False self._orig = False self._path = name self.unpacked = unpacked - self.is_dir = [False, True][os.path.isdir(name)] self._check_orig() - if self.is_dir: + if self.is_dir(): self.unpacked = self.path def _check_orig(self): """Check if archive can be used as orig tarball""" - if self.is_dir: + if self.is_dir(): self._orig = False return @@ -130,10 +126,22 @@ class UpstreamSource(object): except IndexError: self._orig = False - @property def is_orig(self): + """ + @return: C{True} if sources are suitable as upstream source, + C{False} otherwise + @rtype: C{bool} + """ return self._orig + def is_dir(self): + """ + @return: C{True} if if upstream sources are an unpacked directory, + C{False} otherwise + @rtype: C{bool} + """ + return True if os.path.isdir(self._path) else False + @property def path(self): return self._path.rstrip('/') @@ -143,7 +151,7 @@ class UpstreamSource(object): Unpack packed upstream sources into a given directory and determine the toplevel of the source tree. """ - if self.is_dir: + if self.is_dir(): raise GbpError, "Cannot unpack directory %s" % self.path if not filters: diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py index 98a43d2b..0fbd7cdc 100644 --- a/gbp/scripts/import_orig.py +++ b/gbp/scripts/import_orig.py @@ -62,7 +62,7 @@ class OrigUpstreamSource(UpstreamSource): """ if ((options.pristine_tar and options.filter_pristine_tar and len(options.filters) > 0)): return True - elif not self.is_orig: + elif not self.is_orig(): if len(options.filters): return True elif options.pristine_tar: @@ -224,7 +224,7 @@ def find_source(options, args): def repacked_tarball_name(source, name, version): - if source.is_orig: + if source.is_orig(): # Repacked orig tarballs get need a different name since there's already # one with that name name = os.path.join( @@ -242,7 +242,7 @@ def repack_source(source, name, version, tmpdir, filters): """Repack the source tree""" name = repacked_tarball_name(source, name, version) repacked = source.pack(name, filters) - if source.is_orig: # the tarball was filtered on unpack + if source.is_orig(): # the tarball was filtered on unpack repacked.unpacked = source.unpacked else: # otherwise unpack the generated tarball get a filtered tree if tmpdir: @@ -360,7 +360,7 @@ def main(argv): if repo.bare: set_bare_repo_options(options) - if not source.is_dir: + if not source.is_dir(): tmpdir = tempfile.mkdtemp(dir='../') source.unpack(tmpdir, options.filters) gbp.log.debug("Unpacked '%s' to '%s'" % (source.path, source.unpacked)) |