]> git.decadent.org.uk Git - dak.git/blobdiff - daklib/srcformats.py
Split parsing of "Format:" string and validation of it.
[dak.git] / daklib / srcformats.py
index 735b7b686c26b8f06bf5827c64ee215b1ef78d96..2b07c7ef4f524021b21a033944df3a7be81653af 100644 (file)
@@ -28,7 +28,7 @@ class SourceFormat(type):
                 yield "contains source files not allowed in format %s" % cls.name
 
     @classmethod
-    def parse_format(cls, txt, is_a_dsc=False, field='files'):
+    def parse_format(cls, txt):
         format = re_verwithext.search(txt)
 
         if format is None:
@@ -44,17 +44,19 @@ class SourceFormat(type):
         if format[2] is None:
             format = format[:2]
 
+        return format
+
+    @classmethod
+    def validate_format(cls, format, is_a_dsc=False, field='files'):
         if is_a_dsc:
             if format != (1,0) and \
                format != (3,0,"quilt") and format != (3,0,"native"):
-                raise UnknownFormatError, txt
+                raise UnknownFormatError, repr(format)
         else:
             if (format < (1,5) or format > (1,8)):
-                raise UnknownFormatError, txt
+                raise UnknownFormatError, repr(format)
             if field != "files" and format < (1,8):
-                raise UnknownFormatError, txt
-
-        return format
+                raise UnknownFormatError, repr(format)
 
 class FormatOne(SourceFormat):
     __metaclass__ = SourceFormat