From 71a5eac494c9d519905d019a0c8acb49572f6bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Wed, 2 Dec 2015 20:38:55 +0100 Subject: [PATCH] Pre-compile more regexes --- fdroidserver/common.py | 5 +---- fdroidserver/metadata.py | 11 +++++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 5e04f362..92e50177 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -380,7 +380,7 @@ def has_extension(filename, ext): return ext == f_ext -apk_regex = None +apk_regex = re.compile(r"^(.+)_([0-9]+)\.apk$") def clean_description(description): @@ -397,10 +397,7 @@ def clean_description(description): def apknameinfo(filename): - global apk_regex filename = os.path.basename(filename) - if apk_regex is None: - apk_regex = re.compile(r"^(.+)_([0-9]+)\.apk$") m = apk_regex.match(filename) try: result = (m.group(1), m.group(2)) diff --git a/fdroidserver/metadata.py b/fdroidserver/metadata.py index d1aab68a..fcd77a89 100644 --- a/fdroidserver/metadata.py +++ b/fdroidserver/metadata.py @@ -783,6 +783,9 @@ def sorted_builds(builds): return sorted(builds, key=lambda build: int(build.vercode)) +esc_newlines = re.compile('\\\\( |\\n)') + + def post_metadata_parse(app): for f in app_fields: @@ -797,8 +800,6 @@ def post_metadata_parse(app): text = v.rstrip().lstrip() app.set_field(f, text.split('\n')) - esc_newlines = re.compile('\\\\( |\\n)') - for build in app.builds: for k in build_flags: v = build.get_flag(k) @@ -970,6 +971,9 @@ def parse_yaml_metadata(metadatapath): return app +build_line_sep = re.compile(r"(?