Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions tester/api_config/config_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3478,6 +3478,11 @@ def dump_item_str(self, item):
return '"' + item + '"'
elif isinstance(item, type):
return "type(" + str(item)[str(item).index("'") + 1 : str(item).rindex("'")] + ")"
elif callable(item):
name = getattr(item, "__name__", None) or getattr(item, "__qualname__", None)
if name:
return "callable(" + name + ")"
return "callable(unknown)"
else:
return str(item)

Expand Down Expand Up @@ -3674,6 +3679,12 @@ def get_one_arg(self, token, config, offset):
value, offset = self.get_complex(config, offset)
elif token == "type":
value, offset = self.get_numpy_type(config, offset)
elif token == "callable":
# parse callable(name) format - store as a string marker
start = config.index("(", offset - len(token)) + 1
end = config.index(")", start)
value = config[start:end] # store the callable name as string
offset = end + 1
elif token == "nan":
value = float("nan")
elif token is not None and config[offset - len(token) - 1] == '"':
Expand All @@ -3693,11 +3704,12 @@ def get_one_arg(self, token, config, offset):
def analyse_configs(config_path):
with open(config_path) as f:
configs = f.readlines()
f.close()

api_configs = []
for config in configs:
# print(config)
config = config.strip()
if not config or "(" not in config:
continue
api_config = APIConfig(config)
api_configs.append(api_config)
return api_configs
Loading