From 7ea7b89464e4ea9dc2213fa8419069cada18dac0 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sun, 25 Aug 2019 00:36:26 +0200 Subject: don't permanently store substitutions this fixes that multiple calls to Allocator.build() lose their {{fmt}} formatting strings. --- src/allocator.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/allocator.py b/src/allocator.py index ae22620..e917f10 100644 --- a/src/allocator.py +++ b/src/allocator.py @@ -152,19 +152,21 @@ class Allocator (object): f.write(str(datetime.now().timestamp())) print_info2("Create allocator dictionary") + res_dict = {"cmd_prefix": self.cmd_prefix or "", + "binary_suffix": self.binary_suffix or "", + "LD_PRELOAD": self.LD_PRELOAD or "", + "LD_LIBRARY_PATH": self.LD_LIBRARY_PATH or "", + "color": self.color} + + paths = {"dir": self.dir} + paths["srcdir"] = self.sources.dir if self.sources is not None else "" + for attr in ["LD_PRELOAD", "LD_LIBRARY_PATH", "cmd_prefix"]: value = getattr(self, attr, "") or "" - paths = {"dir": self.dir} - paths["srcdir"] = self.sources.dir if self.sources is not None else "" + if value != "": + value = value.format(**paths) + res_dict[attr] = value - value = value.format(**paths) - setattr(self, attr, value) - - res_dict = {"cmd_prefix": self.cmd_prefix, - "binary_suffix": self.binary_suffix or "", - "LD_PRELOAD": self.LD_PRELOAD, - "LD_LIBRARY_PATH": self.LD_LIBRARY_PATH, - "color": self.color} print_debug("Resulting dictionary:", res_dict) return res_dict -- cgit v1.2.3