Build and return a dict of `FileHandle` from an `astropy.table.Table`

        The dictionary is keyed by FileHandle.key, which is a unique integer for each file
421793
def make_dict(cls, table):
        
        ret_dict = {}
        for row in table:
            file_handle = cls.create_from_row(row)
        ret_dict[file_handle.key] = file_handle
        return ret_dict
264182
def key_from_dict(**kwargs):
    
    out = []
    stack = [kwargs]
    while stack:
        obj = stack.pop()
        if isinstance(obj, dict):
            stack.extend(sorted(obj.items()))
        elif isinstance(obj, (list, tuple)):
            stack.extend(obj)
        else:
            out.append(str(obj))
    return ''.join(out)
1338456
def import_file(filename, name=None):
    
    # Specifying a traditional dot-separated fully qualified name here
    # results in a number of "Parent module 'astropy' not found while
    # handling absolute import" warnings.  Using the same name, the
    # namespaces of the modules get merged together.  So, this
    # generates an underscore-separated name which is more likely to
    # be unique, and it doesn't really matter because the name isn't
    # used directly here anyway.
    mode = 'r'

    if name is None:
        basename = os.path.splitext(filename)[0]
        name = '_'.join(os.path.relpath(basename).split(os.sep)[1:])

    if not os.path.exists(filename):
        raise ImportError('Could not import file {0}'.format(filename))

    if import_machinery:
        loader = import_machinery.SourceFileLoader(name, filename)
        mod = loader.load_module()
    else:
        with open(filename, mode) as fd:
            mod = imp.load_module(name, fd, filename, ('.py', mode, 1))

    return mod
325329
function getRelayHandleKey(
  handleName: string,
  key: ?string,
  fieldName: ?string,
): string {
  if (key && key !== DEFAULT_HANDLE_KEY) {
    return `__${key}_${handleName}`;
  }

  invariant(
    fieldName != null,
    'getRelayHandleKey: Expected either `fieldName` or `key` in `handle` to be provided',
  );
  return `__${fieldName}_${handleName}`;
}
857611
def recordlookup(table, key, dictionary=None):
    

    if dictionary is None:
        dictionary = dict()

    it = iter(table)
    hdr = next(it)
    flds = list(map(text_type, hdr))
    keyindices = asindices(hdr, key)
    assert len(keyindices) > 0, 'no key selected'
    getkey = operator.itemgetter(*keyindices)
    for row in it:
        k = getkey(row)
        rec = Record(row, flds)
        if k in dictionary:
            # work properly with shelve
            l = dictionary[k]
            l.append(rec)
            dictionary[k] = l
        else:
            dictionary[k] = [rec]
    return dictionary
4187
def get_key(self, fileobj):
        
        mapping = self.get_map()
        if mapping is None:
            raise RuntimeError("Selector is closed")
        try:
            return mapping[fileobj]
        except KeyError:
            raise KeyError("{0!r} is not registered".format(fileobj))
917737
def get_attrs(self, key):
        
        try:
            dset = h5py.File.__getitem__(self.hdf5, key)
        except KeyError:
            if self.parent != ():
                dset = h5py.File.__getitem__(self.parent.hdf5, key)
            else:
                raise
        return dict(dset.attrs)
1001322
def parse_file_to_dict(self, fname):
        
        print('TODO - parse_file_to_dict' + fname)
        for m in self.maps:
            if m.tpe == 'file':
                if m.key[0:3] == 'col':
                    print('reading column..')
85334
def file_handles(self) -> Iterable[IO[str]]:
        
        if self.file_handle:
            yield self.file_handle
            self.file_handle.close()
            self.file_handle = None
        else:
            for name in self.file_names():
                with open(name, "r") as f:
                    yield f
130325
def get_dict(*keys, **extras):
    """"""

    _keys = ('url', 'args', 'form', 'data', 'origin', 'headers', 'files', 'json', 'method')

    assert all(map(_keys.__contains__, keys))
    data = request.data
    form = semiflatten(request.form)

    try:
        _json = json.loads(data.decode('utf-8'))
    except (ValueError, TypeError):
        _json = None

    d = dict(
        url=get_url(request),
        args=semiflatten(request.args),
        form=form,
        data=json_safe(data),
        origin=request.headers.get('X-Forwarded-For', request.remote_addr),
        headers=get_headers(),
        files=get_files(),
        json=_json,
        method=request.method,
    )

    out_d = dict()

    for key in keys:
        out_d[key] = d.get(key)

    out_d.update(extras)

    return out_d
764283
def table_to_root(table, filename, **kwargs):
    
    import root_numpy
    root_numpy.array2root(table.as_array(), filename, **kwargs)
743569
def retrieve_file_handles_of_same_dataset(self, **args):
        '''
        
        '''
        mandatory_args = ['drs_id', 'version_number', 'data_node', 'prefix']
        esgfpid.utils.check_presence_of_mandatory_args(args, mandatory_args)
        self.__reset_error_messages()

        # Try plan A
        file_handles = None
        try:
            file_handles = self.__strategy1(args) # can raise SolrError or SolrSwitchedOff, but can't return None
        except esgfpid.exceptions.SolrError as e:
            self.__error_messages.append('Error during first query: '+e.message)

        if file_handles is not None and len(file_handles)>0:
            LOGGER.debug('Retrieved file handles from solr in first query.')
            return file_handles

        # Try plan B
        try:
            file_handles = self.__strategy2(args) # can raise SolrError or SolrSwitchedOff, but can't return None
        except esgfpid.exceptions.SolrError as e:
            self.__error_messages.append('Error during second query: '+e.message)
            msg = '/n'.join(self.__error_messages)
            raise esgfpid.exceptions.SolrError('Failure in both queries. Messages:\n'+msg)

        return file_handles
1198558
def _file_dict(self, fn_):
        '''
        
        '''
        if not os.path.isfile(fn_):
            err = 'The referenced file, {0} is not available.'.format(fn_)
            sys.stderr.write(err + '\n')
            sys.exit(42)
        with salt.utils.files.fopen(fn_, 'r') as fp_:
            data = fp_.read()
        return {fn_: data}
383863
def dict(self):
        
        from collections import OrderedDict

        d = OrderedDict(
            [(p.key, getattr(self, p.key)) for p in self.__mapper__.attrs if p.key not in ('data',)])

        if 'list' in self.data:
            d['bundle_count'] = len(self.data['list'])
        else:
            d['bundle_count'] = None

        if self.data:
            for k, v in self.data.items():
                d[k] = v

        return d
445591
def get_calls_from_dict(self, file_dict, from_name, settings={}):
        '''
        
        '''

        calls = []
        call_settings = dict(settings)

        # Include all possible sections
        # The way to draw them is defined in call graph
        special_sections = {'builders', 'publishers', 'wrappers'}

        # Trigger flags
        triggers = {'trigger-builds', 'trigger-parameterized-builds'}

        if isinstance(file_dict, dict):
            for key in file_dict:

                if key in special_sections:
                    call_settings['section'] = key

                if key in triggers:
                    calls.extend(self.extract_call(file_dict[key], from_name, settings=call_settings))
                else:
                    calls.extend(self.get_calls_from_dict(file_dict[key], from_name, settings=call_settings))
        elif type(file_dict) == list:
            for value in file_dict:
                calls.extend(self.get_calls_from_dict(value, from_name, settings=call_settings))

        return calls
443345
def _parse(self):
        """"""
        with open(self.filename, 'r') as fobj:
            lines = fobj.read().split('\n')

        # Create a header object with content at start of file
        self.header = MOPHeader(self.subfmt).parser(lines)

        # Create a data attribute to hold an astropy.table.Table object
        self.data = MOPDataParser(self.header).parse(lines)
303980
def _preprocess(self, filehandle, metadata):
        ""
        for process in self._preprocessors:
            filehandle = process(filehandle, metadata)
        return filehandle