def parse_owner_mappings(type, options, fatal):
 opt_name = ('--map-' + type)
 value_rx = '^([^=]+)=([^=]*)$'
 if (type in ('uid', 'gid')):
  value_rx = '^(-?[0-9]+)=(-?[0-9]+)$'
 owner_map = {}
 for flag in options:
  (option, parameter) = flag
  if (option != opt_name):
   continue
  match = re.match(value_rx, parameter)
  if (not match):
   raise fatal(("couldn't parse %s as %s mapping" % (parameter, type)))
  (old_id, new_id) = match.groups()
  if (type in ('uid', 'gid')):
   old_id = int(old_id)
   new_id = int(new_id)
  owner_map[old_id] = new_id
 return owner_map

def parse_owner_mappings ( type , options , fatal ) : opt_name = ( '--map-' + type ) value_rx = '^([^=]+)=([^=]*)$' if ( type in ( 'uid' , 'gid' ) ) : value_rx = '^(-?[0-9]+)=(-?[0-9]+)$' owner_map = { } for flag in options : ( option , parameter ) = flag if ( option != opt_name ) : continue match = re . match ( value_rx , parameter ) if ( not match ) : raise fatal ( ( "couldn't parse %s as %s mapping" % ( parameter , type ) ) ) ( old_id , new_id ) = match . groups ( ) if ( type in ( 'uid' , 'gid' ) ) : old_id = int ( old_id ) new_id = int ( new_id ) owner_map [ old_id ] = new_id return owner_map
traverse the options and parse all --map-types .