summaryrefslogtreecommitdiff
path: root/gbp
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2013-04-29 20:55:40 +0200
committerGuido Günther <agx@sigxcpu.org>2013-04-29 21:14:18 +0200
commit43e60bb76e80c6ca7be1ee1da582fe78c5465349 (patch)
tree415cea02d452df14d26c25344601c7be3b03fe9b /gbp
parent45c2346f6a52aec196dd89b8d09d8b06d05b8867 (diff)
Make parse_dsc a classmethod of DscFile
so we have the object creation close to the object itself.
Diffstat (limited to 'gbp')
-rw-r--r--gbp/deb/__init__.py11
-rw-r--r--gbp/deb/dscfile.py8
-rw-r--r--gbp/scripts/import_dsc.py4
-rw-r--r--gbp/scripts/import_dscs.py7
4 files changed, 14 insertions, 16 deletions
diff --git a/gbp/deb/__init__.py b/gbp/deb/__init__.py
index bff4783..41fc8fd 100644
--- a/gbp/deb/__init__.py
+++ b/gbp/deb/__init__.py
@@ -26,7 +26,6 @@ from gbp.git import GitRepositoryError
# Make sure these are available with 'import gbp.deb'
from gbp.deb.changelog import ChangeLog, NoChangeLogError
from gbp.deb.policy import DebianPkgPolicy
-from gbp.deb.dscfile import DscFile
class DpkgCompareVersions(gbpc.Command):
cmd='/usr/bin/dpkg'
@@ -52,16 +51,6 @@ class DpkgCompareVersions(gbpc.Command):
return 0
-def parse_dsc(dscfile):
- """parse dsc by creating a DscFile object"""
- try:
- dsc = DscFile(dscfile)
- except IOError as err:
- raise GbpError("Error reading dsc file: %s" % err)
-
- return dsc
-
-
def parse_changelog_repo(repo, branch, filename):
"""
Parse the changelog file from given branch in the git
diff --git a/gbp/deb/dscfile.py b/gbp/deb/dscfile.py
index 6f450e2..abaf690 100644
--- a/gbp/deb/dscfile.py
+++ b/gbp/deb/dscfile.py
@@ -110,4 +110,12 @@ class DscFile(object):
def __str__(self):
return "<%s object %s>" % (self.__class__.__name__, self.dscfile)
+ @classmethod
+ def parse(cls, filename):
+ try:
+ dsc = cls(filename)
+ except IOError as err:
+ raise GbpError("Error reading dsc file: %s" % err)
+ return dsc
+
# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·:
diff --git a/gbp/scripts/import_dsc.py b/gbp/scripts/import_dsc.py
index 7ed0e36..11c47e8 100644
--- a/gbp/scripts/import_dsc.py
+++ b/gbp/scripts/import_dsc.py
@@ -27,7 +27,7 @@ import pipes
import time
import gbp.command_wrappers as gbpc
from gbp.pkg import UpstreamSource
-from gbp.deb import parse_dsc
+from gbp.deb.dscfile import DscFile
from gbp.deb.git import (DebianGitRepository, GitRepositoryError)
from gbp.deb.changelog import ChangeLog
from gbp.git import rfc822_date_to_git
@@ -263,7 +263,7 @@ def main(argv):
else:
dsc = pkg
- src = parse_dsc(dsc)
+ src = DscFile.parse(dsc)
if src.pkgformat not in [ '1.0', '3.0' ]:
raise GbpError("Importing %s source format not yet supported." % src.pkgformat)
if options.verbose:
diff --git a/gbp/scripts/import_dscs.py b/gbp/scripts/import_dscs.py
index 565f6df..e15808f 100644
--- a/gbp/scripts/import_dscs.py
+++ b/gbp/scripts/import_dscs.py
@@ -21,7 +21,8 @@ import os
import sys
import tempfile
import gbp.command_wrappers as gbpc
-from gbp.deb import parse_dsc, DpkgCompareVersions
+from gbp.deb import DpkgCompareVersions
+from gbp.deb.dscfile import DscFile
from gbp.errors import GbpError
from gbp.git import GitRepository, GitRepositoryError
from gbp.scripts import import_dsc
@@ -119,7 +120,7 @@ def main(argv):
else:
for arg in argv[::-1]:
if arg.endswith('.dsc'):
- dscs.append(parse_dsc(arg))
+ dscs.append(DscFile.parse(arg))
import_args.remove(arg)
if not use_debsnap and not dscs:
@@ -128,7 +129,7 @@ def main(argv):
if use_debsnap:
dirs['tmp'] = os.path.abspath(tempfile.mkdtemp())
- dscs = [ parse_dsc(f) for f in fetch_snapshots(pkg, dirs['tmp']) ]
+ dscs = [ DscFile.parse(f) for f in fetch_snapshots(pkg, dirs['tmp']) ]
dscs.sort(cmp=dsc_cmp)
importer = GitImportDsc(import_args)