Skip to content

Commit e93c691

Browse files
committed
making load of help messages significantly faster
1 parent 1e33c23 commit e93c691

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/server/data_n_json.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,20 +526,26 @@ def get_param_list(cmd_str):
526526

527527

528528
def get_help_list(cmd_str):
529-
530529
data_init = ini_data()
531530
win_exe = data_init.get_win_exe()
532-
533531
try:
532+
my_cmd_mod = importlib.import_module(
533+
"dials.command_line." + cmd_str
534+
)
535+
single_str = my_cmd_mod.__doc__
536+
my_cmd_hlp = single_str.split("\n")
537+
print(" getting docstring from >> dials." + cmd_str)
538+
539+
except AttributeError:
534540
my_cmd_mod = importlib.import_module(
535541
"dials.command_line." + cmd_str
536542
)
537543
single_str = my_cmd_mod.help_message
538544
my_cmd_hlp = single_str.split("\n")
539545
print("getting help message from >> dials." + cmd_str)
540546

541-
except (AttributeError, ModuleNotFoundError):
542-
my_cmd_hlp = ["None(AttributeError)"]
547+
except ModuleNotFoundError:
548+
my_cmd_hlp = ["None(ModuleNotFoundError)"]
543549
inner_lst = ["dials." + cmd_str , "-h"]
544550
try:
545551
if win_exe:
@@ -569,6 +575,10 @@ def get_help_list(cmd_str):
569575
new_line = my_proc.stdout.readline()
570576
my_cmd_hlp.append(new_line[:-1])
571577

578+
except TypeError:
579+
print("..." + cmd_str + " ...TypeError")
580+
my_cmd_hlp = []
581+
572582
top_trimed_lst_1 = []
573583
found_sage_pp = False
574584
for single_line in my_cmd_hlp:

0 commit comments

Comments
 (0)