diff options
Diffstat (limited to 'gbp/deb/format.py')
-rw-r--r-- | gbp/deb/format.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/gbp/deb/format.py b/gbp/deb/format.py index b9c4eb0f..2717d4bb 100644 --- a/gbp/deb/format.py +++ b/gbp/deb/format.py @@ -16,9 +16,11 @@ # <http://www.gnu.org/licenses/> """Parse debian/source/format""" + class DebianSourceFormatError(Exception): pass + class DebianSourceFormat(object): """ Contents of debian/source/format @@ -47,8 +49,7 @@ class DebianSourceFormat(object): self._version = parts[0] if len(parts) == 2: - if (parts[1][0] == '(' and - parts[1][-1] == ')'): + if (parts[1][0] == '(' and parts[1][-1] == ')'): self._type = parts[1][1:-1] else: raise DebianSourceFormatError("Cannot get source format from " @@ -73,7 +74,7 @@ class DebianSourceFormat(object): return "%s (%s)" % (self._version, self._type) @classmethod - def parse_file(klass, filename): + def parse_file(cls, filename): """ Parse debian/source/format file @@ -94,10 +95,10 @@ class DebianSourceFormat(object): >>> os.unlink(t.name) """ with open(filename) as f: - return klass(f.read()) + return cls(f.read()) @classmethod - def from_content(klass, version, type, format_file=None): + def from_content(cls, version, type, format_file=None): """ Write a format file from I{type} and I{format} at I{format_file} @@ -107,10 +108,11 @@ class DebianSourceFormat(object): @param format_file: the format file to create with the above parameters """ - format_file = format_file or klass.format_file - with open(klass.format_file, 'w') as f: + format_file = format_file or cls.format_file + with open(cls.format_file, 'w') as f: f.write("%s (%s)" % (version, type)) - return klass.parse_file(klass.format_file) + return cls.parse_file(cls.format_file) + if __name__ == "__main__": import doctest |