X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Futils.py;h=dbc8c16c0fce391c8b8f5fc9764f57223d15bd22;hb=66e52b75f85d576a84bf5b7127b79252378cbad9;hp=830794833f13cc870a3d36e3aa7a2d4974236b25;hpb=158e9baf0e519d1af426df73b693008abacb3c26;p=dak.git diff --git a/daklib/utils.py b/daklib/utils.py index 83079483..dbc8c16c 100755 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # vim:set et ts=4 sw=4: -# Utility functions +""" Utility functions """ # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 James Troup ################################################################################ @@ -28,32 +28,12 @@ import apt_pkg import database import time from dak_exceptions import * +from regexes import re_html_escaping, html_escaping, re_single_line_field, \ + re_multi_line_field, re_srchasver, re_verwithext, \ + re_parse_maintainer, re_taint_free, re_gpg_uid ################################################################################ -re_comments = re.compile(r"\#.*") -re_no_epoch = re.compile(r"^\d+\:") -re_no_revision = re.compile(r"-[^-]+$") -re_arch_from_filename = re.compile(r"/binary-[^/]+/") -re_extract_src_version = re.compile (r"(\S+)\s*\((.*)\)") -re_isadeb = re.compile (r"(.+?)_(.+?)_(.+)\.u?deb$") -re_issource = re.compile (r"(.+)_(.+?)\.(orig\.tar\.gz|diff\.gz|tar\.gz|dsc)$") - -re_single_line_field = re.compile(r"^(\S*)\s*:\s*(.*)") -re_multi_line_field = re.compile(r"^\s(.*)") -re_taint_free = re.compile(r"^[-+~/\.\w]+$") - -re_parse_maintainer = re.compile(r"^\s*(\S.*\S)\s*\<([^\>]+)\>") -re_gpg_uid = re.compile('^uid.*<([^>]*)>') - -re_srchasver = re.compile(r"^(\S+)\s+\((\S+)\)$") -re_verwithext = re.compile(r"^(\d+)(?:\.(\d+))(?:\s+\((\S+)\))?$") - -re_srchasver = re.compile(r"^(\S+)\s+\((\S+)\)$") - -html_escaping = {'"':'"', '&':'&', '<':'<', '>':'>'} -re_html_escaping = re.compile('|'.join(map(re.escape, html_escaping.keys()))) - default_config = "/etc/dak/dak.conf" default_apt_config = "/etc/dak/apt.conf" @@ -685,11 +665,11 @@ def regex_safe (s): # Perform a substition of template def TemplateSubst(map, filename): - file = open_file(filename) - template = file.read() + templatefile = open_file(filename) + template = templatefile.read() for x in map.keys(): template = template.replace(x,map[x]) - file.close() + templatefile.close() return template ################################################################################ @@ -785,13 +765,13 @@ def find_next_free (dest, too_many=100): ################################################################################ def result_join (original, sep = '\t'): - list = [] + resultlist = [] for i in xrange(len(original)): if original[i] == None: - list.append("") + resultlist.append("") else: - list.append(original[i]) - return sep.join(list) + resultlist.append(original[i]) + return sep.join(resultlist) ################################################################################ @@ -1118,7 +1098,7 @@ on error.""" return "%s: tainted filename" % (filename) # Invoke gpgv on the file - status_read, status_write = os.pipe(); + status_read, status_write = os.pipe() cmd = "gpgv --status-fd %s --keyring /dev/null %s" % (status_write, filename) (_, status, _) = gpgv_get_status_output(cmd, status_read, status_write) @@ -1190,7 +1170,7 @@ used.""" return None # Build the command line - status_read, status_write = os.pipe(); + status_read, status_write = os.pipe() cmd = "gpgv --status-fd %s %s %s %s" % ( status_write, gpg_keyring_args(keyrings), sig_filename, data_filename)