X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fsrcformats.py;h=7d7dd940e3837c1c5c99a7f8708ae3663ae53d44;hb=d0779ef69d429a210405002f252067806ddfa6f2;hp=87ba2f89c614bd71c9903a4ff7d05a6ee379179b;hpb=b2d2d87ae436de26dacd15885c6e71309c869180;p=dak.git diff --git a/daklib/srcformats.py b/daklib/srcformats.py index 87ba2f89..7d7dd940 100644 --- a/daklib/srcformats.py +++ b/daklib/srcformats.py @@ -1,7 +1,22 @@ import re +from dak_exceptions import UnknownFormatError + srcformats = [] +def get_format_from_string(txt): + """ + Returns the SourceFormat class that corresponds to the specified .changes + Format value. If the string does not match any class, UnknownFormatError + is raised. + """ + + for format in srcformats: + if format.re_format.match(txt): + return format + + raise UnknownFormatError, "Unknown format %r" % txt + class SourceFormat(type): def __new__(cls, name, bases, attrs): klass = super(SourceFormat, cls).__new__(cls, name, bases, attrs) @@ -17,7 +32,7 @@ class SourceFormat(type): @classmethod def reject_msgs(cls, has): - if len(cls.required) != len([x for x in requires if has[x]]): + if len(cls.requires) != len([x for x in cls.requires if has[x]]): yield "lack of required files for format %s" % cls.name for key in cls.disallowed: @@ -37,6 +52,8 @@ class FormatOne(SourceFormat): def reject_msgs(cls, has): if not (has['native_tar_gz'] or (has['orig_tar_gz'] and has['debian_diff'])): yield "no .tar.gz or .orig.tar.gz+.diff.gz in 'Files' field." + if has['native_tar_gz'] and has['debian_diff']: + yield "native package with diff makes no sense" if (has['orig_tar_gz'] != has['orig_tar']) or \ (has['native_tar_gz'] != has['native_tar']): yield "contains source files not allowed in format %s" % cls.name