__all__.append('CHANGESFIELDS_DSCFILES_OPTIONAL')
+CHANGESFIELDS_ORIGFILES = [ "id", "location" ]
+
+__all__.append('CHANGESFIELDS_ORIGFILES')
+
###############################################################################
class Changes(object):
self.dsc = {}
self.files = {}
self.dsc_files = {}
-
- self.orig_tar_id = None
- self.orig_tar_location = ""
- self.orig_tar_gz = None
+ self.orig_files = {}
def file_summary(self):
# changes["distribution"] may not exist in corner cases
or the text of a warning if there are
"""
- conf = Config()
summary = ""
# Abandon the check if it's a non-sourceful upload
entry["override section"])
if entry["priority"] != "-":
- if entry["priority"] != entry["override_priority"]:
+ if entry["priority"] != entry["override priority"]:
summary += "%s: package says priority is %s, override says %s.\n" % (name,
entry["priority"],
entry["override priority"])
self.files.update(p.load())
self.dsc_files.update(p.load())
- self.orig_tar_id = p.load()
- self.orig_tar_location = p.load()
+ next_obj = p.load()
+ if isinstance(next_obj, dict):
+ self.orig_files.update(next_obj)
+ else:
+ # Auto-convert old dak files to new format supporting
+ # multiple tarballs
+ orig_tar_gz = None
+ for dsc_file in self.dsc_files.keys():
+ if dsc_file.endswith(".orig.tar.gz"):
+ orig_tar_gz = dsc_file
+ self.orig_files[orig_tar_gz] = {}
+ if next_obj != None:
+ self.orig_files[orig_tar_gz]["id"] = next_obj
+ next_obj = p.load()
+ if next_obj != None and next_obj != "":
+ self.orig_files[orig_tar_gz]["location"] = next_obj
+ if len(self.orig_files[orig_tar_gz]) == 0:
+ del self.orig_files[orig_tar_gz]
dump_file.close()
return ret
+ def sanitised_orig_files(self):
+ ret = {}
+ for name, entry in self.orig_files.items():
+ ret[name] = {}
+ # Optional orig_files fields
+ for i in CHANGESFIELDS_ORIGFILES:
+ if entry.has_key(i):
+ ret[name][i] = entry[i]
+
+ return ret
+
def write_dot_dak(self, dest_dir):
"""
Dump ourself into a cPickle file.
p.dump(self.sanitised_dsc())
p.dump(self.sanitised_files())
p.dump(self.sanitised_dsc_files())
- p.dump(self.orig_tar_id)
- p.dump(self.orig_tar_location)
+ p.dump(self.sanitised_orig_files())
dump_file.close()
+ def unknown_files_fields(self, name):
+ return sorted(list( set(self.files[name].keys()) -
+ set(CHANGESFIELDS_FILES)))
+
+ def unknown_changes_fields(self):
+ return sorted(list( set(self.changes.keys()) -
+ set(CHANGESFIELDS_MANDATORY + CHANGESFIELDS_OPTIONAL)))
+
+ def unknown_dsc_fields(self):
+ return sorted(list( set(self.dsc.keys()) -
+ set(CHANGESFIELDS_DSC)))
+
+ def unknown_dsc_files_fields(self, name):
+ return sorted(list( set(self.dsc_files[name].keys()) -
+ set(CHANGESFIELDS_DSCFILES_MANDATORY + CHANGESFIELDS_DSCFILES_OPTIONAL)))
+
+ def str_files(self):
+ r = []
+ for name, entry in self.files.items():
+ r.append(" %s:" % (name))
+ for i in CHANGESFIELDS_FILES:
+ if entry.has_key(i):
+ r.append(" %s: %s" % (i.capitalize(), entry[i]))
+ xfields = self.unknown_files_fields(name)
+ if len(xfields) > 0:
+ r.append("files[%s] still has following unrecognised keys: %s" % (name, ", ".join(xfields)))
+
+ return r
+
+ def str_changes(self):
+ r = []
+ for i in CHANGESFIELDS_MANDATORY:
+ val = self.changes[i]
+ if isinstance(val, list):
+ val = " ".join(val)
+ elif isinstance(val, dict):
+ val = " ".join(val.keys())
+ r.append(' %s: %s' % (i.capitalize(), val))
+
+ for i in CHANGESFIELDS_OPTIONAL:
+ if self.changes.has_key(i):
+ r.append(' %s: %s' % (i.capitalize(), self.changes[i]))
+
+ xfields = self.unknown_changes_fields()
+ if len(xfields) > 0:
+ r.append("Warning: changes still has the following unrecognised fields: %s" % ", ".join(xfields))
+
+ return r
+
+ def str_dsc(self):
+ r = []
+ for i in CHANGESFIELDS_DSC:
+ if self.dsc.has_key(i):
+ r.append(' %s: %s' % (i.capitalize(), self.dsc[i]))
+
+ xfields = self.unknown_dsc_fields()
+ if len(xfields) > 0:
+ r.append("Warning: dsc still has the following unrecognised fields: %s" % ", ".join(xfields))
+
+ return r
+
+ def str_dsc_files(self):
+ r = []
+ for name, entry in self.dsc_files.items():
+ r.append(" %s:" % (name))
+ for i in CHANGESFIELDS_DSCFILES_MANDATORY:
+ r.append(" %s: %s" % (i.capitalize(), entry[i]))
+ for i in CHANGESFIELDS_DSCFILES_OPTIONAL:
+ if entry.has_key(i):
+ r.append(" %s: %s" % (i.capitalize(), entry[i]))
+ xfields = self.unknown_dsc_files_fields(name)
+ if len(xfields) > 0:
+ r.append("dsc_files[%s] still has following unrecognised keys: %s" % (name, ", ".join(xfields)))
+
+ return r
+
+ def __str__(self):
+ r = []
+
+ r.append(" Changes:")
+ r += self.str_changes()
+
+ r.append("")
+
+ r.append(" Dsc:")
+ r += self.str_dsc()
+
+ r.append("")
+
+ r.append(" Files:")
+ r += self.str_files()
+
+ r.append("")
+
+ r.append(" Dsc Files:")
+ r += self.str_dsc_files()
+
+ return "\n".join(r)
+
__all__.append('Changes')