Process and filter jochem file to produce list of names for dictionary.
420910
def prepare_jochem(ctx, jochem, output, csoutput):
    """"""
    click.echo('chemdataextractor.dict.prepare_jochem')
    for i, line in enumerate(jochem):
        print('JC%s' % i)
        if line.startswith('TM '):
            if line.endswith('	@match=ci\n'):
                for tokens in _make_tokens(line[3:-11]):
                    output.write(' '.join(tokens))
                    output.write('\n')
            else:
                for tokens in _make_tokens(line[3:-1]):
                    csoutput.write(' '.join(tokens))
                    csoutput.write('\n')
729551
def _process_filters(self, filters):
        
        rv = []
        for f in filters:
            if isinstance(f, F):
                if f.filters:
                    rv.extend(self._process_filters(f.filters))
                    continue

            elif isinstance(f, dict):
                if six.PY3:
                    key = list(f.keys())[0]
                else:
                    key = f.keys()[0]
                val = f[key]
                key = key.strip('_')

                if key not in ('or', 'and', 'not', 'filter'):
                    raise InvalidFieldActionError(
                        '%s is not a valid connector' % f.keys()[0])

                if 'filter' in val:
                    filter_filters = self._process_filters(val['filter'])
                    if len(filter_filters) == 1:
                        filter_filters = filter_filters[0]
                    rv.append({key: {'filter': filter_filters}})
                else:
                    rv.append({key: self._process_filters(val)})

            else:
                key, val = f
                key, field_action = split_field_action(key)
                handler_name = 'process_filter_{0}'.format(field_action)

                if field_action and hasattr(self, handler_name):
                    rv.append(getattr(self, handler_name)(
                            key, val, field_action))

                elif key.strip('_') in ('or', 'and', 'not'):
                    connector = key.strip('_')
                    rv.append({connector: self._process_filters(val.items())})

                elif field_action is None:
                    if val is None:
                        rv.append({'missing': {
                                    'field': key, "null_value": True}})
                    else:
                        rv.append({'term': {key: val}})

                elif field_action in ('startswith', 'prefix'):
                    rv.append({'prefix': {key: val}})

                elif field_action == 'in':
                    rv.append({'in': {key: val}})

                elif field_action in RANGE_ACTIONS:
                    rv.append({'range': {key: {field_action: val}}})

                elif field_action == 'range':
                    lower, upper = val
                    rv.append({'range': {key: {'gte': lower, 'lte': upper}}})

                elif field_action == 'distance':
                    distance, latitude, longitude = val

                    rv.append({
                        'geo_distance': {
                            'distance': distance,
                            key: [longitude, latitude]
                        }
                    })

                else:
                    raise InvalidFieldActionError(
                        '%s is not a valid field action' % field_action)

        return rv
3331
def make_filenames(self, **kwargs):
        
        out_dict = dict(ft1file=self.ft1file(**kwargs),
                        ltcube=self.ltcube(**kwargs),
                        ccube=self.ccube(**kwargs),
                        bexpcube=self.bexpcube(**kwargs),
                        srcmaps=self.srcmaps(**kwargs),
                        mcube=self.mcube(**kwargs))
        return out_dict
792437
def _filter(self, dict, keep):
        
        if not keep:
            return dict

        result = {}
        for key, value in dict.iteritems():
            if key in keep:
                result[key] = value
        return result
875380
def _line_to_dict(self, file, field_names):
        
        for line in file:
            delimiter = settings.IPGEOBASE_FILE_FIELDS_DELIMITER
            yield self._extract_data_from_line(line, field_names, delimiter)
430061
def filenames(self):
        """"""
        if self.topic.has_file:
            yield self.topic.file.filename
        for reply in self.replies:
            if reply.has_file:
                yield reply.file.filename
921603
def identify_names(filename):
    """"""
    node, _ = parse_source_file(filename)
    if node is None:
        return {}

    # Get matches from the code (AST)
    finder = NameFinder()
    finder.visit(node)
    names = list(finder.get_mapping())
    names += extract_object_names_from_docs(filename)

    example_code_obj = collections.OrderedDict()
    for name, full_name in names:
        if name in example_code_obj:
            continue  # if someone puts it in the docstring and code
        # name is as written in file (e.g. np.asarray)
        # full_name includes resolved import path (e.g. numpy.asarray)
        splitted = full_name.rsplit('.', 1)
        if len(splitted) == 1:
            # module without attribute. This is not useful for
            # backreferences
            continue

        module, attribute = splitted
        # get shortened module name
        module_short = get_short_module_name(module, attribute)
        cobj = {'name': attribute, 'module': module,
                'module_short': module_short}
        example_code_obj[name] = cobj
    return example_code_obj
231567
def namelist(self):
        """"""
        l = []
        for data in self.filelist:
            l.append(data.filename)
        return l
663464
def _name_lookup(names):
    """
    mapper = dict(zip(range(len(names)), names))

    def lookup(val):
        return mapper.get(val, 'Unknown')
    return lookup
395283
def list_names(cls):
        """"""
        response = subwrap.run(['lxc-ls'])
        output = response.std_out
        return map(str.strip, output.splitlines())
1303050
def filter_python_files(files):
    ""
    py_files = []
    for f in files:
        # If we end in .py, or if we don't have an extension and file says that
        # we are a python script, then add us to the list
        extension = os.path.splitext(f)[-1]

        if extension:
            if extension == '.py':
                py_files.append(f)
        elif 'python' in open(f, 'r').readline():
            py_files.append(f)
        elif 'python script' in bash('file {}'.format(f)).value().lower():
            py_files.append(f)

    return py_files
319712
def read_dict(file_name, clear_none=False, encoding='utf-8'):
    
    with open(file_name, 'rb') as f:
        data = f.read()

    if encoding is not None:
        data = data.decode(encoding)

    line_list = data.splitlines()
    data = []
    i = 0
    for line in line_list:
        i += 1
        try:
            line = force_text(line).strip()
            data.append(line)
        except:
            print('read error line %s' % i)
    if clear_none:
        data = [t for t in data if t != '']
    data = deque(data)
    return data
580832
def _listeq_to_dict(jobconfs):
    """"""
    if not isinstance(jobconfs, dict):
        jobconfs = dict(x.split('=', 1) for x in jobconfs)
    return dict((str(k), str(v)) for k, v in jobconfs.items())
243955
def filter_indices(self, options, verbosity, *args, **kwargs):
        """"""
        index_name_map = {
            index.__class__.__name__: index
            for index in index_builder.indexes
        }

        # Process includes.
        if options['index']:
            indices = set(options['index'])
        else:
            indices = set(index_name_map.keys())

        # Process excludes.
        for index_name in options['exclude']:
            if index_name not in index_name_map:
                self.invalid_index(index_name)
                return

            indices.discard(index_name)

        # Execute action for each remaining index.
        for index_name in indices:
            try:
                index = index_name_map[index_name]
            except KeyError:
                self.invalid_index(index_name)
                return

            if verbosity > 0:
                self.stdout.write("Processing index '{}'...".format(index_name))
            self.handle_index(index, *args, **kwargs)
1333856
def __clean_dict(dictionary):
        
        key_dict = {}
        value_dict = {}
        final_list = []
        for key in dictionary.keys():
            key_dict[key] = "seq"

        for value in dictionary.values():
            value_dict[value] = "text"

        for (key1, value1), (key2, value2) in zip(key_dict.items(), value_dict.items()):
            final_list.append({value1: int(key1), value2: key2})

        return final_list
49999
def _get_names(self):
        
        names = self._read_name_file('names.json')
        names = self._compute_weights(names)

        return names
1343270
def _get_py_dictionary(self, var, names=None, used___dict__=False):
        '''
        
        '''

        # TODO: Those should be options (would fix https://github.com/Microsoft/ptvsd/issues/66).
        filter_private = False
        filter_special = True
        filter_function = True
        filter_builtin = True

        if not names:
            names, used___dict__ = self.get_names(var)
        d = {}

        # Be aware that the order in which the filters are applied attempts to
        # optimize the operation by removing as many items as possible in the
        # first filters, leaving fewer items for later filters

        if filter_builtin or filter_function:
            for name in names:
                try:
                    name_as_str = name
                    if name_as_str.__class__ != str:
                        name_as_str = '%r' % (name_as_str,)

                    if filter_special:
                        if name_as_str.startswith('__') and name_as_str.endswith('__'):
                            continue

                    if filter_private:
                        if name_as_str.startswith('_') or name_as_str.endswith('__'):
                            continue
                    if not used___dict__:
                        attr = getattr(var, name)
                    else:
                        attr = var.__dict__[name]

                    # filter builtins?
                    if filter_builtin:
                        if inspect.isbuiltin(attr):
                            continue

                    # filter functions?
                    if filter_function:
                        if inspect.isroutine(attr) or isinstance(attr, MethodWrapperType):
                            continue
                except:
                    # if some error occurs getting it, let's put it to the user.
                    strIO = StringIO.StringIO()
                    traceback.print_exc(file=strIO)
                    attr = strIO.getvalue()

                d[name_as_str] = attr

        return d, used___dict__