format = r'1.0'
@classmethod
- def reject_msgs(cls, native_tar, native_tar_gz, debian_tar, debian_diff, orig_tar, orig_tar_gz, more_orig_tar):
- if not (native_tar_gz or (orig_tar_gz and debian_diff)):
+ 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 (orig_tar_gz != orig_tar) or \
- (native_tar_gz != native_tar) or \
- debian_tar or more_orig_tar:
+ if (has['orig_tar_gz'] != has['orig_tar']) or \
+ (has['native_tar_gz'] != has['native_tar']) or \
+ has['debian_tar'] or has['more_orig_tar']:
yield "contains source files not allowed in format %s" % cls.name
class FormatThree(object):
format = r'3\.\d+ \(native\)'
@classmethod
- def reject_msgs(cls, native_tar, native_tar_gz, debian_tar, debian_diff, orig_tar, orig_tar_gz, more_orig_tar):
- if not native_tar:
+ def reject_msgs(cls, has):
+ if not has['native_tar']:
yield "lack of required files for format %s" % cls.name
- if orig_tar or debian_diff or debian_tar or more_orig_tar:
+ if has['orig_tar'] or has['debian_diff'] or has['debian_tar'] or has['more_orig_tar']:
yield "contains source files not allowed in format %s" % cls.name
class FormatThreeQuilt(object):
format = r'3\.\d+ \(quilt\)'
@classmethod
- def reject_msgs(cls, native_tar, native_tar_gz, debian_tar, debian_diff, orig_tar, orig_tar_gz, more_orig_tar):
- if not(orig_tar and debian_tar):
+ def reject_msgs(cls, has):
+ if not (has['orig_tar'] and has['debian_tar']):
yield "lack of required files for format %s" % cls.name
- if debian_diff or native_tar:
+ if has['debian_diff'] or has['native_tar']:
yield "contains source files not allowed in format %s" % cls.name
re_re_mark, re_whitespace_comment, re_issource
from srcformats import srcformats
+from collections import defaultdict
################################################################################
# Ensure .dsc lists proper set of source files according to the format
# announced
- has_native_tar = 0
- has_native_tar_gz = 0
- has_orig_tar = 0
- has_orig_tar_gz = 0
- has_more_orig_tar = 0
- has_debian_tar = 0
- has_debian_diff = 0
+ has = defaultdict(lambda: 0)
+
for f in dsc_files.keys():
m = re_issource.match(f)
if not m:
continue
ftype = m.group(3)
if ftype == "orig.tar.gz":
- has_orig_tar_gz += 1
- has_orig_tar += 1
+ has['orig_tar_gz'] += 1
+ has['orig_tar'] += 1
elif ftype == "diff.gz":
- has_debian_diff += 1
+ has['debian_diff'] += 1
elif ftype == "tar.gz":
- has_native_tar_gz += 1
- has_native_tar += 1
+ has['native_tar_gz'] += 1
+ has['native_tar'] += 1
elif re.match(r"debian\.tar\.(gz|bz2|lzma)", ftype):
- has_debian_tar += 1
+ has['debian_tar'] += 1
elif re.match(r"orig\.tar\.(gz|bz2|lzma)", ftype):
- has_orig_tar += 1
+ has['orig_tar'] += 1
elif re.match(r"tar\.(gz|bz2|lzma)", ftype):
- has_native_tar += 1
+ has['native_tar'] += 1
elif re.match(r"orig-.+\.tar\.(gz|bz2|lzma)", ftype):
- has_more_orig_tar += 1
+ has['more_orig_tar'] += 1
else:
reject("%s: unexpected source file '%s'" % (dsc_filename, f))
- if has_orig_tar > 1:
+ if has['orig_tar'] > 1:
rejmsg.append("%s: lists multiple .orig tarballs." % (dsc_filename))
- if has_native_tar > 1:
+ if has['native_tar'] > 1:
rejmsg.append("%s: lists multiple native tarballs." % (dsc_filename))
- if has_debian_tar > 1 or has_debian_diff > 1:
+ if has['debian_tar'] > 1 or has['debian_diff'] > 1:
rejmsg.append("%s: lists multiple debian diff/tarballs." % (dsc_filename))
for format in srcformats:
if format.re_format.match(dsc['format']):
- msgs = format.reject_msgs(
- has_native_tar,
- has_native_tar_gz,
- has_debian_tar,
- has_debian_diff,
- has_orig_tar,
- has_orig_tar_gz,
- has_more_orig_tar
- )
- rejmsg.extend(['%s: %s' % (dsc_filename, x) for x in msgs])
+ rejmsg.extend([
+ '%s: %s' % (dsc_filename, x) for x in format.reject_msgs(has)
+ ])
break
return rejmsg