+def get_type(f, session=None):
+ """
+ Get the file type of C{f}
+
+ @type f: dict
+ @param f: file entry from Changes object
+
+ @rtype: string
+ @return: filetype
+
+ """
+ if session is None:
+ session = DBConn().session()
+
+ # Determine the type
+ if f.has_key("dbtype"):
+ file_type = file["dbtype"]
+ elif f["type"] in [ "orig.tar.gz", "orig.tar.bz2", "tar.gz", "tar.bz2", "diff.gz", "diff.bz2", "dsc" ]:
+ file_type = "dsc"
+ else:
+ utils.fubar("invalid type (%s) for new. Dazed, confused and sure as heck not continuing." % (file_type))
+
+ # Validate the override type
+ type_id = get_override_type(file_type, session)
+ if type_id is None:
+ utils.fubar("invalid type (%s) for new. Say wha?" % (file_type))
+
+ return file_type
+
+################################################################################
+