]> git.decadent.org.uk Git - dak.git/blob - daklib/srcformats.py
Don't pass dsc_filename to reject_msgs; prepend it in check_dsc_files.
[dak.git] / daklib / srcformats.py
1 import re
2
3 srcformats = []
4
5 class SourceFormat(type):
6     def __new__(cls, name, bases, attrs):
7         klass = super(SourceFormat, cls).__new__(cls, name, bases, attrs)
8         srcformats.append(klass)
9
10         klass.re_format = re.compile(klass.format)
11
12         return klass
13
14 class FormatOne(object):
15     __metaclass__ = SourceFormat
16
17     format = r'1.0'
18
19     @classmethod
20     def reject_msgs(cls, has_native_tar, has_native_tar_gz, has_debian_tar, has_debian_diff, has_orig_tar, has_orig_tar_gz, has_more_orig_tar):
21         if not (has_native_tar_gz or (has_orig_tar_gz and has_debian_diff)):
22             yield "no .tar.gz or .orig.tar.gz+.diff.gz in 'Files' field."
23         if (has_orig_tar_gz != has_orig_tar) or \
24            (has_native_tar_gz != has_native_tar) or \
25            has_debian_tar or has_more_orig_tar:
26             yield "contains source files not allowed in format 1.0"
27
28 class FormatThree(object):
29     __metaclass__ = SourceFormat
30
31     format = r'3\.\d+ \(native\)'
32
33     @classmethod
34     def reject_msgs(cls, has_native_tar, has_native_tar_gz, has_debian_tar, has_debian_diff, has_orig_tar, has_orig_tar_gz, has_more_orig_tar):
35         if not has_native_tar:
36             yield "lack required files for format 3.x (native)."
37         if has_orig_tar or has_debian_diff or has_debian_tar or has_more_orig_tar:
38             yield "contains source files not allowed in format '3.x (native)'"
39
40 class FormatThreeQuilt(object):
41     __metaclass__ = SourceFormat
42
43     format = r'3\.\d+ \(quilt\)'
44
45     @classmethod
46     def reject_msgs(cls, has_native_tar, has_native_tar_gz, has_debian_tar, has_debian_diff, has_orig_tar, has_orig_tar_gz, has_more_orig_tar):
47         if not(has_orig_tar and has_debian_tar):
48             yield "lack required files for format '3.x (quilt)'."
49         if has_debian_diff or has_native_tar:
50             yield "contains source files not allowed in format 3.x (quilt)"