This is so that we have an idea of where we need what.
Lots of these should be changed to be opaque functions,
not exposing that they're internally regexes at all.
Signed-off-by: Mark Hymers <mhy@debian.org>
import apt_pkg, apt_inst
from daklib import database
from daklib import utils
+from daklib.regexes import re_issource
################################################################################
dsc_files = utils.build_file_list(dsc, is_a_dsc=1)
has_tar = 0
for f in dsc_files.keys():
- m = utils.re_issource.match(f)
+ m = re_issource.match(f)
if not m:
utils.fubar("%s not recognised as source." % (f))
ftype = m.group(3)
import apt_pkg, apt_inst
from daklib import database
from daklib import utils
+from daklib.regexes import re_no_epoch
################################################################################
unsat = 0
break
# As part of the same .changes?
- epochless_version = utils.re_no_epoch.sub('', version)
+ epochless_version = re_no_epoch.sub('', version)
dep_filename = "%s_%s_%s.deb" % (dep, epochless_version, arch)
if files.has_key(dep_filename):
if Options["debug"]:
import apt_pkg
from daklib import database
from daklib import utils
-from daklib.regexes import re_isdeb
+from daklib.regexes import re_isdeb, re_isadeb, re_issource, re_no_epoch
################################################################################
return
num_files = len(files.keys())
for f in files.keys():
- if utils.re_isadeb.match(f):
+ if re_isadeb.match(f):
m = re_isdeb.match(f)
pkg = m.group(1)
version = m.group(2)
if Options["debug"]:
print "BINARY: %s ==> %s_%s_%s" % (f, pkg, version, arch)
else:
- m = utils.re_issource.match(f)
+ m = re_issource.match(f)
if m:
pkg = m.group(1)
version = m.group(2)
# FIXME
utils.warn("%s doesn't seem to exist for %s in %s?? (from %s [%s])" % (pkg, arch, Options["suite"], f, filename))
continue
- pu_version = utils.re_no_epoch.sub('', pu[pkg][arch])
+ pu_version = re_no_epoch.sub('', pu[pkg][arch])
if pu_version == version:
if Options["verbose"]:
print "%s: ok" % (f)
from daklib import utils
from daklib import database
from daklib import logging
+from daklib.regexes import re_comments
################################################################################
start_time = time.time()
projectB.query("BEGIN WORK")
for line in file.readlines():
- line = utils.re_comments.sub('', line).strip()
+ line = re_comments.sub('', line).strip()
if line == "":
continue
import apt_pkg
from daklib import database
from daklib import utils
+from daklib.regexes import re_extract_src_version
################################################################################
bin2source[package]["version"] = version
bin2source[package]["source"] = source
if source.find("(") != -1:
- m = utils.re_extract_src_version.match(source)
+ m = re_extract_src_version.match(source)
source = m.group(1)
version = m.group(2)
if not bin_pkgs.has_key(package):
import apt_pkg, apt_inst
from daklib import database
from daklib import utils
-from daklib.regexes import *
+from daklib.regexes import html_escaping, re_html_escaping, re_version, re_spacestrip, \
+ re_contrib, re_nonfree, re_localhost, re_newlinespace, \
+ re_package, re_doc_directory
################################################################################
def escape_if_needed(s):
if use_html:
- return utils.re_html_escaping.sub(lambda x: utils.html_escaping.get(x.group(0)), s)
+ return re_html_escaping.sub(lambda x: html_escaping.get(x.group(0)), s)
else:
return s
from daklib import database
from daklib import utils
from daklib.dak_exceptions import *
-from daklib.regexes import re_arch_from_filename
+from daklib.regexes import re_arch_from_filename, re_taint_free, re_no_epoch, \
+ re_extract_src_version
###############################################################################
###############################################################################
def check_signature (filename):
- if not utils.re_taint_free.match(os.path.basename(filename)):
+ if not re_taint_free.match(os.path.basename(filename)):
reject("!!WARNING!! tainted filename: '%s'." % (filename))
return None
package = Scanner.Section["package"]
version = Scanner.Section["version"]
directory = Scanner.Section["directory"]
- dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, utils.re_no_epoch.sub('', version)))
+ dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, re_no_epoch.sub('', version)))
# Sometimes the Directory path is a lie; check in the pool
if not os.path.exists(dsc_file):
if directory.split('/')[0] == "dists":
directory = Cnf["Dir::PoolRoot"] + utils.poolify(package, component)
- dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, utils.re_no_epoch.sub('', version)))
+ dsc_file = os.path.join(Cnf["Dir::Root"], directory, "%s_%s.dsc" % (package, re_no_epoch.sub('', version)))
if not os.path.exists(dsc_file):
utils.fubar("%s not found." % (dsc_file))
install_date = time.strftime("%Y-%m-%d", time.localtime(os.path.getmtime(dsc_file)))
directory = poolify (directory, location)
if directory != "" and not directory.endswith("/"):
directory += '/'
- no_epoch_version = utils.re_no_epoch.sub('', version)
+ no_epoch_version = re_no_epoch.sub('', version)
# Add all files referenced by the .dsc to the files table
ids = []
for line in Scanner.Section["files"].split('\n'):
source = Scanner.Section["source"]
source_version = ""
if source.find("(") != -1:
- m = utils.re_extract_src_version.match(source)
+ m = re_extract_src_version.match(source)
source = m.group(1)
source_version = m.group(2)
if not source_version:
import apt_pkg
from daklib import database
from daklib import utils
+from daklib.regexes import re_comments
################################################################################
for filename in extra_files:
file = utils.open_file(filename)
for line in file.readlines():
- line = utils.re_comments.sub('', line).strip()
+ line = re_comments.sub('', line).strip()
if line == "":
continue
split = line.split()
import apt_pkg, apt_inst
import daklib.database
import daklib.utils
-from daklib.regexes import re_isadeb
+from daklib.regexes import re_isadeb, re_extract_src_version, re_no_epoch, re_issource
################################################################################
package = control.Find("Package", "")
source = control.Find("Source", package)
if source.find("(") != -1:
- m = daklib.utils.re_extract_src_version.match(source)
+ m = re_extract_src_version.match(source)
source = m.group(1)
# If it's a binary, we need to also rename the file to include the architecture
version = control.Find("Version", "")
architecture = control.Find("Architecture", "")
if package == "" or version == "" or architecture == "":
daklib.utils.fubar("%s: couldn't determine required information to rename .deb file." % (legacy_filename))
- version = daklib.utils.re_no_epoch.sub('', version)
+ version = re_no_epoch.sub('', version)
destination_filename = "%s_%s_%s.deb" % (package, version, architecture)
else:
- m = daklib.utils.re_issource.match(base_filename)
+ m = re_issource.match(base_filename)
if m:
source = m.group(1)
else:
from daklib import queue
from daklib import utils
from daklib.dak_exceptions import *
+from daklib.regexes import re_default_answer, re_issource, re_fdnic
###############################################################################
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.match(prompt)
+ m = re_default_answer.match(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
for file in files.keys():
if files[file]["type"] == "deb":
new_changelog.write("stable/%s/binary-%s/%s\n" % (files[file]["component"], files[file]["architecture"], file))
- elif utils.re_issource.match(file):
+ elif re_issource.match(file):
new_changelog.write("stable/%s/source/%s\n" % (files[file]["component"], file))
else:
new_changelog.write("%s\n" % (file))
- chop_changes = queue.re_fdnic.sub("\n", changes["changes"])
+ chop_changes = re_fdnic.sub("\n", changes["changes"])
new_changelog.write(chop_changes + '\n\n')
if os.access(changelog_filename, os.R_OK) != 0:
changelog = utils.open_file(changelog_filename)
from daklib import logging
from daklib import queue
from daklib import utils
+from daklib.regexes import re_no_epoch, re_default_answer, re_isanum
# Globals
Cnf = None
source_package = files[f]["source package"]
if not Upload.pkg.changes["architecture"].has_key("source") \
and not Upload.source_exists(source_package, source_version, Upload.pkg.changes["distribution"].keys()):
- source_epochless_version = utils.re_no_epoch.sub('', source_version)
+ source_epochless_version = re_no_epoch.sub('', source_version)
dsc_filename = "%s_%s.dsc" % (source_package, source_epochless_version)
found = 0
for q in ["Accepted", "Embargoed", "Unembargoed"]:
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.match(prompt)
+ m = re_default_answer.match(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.match(prompt)
+ m = re_default_answer.match(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
answer = answer[:1].upper()
if answer == "E" or answer == "D":
got_answer = 1
- elif queue.re_isanum.match (answer):
+ elif re_isanum.match (answer):
answer = int(answer)
if (answer < 1) or (answer > index):
print "%s is not a valid index (%s). Please retry." % (answer, index_range(index))
answer = "XXX"
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.search(prompt)
+ m = re_default_answer.search(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
answer = "XXX"
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.search(prompt)
+ m = re_default_answer.search(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.search(prompt)
+ m = re_default_answer.search(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.search(prompt)
+ m = re_default_answer.search(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
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
+ re_strip_revision, re_strip_srcver, re_spacestrip, \
+ re_isanum, re_noepoch, re_norevision, re_taint_free, \
+ re_isadeb, re_extract_src_version, re_issource
from types import *
# Ensure all the values in Closes: are numbers
if changes.has_key("closes"):
for i in changes["closes"].keys():
- if queue.re_isanum.match (i) == None:
+ if re_isanum.match (i) == None:
reject("%s: `%s' from Closes field isn't a number." % (filename, i))
# chopversion = no epoch; chopversion2 = no epoch and no revision (e.g. for .orig.tar.gz comparison)
- changes["chopversion"] = utils.re_no_epoch.sub('', changes["version"])
- changes["chopversion2"] = utils.re_no_revision.sub('', changes["chopversion"])
+ changes["chopversion"] = re_no_epoch.sub('', changes["version"])
+ changes["chopversion2"] = re_no_revision.sub('', changes["chopversion"])
# Check there isn't already a changes file of the same name in one
# of the queue directories.
if not Cnf.has_key("Dir::Queue::%s" % (d)): continue
if os.path.exists(Cnf["Dir::Queue::%s" % (d) ] + '/' + f):
reject("%s file already exists in the %s directory." % (f, d))
- if not utils.re_taint_free.match(f):
+ if not re_taint_free.match(f):
reject("!!WARNING!! tainted filename: '%s'." % (f))
# Check the file is readable
if os.access(f, os.R_OK) == 0:
files[f]["byhand"] = 1
files[f]["type"] = "byhand"
# Checks for a binary package...
- elif utils.re_isadeb.match(f):
+ elif re_isadeb.match(f):
has_binaries = 1
files[f]["type"] = "deb"
source = files[f]["source"]
source_version = ""
if source.find("(") != -1:
- m = utils.re_extract_src_version.match(source)
+ m = re_extract_src_version.match(source)
source = m.group(1)
source_version = m.group(2)
if not source_version:
files[f]["source version"] = source_version
# Ensure the filename matches the contents of the .deb
- m = utils.re_isadeb.match(f)
+ m = re_isadeb.match(f)
# package name
file_package = m.group(1)
if files[f]["package"] != file_package:
reject("%s: package part of filename (%s) does not match package name in the %s (%s)." % (f, file_package, files[f]["dbtype"], files[f]["package"]))
- epochless_version = utils.re_no_epoch.sub('', control.Find("Version"))
+ epochless_version = re_no_epoch.sub('', control.Find("Version"))
# version
file_version = m.group(2)
if epochless_version != file_version:
# Check in the SQL database
if not Upload.source_exists(source_package, source_version, changes["distribution"].keys()):
# Check in one of the other directories
- source_epochless_version = utils.re_no_epoch.sub('', source_version)
+ source_epochless_version = re_no_epoch.sub('', source_version)
dsc_filename = "%s_%s.dsc" % (source_package, source_epochless_version)
if os.path.exists(Cnf["Dir::Queue::Byhand"] + '/' + dsc_filename):
files[f]["byhand"] = 1
# Checks for a source package...
else:
- m = utils.re_issource.match(f)
+ m = re_issource.match(f)
if m:
has_source = 1
files[f]["package"] = m.group(1)
pass
# Ensure the version number in the .dsc matches the version number in the .changes
- epochless_dsc_version = utils.re_no_epoch.sub('', dsc["version"])
+ epochless_dsc_version = re_no_epoch.sub('', dsc["version"])
changes_version = files[dsc_filename]["version"]
if epochless_dsc_version != files[dsc_filename]["version"]:
reject("version ('%s') in .dsc does not match version ('%s') in .changes." % (epochless_dsc_version, changes_version))
# Ensure there is a .tar.gz in the .dsc file
has_tar = 0
for f in dsc_files.keys():
- m = utils.re_issource.match(f)
+ m = re_issource.match(f)
if not m:
reject("%s: %s in Files field not recognised as source." % (dsc_filename, f))
continue
# Create a symlink mirror of the source files in our temporary directory
for f in files.keys():
- m = utils.re_issource.match(f)
+ m = re_issource.match(f)
if m:
src = os.path.join(source_dir, f)
# If a file is missing for whatever reason, give up.
return
# Get the upstream version
- upstr_version = utils.re_no_epoch.sub('', dsc["version"])
+ upstr_version = re_no_epoch.sub('', dsc["version"])
if re_strip_revision.search(upstr_version):
upstr_version = re_strip_revision.sub('', upstr_version)
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.match(prompt)
+ m = re_default_answer.match(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
from daklib import logging
from daklib import queue
from daklib import utils
+from daklib.regexes import re_default_answer
################################################################################
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.search(prompt)
+ m = re_default_answer.search(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
answer = "XXX"
while prompt.find(answer) == -1:
answer = utils.our_raw_input(prompt)
- m = queue.re_default_answer.search(prompt)
+ m = re_default_answer.search(prompt)
if answer == "":
answer = m.group(1)
answer = answer[:1].upper()
from daklib import database
from daklib import queue
from daklib import utils
-from daklib.regexes import re_htmlescaping, html_escaping
+from daklib.regexes import re_html_escaping, html_escaping
################################################################################
### work around bug #487902 in debian-python 0.1.10
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 regexes import re_default_answer, re_fdnic, re_bin_only_nmu
from types import *
import database
import time
from dak_exceptions import *
-from regexes 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
################################################################################