Update contextual help
This commit is contained in:
parent
7a4dcff667
commit
0d70518220
1 changed files with 11 additions and 4 deletions
|
@ -27,12 +27,13 @@ def find_arguments(directory):
|
||||||
content = file.read()
|
content = file.read()
|
||||||
|
|
||||||
# Search for the expression "params." excluding prefixes and read the attribute without trailing detritus
|
# Search for the expression "params." excluding prefixes and read the attribute without trailing detritus
|
||||||
matches = re.findall(r'(?:^|\s)params\.(.*?)(?=[\). <,;}]|\Z)', content)
|
# matches = re.findall(r'(?:^|\s)params\.(.*)(?=[\). <,;}]|\Z)', content)
|
||||||
|
matches = set(re.findall(r'(?:^|\b)params\.([a-zA-Z_0-9]*)(?=[\). <,;}]|\Z)', content))
|
||||||
# Remove duplicates from matches list
|
# Remove duplicates from matches list
|
||||||
arguments_list = list(set([match.strip() for match in matches]))
|
# arguments_list = list(set([match.strip() for match in matches]))
|
||||||
|
|
||||||
# Add the matches to the dictionary
|
# Add the matches to the dictionary
|
||||||
arguments[filepath] = arguments_list
|
arguments[filepath] = matches
|
||||||
|
|
||||||
return arguments
|
return arguments
|
||||||
|
|
||||||
|
@ -53,6 +54,12 @@ def find_parameters(file, sorted_result):
|
||||||
for filename, arguments in sorted_result.items():
|
for filename, arguments in sorted_result.items():
|
||||||
parameters = []
|
parameters = []
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
for argument in arguments:
|
||||||
|
# building pattern to avoid spurious matches
|
||||||
|
pattern = r"(?:--{}\s)|(?:params\.{}[\s.,();])".format(argument, argument.split('n_')[-1])
|
||||||
|
if re.search(pattern, line):
|
||||||
|
parameters.append(line)
|
||||||
|
'''for line in lines:
|
||||||
for argument in arguments:
|
for argument in arguments:
|
||||||
# need to try to avoid spurious matches
|
# need to try to avoid spurious matches
|
||||||
argument1 = "--" + argument + " "
|
argument1 = "--" + argument + " "
|
||||||
|
@ -64,7 +71,7 @@ def find_parameters(file, sorted_result):
|
||||||
parameters.append(line)
|
parameters.append(line)
|
||||||
argument3 = "params." + argument
|
argument3 = "params." + argument
|
||||||
if argument3 in line:
|
if argument3 in line:
|
||||||
parameters.append(line)
|
parameters.append(line)'''
|
||||||
all_parameters = set(parameters)
|
all_parameters = set(parameters)
|
||||||
print(f"\n\nFilename: \033[32m{filename.split('/')[-1]}\033[0m\n\n command-line arguments available and gpt-params functions implemented:\n")
|
print(f"\n\nFilename: \033[32m{filename.split('/')[-1]}\033[0m\n\n command-line arguments available and gpt-params functions implemented:\n")
|
||||||
if not all_parameters:
|
if not all_parameters:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue