@@ -135,7 +135,12 @@ def get_quant_iter_pos(name: str) -> tuple:
135135def to_py_arg_name (name : str ) -> str :
136136 """Python-compatible term"""
137137 arg = str (name ).lower ().strip ()
138- p = engine ()
138+ if arg == "" :
139+ return arg
140+ elif arg .isdigit ():
141+ return ""
142+ if arg [0 ].isdigit ():
143+ p = engine ()
139144 if arg [0 ].isdigit ():
140145 if arg [1 ].isdigit ():
141146 raise ValueError (f"The code needs to be expanded to handle numbers" )
@@ -146,8 +151,11 @@ def to_py_arg_name(name: str) -> str:
146151 num_value = p .number_to_words (arg [:3 ])
147152 arg = f"{ num_value } { arg [3 :]} "
148153
149- if ("," in arg and "--" in arg ) or arg == "–" :
150- return ""
154+ if "--" in arg or arg == "–" :
155+ arg = arg .replace ("--" , "" )
156+ arg = arg .replace ("–" , "" )
157+ arg = arg .replace (" " , "" )
158+ return arg
151159
152160 for key , value in PY_ARG_CLEANUP .items ():
153161 arg = arg .replace (key , value )
@@ -204,7 +212,7 @@ def str_types(types, join_str: str) -> str:
204212
205213def to_py_signature (py_arg_name , types ) -> str :
206214 """Return the Python signature of the argument."""
207- if py_arg_name not in [ "--" , "–" , "" ] :
215+ if "," not in py_arg_name and py_arg_name != "" :
208216 kwarg = f'{ py_arg_name } : { str_types (types , " | " )} = ""'
209217 else :
210218 kwarg = None
@@ -2119,16 +2127,17 @@ def _parse_list_entry(self):
21192127 additional_args = argument_obj .multiple_args
21202128 if len (additional_args ) > 0 :
21212129 for arg in additional_args :
2122- if arg .py_arg_name != "" and arg .py_arg_name not in self .py_arg_names :
2130+ arg_name = arg .py_arg_name
2131+ if ("," in arg_name or arg_name == "" ) or (arg_name not in self .py_arg_names ):
21232132 self ._arguments .append (arg )
21242133
21252134 else :
2126- if argument_obj .py_arg_name != "" :
2127- self ._arguments .append (argument_obj )
2135+ self ._arguments .append (argument_obj )
21282136
21292137 def __iadd__ (self , argument_list ):
21302138 for arg in argument_list .arguments :
2131- if arg .py_arg_name not in self .py_arg_names :
2139+ arg_name = arg .py_arg_name
2140+ if ("," not in arg_name or arg_name == "" ) or (arg_name not in self .py_arg_names ):
21322141 self ._arguments .append (arg )
21332142 return self
21342143
@@ -2350,7 +2359,7 @@ def to_py_docstring(
23502359 self , max_length = 100 , indent = "" , links = None , base_url = None , fcache = None
23512360 ) -> List [str ]:
23522361 """Return a list of string to enable converting the element to an RST format."""
2353- if self .py_arg_name not in [ "--" , "–" , "" ] :
2362+ if "," not in self .py_arg_name and self . py_arg_name != "" :
23542363 docstring = [f'{ indent } { self .py_arg_name } : { str_types (self .types , " or " )} ' ]
23552364 if isinstance (self ._description , str ):
23562365 rst_description = self ._description
@@ -2373,6 +2382,7 @@ def to_py_docstring(
23732382
23742383 docstring = [f'{ indent } { self .py_arg_name } : { str_types (self .types , " or " )} ' ]
23752384 docstring .extend (list_description )
2385+
23762386 else :
23772387 docstring = []
23782388 return docstring
@@ -2442,6 +2452,8 @@ def arg_desc(self) -> List[Argument]:
24422452 arguments = ArgumentList (child , self .args )
24432453 else :
24442454 arguments += ArgumentList (child , self .args )
2455+ if self .py_name == "secmodif" :
2456+ print (arguments .py_arg_names )
24452457
24462458 else :
24472459 for elem in refsyn :
@@ -2450,14 +2462,20 @@ def arg_desc(self) -> List[Argument]:
24502462 arguments = ArgumentList (elem , self .args )
24512463 else :
24522464 arguments += ArgumentList (elem , self .args )
2465+ if self .py_name == "secmodif" :
2466+ print ("HERE" )
2467+ print (arguments .py_arg_names )
2468+
24532469
2470+ # if self.py_name in ["secmodif", "dmat"]:
2471+ # print(arguments.initial_args)
2472+ # print(arguments.py_arg_names)
24542473 if arguments is not None :
24552474 if len (arguments .py_arg_names ) < len (arguments .initial_args ):
24562475 for arg in arguments .initial_args :
24572476 if arg not in arguments .py_arg_names :
24582477 new_arg = Argument (arg , arguments .initial_args , "" )
2459- if new_arg .py_arg_name != "" :
2460- arguments .arguments .append (new_arg )
2478+ arguments .arguments .append (new_arg )
24612479
24622480 return arguments .arguments
24632481
@@ -2899,9 +2917,15 @@ def py_source(self, custom_functions=None, indent=""):
28992917 if len (self .arg_desc ) > 0 :
29002918 command = 'command = f"' + self .name
29012919 for arg in self .arg_desc :
2902- command += ",{"
2903- command += arg .py_arg_name
2904- command += "}"
2920+ name = arg .py_arg_name
2921+ if "," in name :
2922+ command += f",{ name } "
2923+ elif name == "" :
2924+ command += ","
2925+ else :
2926+ command += ",{"
2927+ command += arg .py_arg_name
2928+ command += "}"
29052929 command += '"\n '
29062930 # ",{" + "},{".join(self.arg_desc.py_arg_name) + '}"\n'
29072931 else :
0 commit comments