Skip to content

Commit 7a1d333

Browse files
committed
Freeze graphics path results
... to align with all other attributes.
1 parent ec5080f commit 7a1d333

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

latextools/utils/analysis.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ def __init__(self, tex_root):
142142
self._command_cache = {}
143143

144144
self._import_base_paths = {}
145+
self._graphics_path = None
145146

146147
self.__frozen = False
147148

@@ -248,19 +249,18 @@ def filter_commands(self, how, flags=DEFAULT_FLAGS):
248249
raise Exception(f"Unsupported filter type: {type(how)}")
249250

250251
def graphics_paths(self):
251-
try:
252-
return self._graphics_path
253-
except AttributeError:
254-
pass
255-
self._graphics_path = []
256-
commands = self.filter_commands("graphicspath")
257-
for com in commands:
258-
base_path = os.path.join(self.tex_base_path(com.file_name))
259-
paths = (p.rstrip("}") for p in com.args.split("{") if p)
260-
self._graphics_path.extend(
261-
os.path.normpath(p if os.path.isabs(p) else os.path.join(base_path, p))
262-
for p in paths
263-
)
252+
if self._graphics_path is None:
253+
result = []
254+
commands = self.filter_commands("graphicspath")
255+
for com in commands:
256+
base_path = os.path.join(self.tex_base_path(com.file_name))
257+
paths = (p.rstrip("}") for p in com.args.split("{") if p)
258+
result.extend(
259+
os.path.normpath(p if os.path.isabs(p) else os.path.join(base_path, p))
260+
for p in paths
261+
)
262+
# freeze result
263+
self._graphics_path = tuple(result)
264264

265265
return self._graphics_path
266266

0 commit comments

Comments
 (0)