Generate a new argument list by remapping keys. The 'remap'
    dict maps from destination key -> priority list of source keys
967837
def remap_args(input_args, remap):
    
    out_args = input_args
    for dest_key, src_keys in remap.items():
        remap_value = None
        if isinstance(src_keys, str):
            src_keys = [src_keys]

        for key in src_keys:
            if key in input_args:
                remap_value = input_args[key]
                break

        if remap_value is not None:
            if out_args is input_args:
                out_args = {**input_args}
            out_args[dest_key] = remap_value

    return out_args
1103328
def fillkeys(Recs):
    
    keylist, OutRecs = [], []
    for rec in Recs:
        for key in list(rec.keys()):
            if key not in keylist:
                keylist.append(key)
    for rec in Recs:
        for key in keylist:
            if key not in list(rec.keys()):
                rec[key] = ""
        OutRecs.append(rec)
    return OutRecs, keylist
904670
def _update_file_args(self, file_mapping):
        """"""
        for key, value in self.args.items():
            new_value = file_mapping.get(value, value)
            if new_value != value:
                self.args[key] = new_value
982372
def _map_arguments(self, args):
        
        data = args.get('data')
        comp = args.get('comp')
        ft1file = args.get('ft1file')
        scratch = args.get('scratch', None)
        dry_run = args.get('dry_run', None)

        self._set_link('split-and-bin', SplitAndBin_SG,
                       comp=comp, data=data,
                       hpx_order_max=args.get('hpx_order_ccube', 9),
                       ft1file=ft1file,
                       scratch=scratch,
                       dry_run=dry_run)

        self._set_link('coadd-split', CoaddSplit_SG,
                       comp=comp, data=data,
                       ft1file=ft1file)

        self._set_link('expcube2', Gtexpcube2_SG,
                       comp=comp, data=data,
                       hpx_order_max=args.get('hpx_order_expcube', 5),
                       dry_run=dry_run)
1147547
def args_wrapper(*args):
    
    out = defaultdict(list)
    for callback in args:
        callback_args = callback.callback_args()
        for k, v in callback_args.items():
            out[k].append(v)
    return dict(out)
744567
def list_keys(kwargs=None, call=None):
    '''
    
    '''
    if call != 'function':
        log.error(
            'The list_keys function must be called with -f or --function.'
        )
        return False

    if not kwargs:
        kwargs = {}

    ret = {}
    rcode, data = query(command='my/keys', method='GET')
    for pair in data:
        ret[pair['name']] = pair['key']
    return {'keys': ret}
1244069
def reorder_keys(self, keys):
        ''''''
        if len(keys) != len(self._set):
            raise ValueError('The supplied number of keys does not match.')
        if set(keys) != self._set:
            raise ValueError('The supplied keys do not match the current set of keys.')
        self._keys = list(keys)
871448
def rename_keys(record: Mapping, key_map: Mapping) -> dict:
    """"""

    new_record = dict()

    for k, v in record.items():
        key = key_map[k] if k in key_map else k
        new_record[key] = v

    return new_record
466635
def key_list(items=None):
    '''
    
    '''
    if items is None:
        items = []

    ret = {}
    if items and isinstance(items, list):
        for item in items:
            if 'name' in item:
                # added for consistency with old code
                if 'id' not in item:
                    item['id'] = item['name']
                ret[item['name']] = item
    return ret
989440
def args_to_dict(args):
    # type: (str) -> DictUpperBound[str,str]
    
    arguments = dict()
    for arg in args.split(','):
        key, value = arg.split('=')
        arguments[key] = value
    return arguments
74219
def transform_arguments(arguments, prev_values, inputs)
      arguments = arguments.replace_values_from_previous(prev_values)
      arguments.each do |arg_name, arg_values|
        arguments[arg_name] = {} unless arguments[arg_name].is_a?(Hash)
        arguments[arg_name]['value'] = ''
        if inputs.key?(arg_name)
          arguments[arg_name]['value'] = inputs[arg_name]
        elsif arg_values.is_a?(Hash) && arg_values.key?('default')
          arguments[arg_name]['value'] = arg_values['default']
        end
      end
    end
1050372
def _print_map_dict(self, argkey, filename, append):
        """"""
        result = []
        skeys = list(sorted(self.curargs[argkey].keys()))
        for key in skeys:
            result.append("'{}' => {}".format(key, self.curargs[argkey][key]))
        self._redirect_output('\n'.join(result), filename, append, msg.info)
927412
def _map_arguments(self, args):
        

        config_yaml = args['config']
        config_dict = load_yaml(config_yaml)

        data = config_dict.get('data')
        comp = config_dict.get('comp')
        dry_run = args.get('dry_run', False)

        self._set_link('prepare', SplitAndMktimeChain,
                       comp=comp, data=data,
                       ft1file=config_dict['ft1file'],
                       ft2file=config_dict['ft2file'],
                       hpx_order_ccube=config_dict.get('hpx_order_ccube', 7),
                       hpx_order_expcube=config_dict.get('hpx_order_expcube', 7),
                       mktime=config_dict.get('mktimefitler', None),
                       do_ltsum=config_dict.get('do_ltsum', False),
                       scratch=config_dict.get('scratch', None),
                       dry_run=dry_run)

        self._set_link('residual-cr', ResidualCR_SG,
                       comp=comp, data=data,
                       mktimefilter=config_dict.get('mktimefitler', None),
                       hpx_order=config_dict.get('hpx_order_fitting', 4),
                       clean=config_dict.get('clean_class', None),
                       dirty=config_dict.get('dirty_class', None),                       
                       select_factor=config_dict.get('select_factor', None),
                       mask_factor=config_dict.get('mask_factor', None),
                       sigma=config_dict.get('sigma', None),
                       full_output=config_dict.get('full_output', False),
                       dry_run=dry_run)
410441
def args_kwargs_to_initdict(args: ArgsList, kwargs: KwargsDict) -> InitDict:
    
    return {ARGS_LABEL: args,
            KWARGS_LABEL: kwargs}
129177
def _map_arguments(self, args):
        
        data = args.get('data')
        comp = args.get('comp')
        library = args.get('library')
        dry_run = args.get('dry_run', False)

        self._set_link('srcmaps-catalog', SrcmapsCatalog_SG,
                       comp=comp, data=data,
                       library=library,
                       nsrc=args.get('nsrc', 500),
                       dry_run=dry_run)

        self._set_link('gather-srcmaps', GatherSrcmaps_SG,
                       comp=comp, data=data,
                       library=library,
                       dry_run=dry_run)
        
        self._set_link('merge-srcmaps', MergeSrcmaps_SG,
                       comp=comp, data=data,
                       library=library,
                       dry_run=dry_run)
696005
def apply_mapping(raw_row, mapping):
    '''
    
    '''
    row = {target: mapping_func(raw_row[source_key])
           for target, (mapping_func, source_key)
           in mapping.fget().items()}
    return row
1358656
def _prepare_memoization_key(args, kwargs):
    
    key_list = []
    for arg in args:
        try:
            hash(arg)
            key_list.append(arg)
        except:
            key_list.append(repr(arg))
    for (k, v) in kwargs.items():
        try:
            hash(k)
            hash(v)
            key_list.append((k, v))
        except:
            key_list.append((repr(k), repr(v)))
    return tuple(key_list)