@@ -58,11 +58,17 @@ def parse_command(command, indent=' '):
5858 # for all other commands stderr is just appended to stdout
5959 out += err
6060
61- warning = None
62- pattern = r'([\w\.]+ (?:has been|was) re(?:named to|placed(?: that [ \*\n]*|) by)(?: the ISP program|) [\w\.]+)'
63- match = re .search (pattern , out )
64- if match :
65- warning = "raise DeprecationWarning('{}')" .format (match .group ())
61+ # raise a warning when the command has been deprecated
62+ # extract all lines starting and ending with three asterisks
63+ matches = re .findall (r'^\*{3}\s*(.*?)\s*\*{3}$' , out , re .MULTILINE )
64+ if matches :
65+ # join the lines and search for a deprecation message
66+ cleaned = ' ' .join (matches )
67+ pattern = (r'([\w\.]+ (?:has been|was) re(?:named to|placed(?: that [ \*\n]*|) by)'
68+ r'(?:[ \*\n]*|)(?: the ISP program|) [\w\.]+)' )
69+ match = re .search (pattern , cleaned )
70+ if match :
71+ raise DeprecationWarning (match .group ())
6672
6773 if re .search (r"Can't locate FILE/Path\.pm in @INC" , out ):
6874 raise RuntimeError ('unable to parse Perl script' )
@@ -139,6 +145,8 @@ def parse_command(command, indent=' '):
139145 'mk_base_calc' : [('<RSLC_tab>' , '<SLC_tab>' )],
140146 'mk_cpd_all' : [('dtab' , 'data_tab' )],
141147 'mk_cpx_ref_2d' : [('diff_tab' , 'cpx_tab' )],
148+ 'mk_diff_tc_2d' : [('<def>' , '<def_rate>' ),
149+ ('def (input)' , 'def_rate (input)' )],
142150 'mk_dispmap2_2d' : [('RMLI_image' , 'MLI' ),
143151 ('RMLI_par' , 'MLI_par' ),
144152 ('MLI_image' , 'MLI' ),
@@ -166,6 +174,7 @@ def parse_command(command, indent=' '):
166174 ('MLI_image' , 'MLI' )],
167175 'mk_rasmph_all' : [('RMLI_image' , 'MLI' ),
168176 ('MLI_image' , 'MLI' )],
177+ 'mk_tab2' : [('--linenumber' , 'linenumber' )],
169178 'mk_unw_2d' : [('unw_mask1' , 'unw_mask' )],
170179 'mk_unw_ref_2d' : [('diff_tab' , 'DIFF_tab' )],
171180 'MLI2pt' : [('MLI_TAB' , 'MLI_tab' ),
@@ -358,9 +367,6 @@ def replace(inlist, replacement):
358367 if command_base in replacements .keys ():
359368 arg_req = replace (arg_req , replacements [command_base ])
360369 arg_opt = replace (arg_opt , replacements [command_base ])
361-
362- if command_base in ['par_CS_geo' , 'par_KS_geo' ]:
363- out = re .sub ('[ ]*trunk.*' , '' , out , flags = re .DOTALL )
364370 ###########################################
365371 # check if there are any double parameters
366372
@@ -379,22 +385,23 @@ def replace(inlist, replacement):
379385 ######################################################################################
380386 # create the function argument string for the Python function
381387
382- # optional arguments are parametrized with '-' as default value, e.g. arg_opt='-'
388+ # optional arguments are parametrized with '-' as default value, e.g., arg_opt='-'
389+ argstr_function = ', ' .join (arg_req + [x + "='-'" for x in arg_opt ])
383390 # a '-' in the parameter name is replaced with '_'
384- # example: "arg1, arg2, arg3='-'"
385- argstr_function = re . sub ( r'([^\'])-([^\'])' , r'\1_\2' , ', ' . join ( arg_req + [ x + "='-'" for x in arg_opt ])) \
386- .replace (', def=' , ', drm=' )
391+ argstr_function = re . sub ( r'([^\'])-([^\'])' , r'\1_\2' , argstr_function )
392+ # replace unsupported 'def' parameter name with 'drm'
393+ argstr_function = argstr_function .replace (', def=' , ', drm=' )
387394
388395 # some commands have different defaults than '-'
389396 replacements_defaults = {'S1_import_SLC_from_zipfiles' : {'OPOD_dir' : '.' }}
390397
391398 if command_base in replacements_defaults .keys ():
392399 for key , value in replacements_defaults [command_base ].items ():
393- old = "{ }='-'". format ( key )
400+ old = f" { key } ='-'"
394401 if isinstance (value , str ):
395- new = "{0 }='{1 }'". format ( key , value )
402+ new = f" { key } ='{ value } '"
396403 else :
397- new = "{0 }={1}" . format ( key , value )
404+ new = f" { key } ={ value } "
398405 argstr_function = argstr_function .replace (old , new )
399406
400407 # create the function definition string
@@ -417,12 +424,13 @@ def replace(inlist, replacement):
417424 ('max' , '-b' , None ),
418425 ('rmax' , '-R' , None ),
419426 ('mode' , '-m' , None ),
420- ('update' , '-u' , False )]}
427+ ('update' , '-u' , False )],
428+ 'mk_tab2' : [('linenumber' , '--linenumber' , False )]}
421429
422430 # replace arg default like arg='-' with arg=None or arg=False
423431 if command_base in flag_args :
424432 for arg in flag_args [command_base ]:
425- fun_def = re .sub ('{ }=\' -\' '. format ( arg [ 0 ]), '{0 }={1}' . format ( arg [0 ], arg [ 2 ]) , fun_def )
433+ fun_def = re .sub (f' { arg [ 0 ] } =\' -\' ', f' { arg [ 0 ] } ={ arg [2 ] } ' , fun_def )
426434 ######################################################################################
427435 # create the process call argument string
428436
@@ -440,7 +448,7 @@ def replace(inlist, replacement):
440448 key = replacements [command_base ][0 ][1 ]
441449 if isinstance (key , list ):
442450 key = key [0 ]
443- proc_args_tmp .insert (proc_args_tmp .index (key ), 'len({})' . format ( key ) )
451+ proc_args_tmp .insert (proc_args_tmp .index (key ), f 'len({ key } )' )
444452
445453 if command_base == 'validate' :
446454 index = proc_args_tmp .index ('classes_inv' )
@@ -469,10 +477,7 @@ def replace(inlist, replacement):
469477 # create the process call string
470478 proc_str = "process(cmd, logpath=logpath, outdir=outdir{inlist}, shellscript=shellscript)" \
471479 .format (inlist = ', inlist=inlist' if command_base in inlist else '' )
472- if warning is not None :
473- fun_proc = warning
474- else :
475- fun_proc = '{0}\n {1}' .format (cmd_str , proc_str )
480+ fun_proc = '{0}\n {1}' .format (cmd_str , proc_str )
476481
477482 if command_base == 'lin_comb_cpx' :
478483 fun_proc = fun_proc .replace ('factors_r, factors_i' , 'zip(factors_r, factors_i)' )
@@ -564,7 +569,7 @@ def replace(inlist, replacement):
564569 description = re .split (r'\n+\s*' , description .strip ('\n ' ))
565570
566571 # escape * characters (which are treated as special characters for bullet lists by sphinx)
567- description = [x .replace ('*' , r'\*' ) for x in description ]
572+ description = [x .replace ('*' , r'\\ *' ) for x in description ]
568573
569574 # convert all lines starting with an integer number or 'NOTE' to bullet list items
570575 latest = None
@@ -652,7 +657,7 @@ def parse_module(bindir, outfile):
652657
653658 excludes = ['coord_trans' , # doesn't take any parameters and is interactive
654659 'RSAT2_SLC_preproc' , # takes option flags
655- 'mk_ASF_CEOS_list' , # "cannot create : Directory nonexistent"
660+ 'mk_ASF_CEOS_list' , # "cannot create: Directory nonexistent"
656661 '2PASS_UNW' , # parameter name inconsistencies
657662 'mk_diff_2d' , # takes option flags
658663 'gamma_doc' # opens the Gamma documentation
@@ -680,8 +685,8 @@ def parse_module(bindir, outfile):
680685 with open (outfile , 'a' ) as out :
681686 out .write (outstring )
682687 if len (failed ) > 0 :
683- log . info (
684- 'the following functions could not be parsed: \n {0} \n ({1} total)' .format ('\n ' .join (failed ), len (failed )))
688+ info = 'the following functions could not be parsed: \n {0} \n ({1} total)'
689+ log . info ( info .format ('\n ' .join (failed ), len (failed )))
685690
686691
687692def autoparse ():
0 commit comments