def merge_options(options, optgroup=None):
 alloptions = {}
 options = list(options)
 for i in range((len(options) - 1), (-1), (-1)):
  (optname, optdict) = options[i]
  if (optname in alloptions):
   options.pop(i)
   alloptions[optname].update(optdict)
  else:
   optdict = optdict.copy()
   options[i] = (optname, optdict)
   alloptions[optname] = optdict
  if (optgroup is not None):
   alloptions[optname]['group'] = optgroup
 return tuple(options)

def merge_options ( options , optgroup = None ) : alloptions = { } options = list ( options ) for i in range ( ( len ( options ) - 1 ) , ( - 1 ) , ( - 1 ) ) : ( optname , optdict ) = options [ i ] if ( optname in alloptions ) : options . pop ( i ) alloptions [ optname ] . update ( optdict ) else : optdict = optdict . copy ( ) options [ i ] = ( optname , optdict ) alloptions [ optname ] = optdict if ( optgroup is not None ) : alloptions [ optname ] [ 'group' ] = optgroup return tuple ( options )
preprocess a list of options and remove duplicates .