mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-06 23:40:29 +03:00
Look for strings in all xml dirs properly
This commit is contained in:
parent
858f89e3ac
commit
a4ab105234
1 changed files with 14 additions and 12 deletions
|
|
@ -589,21 +589,25 @@ class vcs_bzr(vcs):
|
||||||
return [tag.split(' ')[0].strip() for tag in
|
return [tag.split(' ')[0].strip() for tag in
|
||||||
p.stdout.splitlines()]
|
p.stdout.splitlines()]
|
||||||
|
|
||||||
def retrieve_string(xml_dir, string):
|
def retrieve_string(app_dir, string, xmlfiles=None):
|
||||||
|
if xmlfiles is None:
|
||||||
|
xmlfiles = []
|
||||||
|
for r,d,f in os.walk(app_dir):
|
||||||
|
if r.endswith('/res/values'):
|
||||||
|
xmlfiles += [os.path.join(r,x) for x in f if x.endswith('.xml')]
|
||||||
|
|
||||||
|
string_search = None
|
||||||
if string.startswith('@string/'):
|
if string.startswith('@string/'):
|
||||||
string_search = re.compile(r'.*"'+string[8:]+'".*?>([^<]+?)<.*').search
|
string_search = re.compile(r'.*"'+string[8:]+'".*?>([^<]+?)<.*').search
|
||||||
for xmlfile in glob.glob(os.path.join(xml_dir, '*.xml')):
|
|
||||||
for line in file(xmlfile):
|
|
||||||
matches = string_search(line)
|
|
||||||
if matches:
|
|
||||||
return retrieve_string(xml_dir, matches.group(1))
|
|
||||||
elif string.startswith('&') and string.endswith(';'):
|
elif string.startswith('&') and string.endswith(';'):
|
||||||
string_search = re.compile(r'.*<!ENTITY.*'+string[1:-1]+'.*?"([^"]+?)".*>').search
|
string_search = re.compile(r'.*<!ENTITY.*'+string[1:-1]+'.*?"([^"]+?)".*>').search
|
||||||
for xmlfile in glob.glob(os.path.join(xml_dir, '*.xml')):
|
|
||||||
|
if string_search is not None:
|
||||||
|
for xmlfile in xmlfiles:
|
||||||
for line in file(xmlfile):
|
for line in file(xmlfile):
|
||||||
matches = string_search(line)
|
matches = string_search(line)
|
||||||
if matches:
|
if matches:
|
||||||
return retrieve_string(xml_dir, matches.group(1))
|
return retrieve_string(app_dir, matches.group(1), xmlfiles)
|
||||||
|
|
||||||
return string.replace("\\'","'")
|
return string.replace("\\'","'")
|
||||||
|
|
||||||
|
|
@ -628,7 +632,6 @@ def fetch_real_name(app_dir, flavour):
|
||||||
for f in manifest_paths(app_dir, flavour):
|
for f in manifest_paths(app_dir, flavour):
|
||||||
if not has_extension(f, 'xml'):
|
if not has_extension(f, 'xml'):
|
||||||
continue
|
continue
|
||||||
xml_dir = os.path.join(f[:-19], 'res', 'values')
|
|
||||||
for line in file(f):
|
for line in file(f):
|
||||||
if not app_found:
|
if not app_found:
|
||||||
if app_search(line):
|
if app_search(line):
|
||||||
|
|
@ -636,7 +639,7 @@ def fetch_real_name(app_dir, flavour):
|
||||||
if app_found:
|
if app_found:
|
||||||
matches = name_search(line)
|
matches = name_search(line)
|
||||||
if matches:
|
if matches:
|
||||||
return retrieve_string(xml_dir, matches.group(1)).strip()
|
return retrieve_string(app_dir, matches.group(1)).strip()
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
# Retrieve the version name
|
# Retrieve the version name
|
||||||
|
|
@ -644,8 +647,7 @@ def version_name(original, app_dir, flavour):
|
||||||
for f in manifest_paths(app_dir, flavour):
|
for f in manifest_paths(app_dir, flavour):
|
||||||
if not has_extension(f, 'xml'):
|
if not has_extension(f, 'xml'):
|
||||||
continue
|
continue
|
||||||
xml_dir = os.path.join(f[:-19], 'res', 'values')
|
string = retrieve_string(app_dir, original)
|
||||||
string = retrieve_string(xml_dir, original)
|
|
||||||
if string:
|
if string:
|
||||||
return string
|
return string
|
||||||
return original
|
return original
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue