mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-13 23:16:18 +00:00
Refactoring step.
This commit is contained in:
parent
6ad8ea6916
commit
c210423fdf
@ -85,6 +85,15 @@ class CrossRef:
|
|||||||
if trial in self.fileref:
|
if trial in self.fileref:
|
||||||
return trial
|
return trial
|
||||||
return None
|
return None
|
||||||
|
def mark_matching_resources(self, pattern, fn, n):
|
||||||
|
"Mark all definitions matching a specified pattern with a reference."
|
||||||
|
pattern = re.compile(pattern + "$")
|
||||||
|
key = None
|
||||||
|
for trial in self.fileref:
|
||||||
|
if pattern.match(trial):
|
||||||
|
key = trial
|
||||||
|
self.fileref[key].append(fn, n)
|
||||||
|
return key
|
||||||
def __init__(self, filelist):
|
def __init__(self, filelist):
|
||||||
# First, collect macro definitions from the specified filelist."
|
# First, collect macro definitions from the specified filelist."
|
||||||
self.xref = {}
|
self.xref = {}
|
||||||
@ -157,13 +166,10 @@ class CrossRef:
|
|||||||
# it as a reference to everything the substitutions
|
# it as a reference to everything the substitutions
|
||||||
# could potentially match.
|
# could potentially match.
|
||||||
elif '{' in name:
|
elif '{' in name:
|
||||||
pattern = re.sub(r"\{[^}]*\}", '.*', name)
|
pattern = "^" + re.sub(r"\{[^}]*\}", '.*', name)
|
||||||
pattern = re.compile("^" + pattern + "$")
|
key = self.mark_matching_resources(pattern, fn,n+1)
|
||||||
key = None
|
if key:
|
||||||
for trial in self.fileref:
|
self.fileref[key].append(fn, n+1)
|
||||||
if pattern.match(trial):
|
|
||||||
key = trial
|
|
||||||
self.fileref[key].append(fn, n+1)
|
|
||||||
else:
|
else:
|
||||||
key = self.imagesearch(name)
|
key = self.imagesearch(name)
|
||||||
if key:
|
if key:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user