X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=utils.py;h=97598f98ea8aa93c0b547262d7441113662e69dd;hb=083a06be9f96e0e19bed7642352dbf14aa267044;hp=60efbb9b14832c4d734c80c3737e4e14aa62e7e6;hpb=20ef2ddf06d0c75fd3786fae338ccc3161868f7e;p=dak.git diff --git a/utils.py b/utils.py index 60efbb9b..97598f98 100644 --- a/utils.py +++ b/utils.py @@ -1,6 +1,6 @@ # Utility functions # Copyright (C) 2000, 2001 James Troup -# $Id: utils.py,v 1.33 2001-09-26 03:49:16 troup Exp $ +# $Id: utils.py,v 1.35 2001-11-04 22:33:22 troup Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ 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*\<([^\> \t]+)\>"); @@ -67,6 +68,10 @@ def open_file(filename, mode='r'): raise cant_open_exc, filename return f +def touch_file(filename): + fd = os.open(filename, os.O_RDONLY | os.O_CREAT); + os.close(fd); + ###################################################################################### # From reportbug @@ -136,12 +141,12 @@ def extract_component_from_section(section): # "-----BEGIN PGP SIGNATURE-----". def parse_changes(filename, dsc_whitespace_rules): - changes_in = open_file(filename,'r'); + changes_in = open_file(filename); error = ""; changes = {}; lines = changes_in.readlines(); - if lines == []: + if not lines: raise changes_parse_error_exc, "[Empty changes file]"; # Reindex by line number so we can easily verify the format of @@ -165,13 +170,13 @@ def parse_changes(filename, dsc_whitespace_rules): if index > max(indices): raise invalid_dsc_format_exc, index; line = indexed_lines[index]; - if line[:24] != "-----BEGIN PGP SIGNATURE": + if string.find(line, "-----BEGIN PGP SIGNATURE") != 0: raise invalid_dsc_format_exc, index; inside_signature = 0; break; - if line[:24] == "-----BEGIN PGP SIGNATURE": + if string.find(line, "-----BEGIN PGP SIGNATURE") == 0: break; - if line[:29] == "-----BEGIN PGP SIGNED MESSAGE": + if string.find(line, "-----BEGIN PGP SIGNED MESSAGE") == 0: if dsc_whitespace_rules: inside_signature = 1; while index < max(indices) and line != "": @@ -361,8 +366,9 @@ def copy (src, dest, overwrite = 0): def where_am_i (): res = socket.gethostbyaddr(socket.gethostname()); - if DefaultCnf.get("Config::" + res[0] + "::DatbaseHostname"): - return DefaultCnf["Config::" + res[0] + "::DatabaseHostname"] + database_hostname = DefaultCnf.get("Config::" + res[0] + "::DatabaseHostname"); + if database_hostname: + return database_hostname; else: return res[0];