X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fsrcformats.py;h=ade3c45388b6a32d2e27c27d15a4a33a11e98b5a;hb=68f805c214aa62ccd2e3624ebbc6f323eb8eb6dc;hp=bcb2e2bbae4e373df2e0c2cb1a130a58d15cfa1e;hpb=fee8895dd909a9d0f4f4a71c83f689dabee62cfe;p=dak.git diff --git a/daklib/srcformats.py b/daklib/srcformats.py index bcb2e2bb..ade3c453 100644 --- a/daklib/srcformats.py +++ b/daklib/srcformats.py @@ -5,6 +5,19 @@ 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 + def parse_format(txt): """ Parse a .changes Format string into a tuple representation for easy