mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-04 14:30:11 +01:00
Pre-compile more regexes
This commit is contained in:
parent
7e28e0ed90
commit
71a5eac494
@ -380,7 +380,7 @@ def has_extension(filename, ext):
|
|||||||
return ext == f_ext
|
return ext == f_ext
|
||||||
|
|
||||||
|
|
||||||
apk_regex = None
|
apk_regex = re.compile(r"^(.+)_([0-9]+)\.apk$")
|
||||||
|
|
||||||
|
|
||||||
def clean_description(description):
|
def clean_description(description):
|
||||||
@ -397,10 +397,7 @@ def clean_description(description):
|
|||||||
|
|
||||||
|
|
||||||
def apknameinfo(filename):
|
def apknameinfo(filename):
|
||||||
global apk_regex
|
|
||||||
filename = os.path.basename(filename)
|
filename = os.path.basename(filename)
|
||||||
if apk_regex is None:
|
|
||||||
apk_regex = re.compile(r"^(.+)_([0-9]+)\.apk$")
|
|
||||||
m = apk_regex.match(filename)
|
m = apk_regex.match(filename)
|
||||||
try:
|
try:
|
||||||
result = (m.group(1), m.group(2))
|
result = (m.group(1), m.group(2))
|
||||||
|
@ -783,6 +783,9 @@ def sorted_builds(builds):
|
|||||||
return sorted(builds, key=lambda build: int(build.vercode))
|
return sorted(builds, key=lambda build: int(build.vercode))
|
||||||
|
|
||||||
|
|
||||||
|
esc_newlines = re.compile('\\\\( |\\n)')
|
||||||
|
|
||||||
|
|
||||||
def post_metadata_parse(app):
|
def post_metadata_parse(app):
|
||||||
|
|
||||||
for f in app_fields:
|
for f in app_fields:
|
||||||
@ -797,8 +800,6 @@ def post_metadata_parse(app):
|
|||||||
text = v.rstrip().lstrip()
|
text = v.rstrip().lstrip()
|
||||||
app.set_field(f, text.split('\n'))
|
app.set_field(f, text.split('\n'))
|
||||||
|
|
||||||
esc_newlines = re.compile('\\\\( |\\n)')
|
|
||||||
|
|
||||||
for build in app.builds:
|
for build in app.builds:
|
||||||
for k in build_flags:
|
for k in build_flags:
|
||||||
v = build.get_flag(k)
|
v = build.get_flag(k)
|
||||||
@ -970,6 +971,9 @@ def parse_yaml_metadata(metadatapath):
|
|||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
||||||
|
build_line_sep = re.compile(r"(?<!\\),")
|
||||||
|
|
||||||
|
|
||||||
def parse_txt_metadata(metadatapath):
|
def parse_txt_metadata(metadatapath):
|
||||||
|
|
||||||
linedesc = None
|
linedesc = None
|
||||||
@ -1008,8 +1012,7 @@ def parse_txt_metadata(metadatapath):
|
|||||||
|
|
||||||
def parse_buildline(lines):
|
def parse_buildline(lines):
|
||||||
v = "".join(lines)
|
v = "".join(lines)
|
||||||
parts = [p.replace("\\,", ",")
|
parts = [p.replace("\\,", ",") for p in re.split(build_line_sep, v)]
|
||||||
for p in re.split(r"(?<!\\),", v)]
|
|
||||||
if len(parts) < 3:
|
if len(parts) < 3:
|
||||||
raise MetaDataException("Invalid build format: " + v + " in " + metafile.name)
|
raise MetaDataException("Invalid build format: " + v + " in " + metafile.name)
|
||||||
build = Build()
|
build = Build()
|
||||||
|
Loading…
Reference in New Issue
Block a user