@@ -232,7 +232,7 @@ def autoconfig_get_default_import_launcher():
232232 'plot' : '' ,
233233 'platform' : 'Unknown' ,
234234 'application' : '' ,
235- 'args' : '' ,
235+ 'args' : [] ,
236236 'args_extra' : [],
237237 'ROM_path' : '' ,
238238 'ROM_ext' : '' ,
@@ -328,6 +328,7 @@ def autoconfig_import_launchers(CATEGORIES_FILE_PATH, ROMS_DIR, categories, laun
328328 # >> Process tags in XML configuration file
329329 imported_categories_list = []
330330 imported_launchers_list = []
331+ list_type_tags = ['args' , 'args_extra' ]
331332 for root_element in xml_root :
332333 if __debug_xml_parser : log_debug ('>>> Root child tag <{0}>' .format (root_element .tag ))
333334
@@ -352,9 +353,11 @@ def autoconfig_import_launchers(CATEGORIES_FILE_PATH, ROMS_DIR, categories, laun
352353 xml_tag = root_child .tag
353354 if __debug_xml_parser : log_debug ('>>> "{0:<11s}" --> "{1}"' .format (xml_tag , xml_text ))
354355
355- # >> Transform list datatype. Only add to the list if string is non empty.
356- if xml_tag == 'args_extra' and xml_text : launcher_temp [xml_tag ].append (xml_text )
357- else : launcher_temp [xml_tag ] = xml_text
356+ # Transform list datatype. Only add to the list if string is non empty.
357+ if xml_tag in list_type_tags and xml_text :
358+ launcher_temp [xml_tag ].append (xml_text )
359+ continue
360+ launcher_temp [xml_tag ] = xml_text
358361 # --- Add launcher to categories dictionary ---
359362 log_debug ('Adding launcher "{0}" to import list' .format (launcher_temp ['name' ]))
360363 imported_launchers_list .append (launcher_temp )
@@ -712,17 +715,39 @@ def autoconfig_import_launcher(ROMS_DIR, categories, launchers, categoryID, laun
712715 launchers [launcherID ]['application' ] = i_launcher ['application' ]
713716 log_debug ('Imported application "{0}"' .format (i_launcher ['application' ]))
714717
715- if i_launcher ['args' ]:
718+ # Both <args> and <args_extra> are lists. <args_extra> is deprecated.
719+ # Case 1) Only one <args> tag
720+ # Case 2) Multiple <args> tag
721+ # Case 3) One <arg> tag and one or more <args_extra> tags. This is deprecated.
722+ len_args = len (i_launcher ['args' ])
723+ len_extra_args = len (i_launcher ['args_extra' ])
724+ if len_args == 1 and len_extra_args == 0 :
716725 launchers [launcherID ]['args' ] = i_launcher ['args' ]
726+ launchers [launcherID ]['args_extra' ] = []
717727 log_debug ('Imported args "{0}"' .format (i_launcher ['args' ]))
718-
719- # >> For every args_extra item add one entry to the list
720- if i_launcher ['args_extra' ]:
721- # >> Reset current args_extra
728+ log_debug ('Resetted args_extra' )
729+ elif len_args > 1 and len_extra_args == 0 :
730+ args_str = i_launcher ['args' ][0 ]
731+ args_extra_list = i_launcher ['args' ][1 :]
732+ launchers [launcherID ]['args' ] = args_str
733+ log_debug ('Imported args "{0}"' .format (args_str ))
734+ launchers [launcherID ]['args_extra' ] = []
735+ for args in args_extra_list :
736+ launchers [launcherID ]['args_extra' ].append (args )
737+ log_debug ('Imported args_extra "{0}"' .format (args ))
738+ elif len_args == 1 and len_extra_args >= 1 :
739+ args_str = i_launcher ['args' ][0 ]
740+ args_extra_list = i_launcher ['args_extra' ]
741+ launchers [launcherID ]['args' ] = args_str
742+ log_debug ('Imported args "{0}"' .format (args_str ))
722743 launchers [launcherID ]['args_extra' ] = []
723- for args in i_launcher [ 'args_extra' ] :
744+ for args in args_extra_list :
724745 launchers [launcherID ]['args_extra' ].append (args )
725746 log_debug ('Imported args_extra "{0}"' .format (args ))
747+ else :
748+ log_error ('Wrong usage of <args> and <args_extra>' )
749+ log_error ('len_args = {}, len_extra_args = {}' .format (len_args , len_extra_args ))
750+ log_error ('No arguments imported.' )
726751
727752 # >> Warn user if rompath directory does not exist
728753 if i_launcher ['ROM_path' ]:
0 commit comments