Commit 2c639c40 authored by Mark Hymers's avatar Mark Hymers

Move regexes into a module so we can keep track

Rather than scatter regexes all over the place (for things
which should probably be functions hiding the implementation
detail anyways such as "is this a valid package version"),
move them into daklib.regexes.

I'm not convinced this is an immediate win, but I think it's
one step on a long road...

Oh, and it's untested
Signed-off-by: Mark Hymers's avatarMark Hymers <mhy@debian.org>
parent 29201530
......@@ -19,10 +19,11 @@
################################################################################
import os, pg, re, sys
import os, pg, sys
import apt_pkg
from daklib import database
from daklib import utils
from daklib.regexes import re_isdeb
################################################################################
......@@ -31,8 +32,6 @@ projectB = None
Options = None
pu = {}
re_isdeb = re.compile (r"^(.+)_(.+?)_(.+?).u?deb$")
################################################################################
def usage (exit_code=0):
......
......@@ -36,24 +36,7 @@ import errno, os, pg, re, sys, md5
import apt_pkg, apt_inst
from daklib import database
from daklib import utils
################################################################################
re_package = re.compile(r"^(.+?)_.*")
re_doc_directory = re.compile(r".*/doc/([^/]*).*")
re_contrib = re.compile('^contrib/')
re_nonfree = re.compile('^non\-free/')
re_arch = re.compile("Architecture: .*")
re_builddep = re.compile("Build-Depends: .*")
re_builddepind = re.compile("Build-Depends-Indep: .*")
re_localhost = re.compile("localhost\.localdomain")
re_version = re.compile('^(.*)\((.*)\)')
re_newlinespace = re.compile('\n')
re_spacestrip = re.compile('(\s)')
from daklib.regexes import *
################################################################################
......
......@@ -36,15 +36,12 @@
###############################################################################
import commands, os, pg, re, sys, time
import commands, os, pg, sys, time
import apt_pkg
from daklib import database
from daklib import utils
from daklib.dak_exceptions import *
###############################################################################
re_arch_from_filename = re.compile(r"binary-[^/]+")
from daklib.regexes import re_arch_from_filename
###############################################################################
......
......@@ -48,15 +48,13 @@ import commands, ldap, pg, re, sys
import apt_pkg
from daklib import database
from daklib import utils
from daklib.regexes import re_gpg_fingerprint, re_debian_address
################################################################################
Cnf = None
projectB = None
re_gpg_fingerprint = re.compile(r"^\s+Key fingerprint = (.*)$", re.MULTILINE)
re_debian_address = re.compile(r"^.*<(.*)@debian\.org>$", re.MULTILINE)
################################################################################
def usage(exit_code=0):
......
......@@ -20,13 +20,13 @@
################################################################################
import apt_pkg, os, sys, pwd, time, commands
from daklib import queue
from daklib import logging
from daklib import utils
from daklib import database
import apt_pkg, os, sys, pwd, time, re, commands
re_taint_free = re.compile(r"^['/;\-\+\.~\s\w]+$");
from daklib.regexes import re_taint_free
Cnf = None
Options = None
......
......@@ -29,14 +29,13 @@ import os, pg, re, stat, sys
import apt_pkg, apt_inst
import daklib.database
import daklib.utils
from daklib.regexes import re_isadeb
################################################################################
Cnf = None
projectB = None
re_isadeb = re.compile (r"(.+?)_(.+?)(_(.+))?\.u?deb$")
################################################################################
def usage (exit_code=0):
......
......@@ -35,17 +35,13 @@ from daklib import logging
from daklib import queue
from daklib import utils
from daklib.dak_exceptions import *
from daklib.regexes import re_valid_version, re_valid_pkg_name, re_changelog_versions, \
re_strip_revision, re_strip_srcver, re_spacestrip
from types import *
################################################################################
re_valid_version = re.compile(r"^([0-9]+:)?[0-9A-Za-z\.\-\+:~]+$")
re_valid_pkg_name = re.compile(r"^[\dA-Za-z][\dA-Za-z\+\-\.]+$")
re_changelog_versions = re.compile(r"^\w[-+0-9a-z.]+ \([^\(\) \t]+\)")
re_strip_revision = re.compile(r"-([^-]+)$")
re_strip_srcver = re.compile(r"\s+\(\S+\)$")
re_spacestrip = re.compile('(\s)')
################################################################################
......
......@@ -44,11 +44,7 @@ import apt_pkg, apt_inst
from daklib import database
from daklib import utils
from daklib.dak_exceptions import *
################################################################################
re_strip_source_version = re.compile (r'\s+.*$')
re_build_dep_arch = re.compile(r"\[[^]]+\]")
from daklib.regexes import re_strip_source_version, re_build_dep_arch
################################################################################
......
......@@ -27,6 +27,7 @@ from debian_bundle import deb822
from daklib import database
from daklib import queue
from daklib import utils
from daklib.regexes import re_htmlescaping, html_escaping
################################################################################
### work around bug #487902 in debian-python 0.1.10
......@@ -40,8 +41,6 @@ deb822.Changes._multivalued_fields = {
row_number = 1
html_escaping = {'"':'&quot;', '&':'&amp;', '<':'&lt;', '>':'&gt;'}
re_html_escaping = re.compile('|'.join(map(re.escape, html_escaping.keys())))
def html_escape(s):
return re_html_escaping.sub(lambda x: html_escaping.get(x.group(0)), s)
......
......@@ -23,11 +23,12 @@
################################################################################
import os, pg, sys, time, errno, fcntl, tempfile, pwd, re
import os, pg, sys, time, errno, fcntl, tempfile, pwd
import apt_pkg
from daklib import database
from daklib import utils
from daklib.dak_exceptions import TransitionsError
from daklib.regexes import re_broken_package
import yaml
# Globals
......@@ -35,8 +36,6 @@ Cnf = None
Options = None
projectB = None
re_broken_package = re.compile(r"[a-zA-Z]\w+\s+\-.*")
################################################################################
#####################################
......
......@@ -24,18 +24,12 @@ import cPickle, errno, os, pg, re, stat, sys, time
import apt_inst, apt_pkg
import utils, database
from dak_exceptions import *
from regexes import re_isanum, re_default_answer, re_fdnic, re_bin_only_nmu
from types import *
###############################################################################
re_isanum = re.compile (r"^\d+$")
re_default_answer = re.compile(r"\[(.*)\]")
re_fdnic = re.compile(r"\n\n")
re_bin_only_nmu = re.compile(r"\+b\d+$")
################################################################################
# Determine what parts in a .changes are NEW
def determine_new(changes, files, projectB, warn=1):
......
#!/usr/bin/env python
# vim:set et sw=4:
# Queue utility functions for dak
# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 James Troup <james@nocrew.org>
# Copyright (C) 2009 Mark Hymers <mhy@debian.org>
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
###############################################################################
import re
re_isanum = re.compile (r"^\d+$")
re_default_answer = re.compile(r"\[(.*)\]")
re_fdnic = re.compile(r"\n\n")
re_bin_only_nmu = re.compile(r"\+b\d+$")
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 = {'"':'&quot;', '&':'&amp;', '<':'&lt;', '>':'&gt;'}
re_html_escaping = re.compile('|'.join(map(re.escape, html_escaping.keys())))
# From clean_proposed_updates.py
re_isdeb = re.compile (r"^(.+)_(.+?)_(.+?).u?deb$")
# From examine_package.py
re_package = re.compile(r"^(.+?)_.*")
re_doc_directory = re.compile(r".*/doc/([^/]*).*")
re_contrib = re.compile('^contrib/')
re_nonfree = re.compile('^non\-free/')
re_arch = re.compile("Architecture: .*")
re_builddep = re.compile("Build-Depends: .*")
re_builddepind = re.compile("Build-Depends-Indep: .*")
re_localhost = re.compile("localhost\.localdomain")
re_version = re.compile('^(.*)\((.*)\)')
re_newlinespace = re.compile('\n')
re_spacestrip = re.compile('(\s)')
# From import_archive.py
re_arch_from_filename = re.compile(r"binary-[^/]+")
# From import_ldap_fingerprints.py
re_gpg_fingerprint = re.compile(r"^\s+Key fingerprint = (.*)$", re.MULTILINE)
re_debian_address = re.compile(r"^.*<(.*)@debian\.org>$", re.MULTILINE)
# From new_security_install.py
re_taint_free = re.compile(r"^['/;\-\+\.~\s\w]+$")
# From process_unchecked.py
re_valid_version = re.compile(r"^([0-9]+:)?[0-9A-Za-z\.\-\+:~]+$")
re_valid_pkg_name = re.compile(r"^[\dA-Za-z][\dA-Za-z\+\-\.]+$")
re_changelog_versions = re.compile(r"^\w[-+0-9a-z.]+ \([^\(\) \t]+\)")
re_strip_revision = re.compile(r"-([^-]+)$")
re_strip_srcver = re.compile(r"\s+\(\S+\)$")
re_spacestrip = re.compile('(\s)')
# From dak/rm.py
re_strip_source_version = re.compile (r'\s+.*$')
re_build_dep_arch = re.compile(r"\[[^]]+\]")
# From dak/transitions.py
re_broken_package = re.compile(r"[a-zA-Z]\w+\s+\-.*")
......@@ -28,32 +28,10 @@ import apt_pkg
import database
import time
from dak_exceptions import *
from regexes import *
################################################################################
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 = {'"':'&quot;', '&':'&amp;', '<':'&lt;', '>':'&gt;'}
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"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment