import errno, os, pg, re, sys, md5
import apt_pkg, apt_inst
-import daklib.database, daklib.utils, daklib.queue
+from daklib import database
+from daklib import utils
################################################################################
re_newlinespace = re.compile('\n')
re_spacestrip = re.compile('(\s)')
-html_escaping = {'"':'"', '&':'&', '<':'<', '>':'>'}
-re_html_escaping = re.compile('|'.join(map(re.escape, html_escaping.keys())))
-
################################################################################
Cnf = None
projectB = None
-Cnf = daklib.utils.get_conf()
+Cnf = utils.get_conf()
projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
-daklib.database.init(Cnf, projectB)
+database.init(Cnf, projectB)
printed_copyrights = {}
################################################################################
# probably xml.sax.saxutils would work as well
-def html_escape(s):
- return re_html_escaping.sub(lambda x: html_escaping.get(x.group(0)), s)
-
def escape_if_needed(s):
if use_html:
- return re_html_escaping.sub(lambda x: html_escaping.get(x.group(0)), s)
+ return utils.re_html_escaping.sub(lambda x: utils.html_escaping.get(x.group(0)), s)
else:
return s
if bodyelement:
print """<thead>
<tr><th colspan="2" class="title" onclick="toggle('%(bodyelement)s', 'table-row-group', 'table-row-group')">%(title)s <span class="toggle-msg">(click to toggle)</span></th></tr>
- </thead>"""%{"bodyelement":bodyelement,"title":html_escape(s)}
+ </thead>"""%{"bodyelement":bodyelement,"title":utils.html_escape(s)}
else:
- print "<h%d>%s</h%d>" % (level, html_escape(s), level)
+ print "<h%d>%s</h%d>" % (level, utils.html_escape(s), level)
else:
print "---- %s ----" % (s)
def colour_output(s, colour):
if use_html:
- return ("%s%s%s" % (html_colours[colour][0], html_escape(s), html_colours[colour][1]))
+ return ("%s%s%s" % (html_colours[colour][0], utils.html_escape(s), html_colours[colour][1]))
else:
return ("%s%s%s" % (ansi_colours[colour], s, ansi_colours['end']))
if use_html:
if strip:
s = s.strip()
- return "<pre>%s</pre>" % (html_escape(s))
+ return "<pre>%s</pre>" % (utils.html_escape(s))
else:
return s
maintainer = ''
arch = ''
- deb_file = daklib.utils.open_file(filename)
+ deb_file = utils.open_file(filename)
try:
extracts = apt_inst.debExtractControl(deb_file)
control = apt_pkg.ParseSection(extracts)
def read_changes_or_dsc (filename):
dsc = {}
- dsc_file = daklib.utils.open_file(filename)
+ dsc_file = utils.open_file(filename)
try:
- dsc = daklib.utils.parse_changes(filename)
+ dsc = utils.parse_changes(filename)
except:
return formatted_text("can't parse .dsc control info")
dsc_file.close()
# Read a file, strip the signature and return the modified contents as
# a string.
def strip_pgp_signature (filename):
- file = daklib.utils.open_file (filename)
+ file = utils.open_file (filename)
contents = ""
inside_signature = 0
skip_next = 0
def check_changes (changes_filename):
display_changes(changes_filename)
- changes = daklib.utils.parse_changes (changes_filename)
- files = daklib.utils.build_file_list(changes)
+ changes = utils.parse_changes (changes_filename)
+ files = utils.build_file_list(changes)
for f in files.keys():
if f.endswith(".deb") or f.endswith(".udeb"):
check_deb(f)
def main ():
global Cnf, projectB, db_files, waste, excluded
-# Cnf = daklib.utils.get_conf()
+# Cnf = utils.get_conf()
Arguments = [('h',"help","Examine-Package::Options::Help"),
('H',"html-output","Examine-Package::Options::Html-Output"),
elif f.endswith(".dsc"):
check_dsc(f)
else:
- daklib.utils.fubar("Unrecognised file type: '%s'." % (f))
+ utils.fubar("Unrecognised file type: '%s'." % (f))
finally:
if not Options["Html-Output"]:
# Reset stdout here so future less invocations aren't FUBAR
sys.stdout = stdout_fd
except IOError, e:
if errno.errorcode[e.errno] == 'EPIPE':
- daklib.utils.warn("[examine-package] Caught EPIPE; skipping.")
+ utils.warn("[examine-package] Caught EPIPE; skipping.")
pass
else:
raise
except KeyboardInterrupt:
- daklib.utils.warn("[examine-package] Caught C-c; skipping.")
+ utils.warn("[examine-package] Caught C-c; skipping.")
pass
#######################################################################################