Parses files to load them into memory and insert them into the class.

        :param filename: File or directory pointing to .ioc files.
        :return: A list of .ioc files which could not be parsed.
979488
def insert(self, filename):
        
        errors = []
        if os.path.isfile(filename):
            log.info('loading IOC from: {}'.format(filename))
            try:
                self.parse(ioc_api.IOC(filename))
            except ioc_api.IOCParseError:
                log.exception('Parse Error')
                errors.append(filename)
        elif os.path.isdir(filename):
            log.info('loading IOCs from: {}'.format(filename))
            for fn in glob.glob(filename + os.path.sep + '*.ioc'):
                if not os.path.isfile(fn):
                    continue
                else:
                    try:
                        self.parse(ioc_api.IOC(fn))
                    except ioc_api.IOCParseError:
                        log.exception('Parse Error')
                        errors.append(fn)
        else:
            pass
        log.info('Parsed [{}] IOCs'.format(len(self)))
        return errors
335771
def file_source(self, filename):
        
        lines = []
        try:
            with self.filesystem.open(filename) as f:
                line_statuses = dict(self.line_statuses(filename))
                for lineno, source in enumerate(f, start=1):
                    line_status = line_statuses.get(lineno)
                    line = Line(lineno, source, line_status, None)
                    lines.append(line)

        except self.filesystem.FileNotFound as file_not_found:
            lines.append(
                Line(0, '%s not found' % file_not_found.path, None, None)
            )

        return lines
562522
def from_files(filenames, strict_type_checks=True):
    
    if strict_type_checks:
        load_whitelist()

    all_histograms = OrderedDict()
    for filename in filenames:
        parser = FILENAME_PARSERS[os.path.basename(filename)]
        histograms = parser(filename, strict_type_checks)

        # OrderedDicts are important, because then the iteration order over
        # the parsed histograms is stable, which makes the insertion into
        # all_histograms stable, which makes ordering in generated files
        # stable, which makes builds more deterministic.
        if not isinstance(histograms, OrderedDict):
            raise ParserError("Histogram parser did not provide an OrderedDict.")

        for name, definition in iteritems(histograms):
            if name in all_histograms:
                raise ParserError('Duplicate histogram name "%s".' % name)
            all_histograms[name] = definition

    # We require that all USE_COUNTER2_* histograms be defined in a contiguous
    # block.
    use_counter_indices = filter(lambda x: x[1].startswith("USE_COUNTER2_"),
                                 enumerate(iterkeys(all_histograms)))
    if use_counter_indices:
        lower_bound = use_counter_indices[0][0]
        upper_bound = use_counter_indices[-1][0]
        n_counters = upper_bound - lower_bound + 1
        if n_counters != len(use_counter_indices):
            raise ParserError("Use counter histograms must be defined in a contiguous block.")

    # Check that histograms that were removed from Histograms.json etc.
    # are also removed from the whitelists.
    if whitelists is not None:
        all_whitelist_entries = itertools.chain.from_iterable(whitelists.itervalues())
        orphaned = set(all_whitelist_entries) - set(iterkeys(all_histograms))
        if len(orphaned) > 0:
            msg = 'The following entries are orphaned and should be removed from ' \
                  'histogram-whitelists.json:\n%s'
            raise ParserError(msg % (', '.join(sorted(orphaned))))

    for name, definition in iteritems(all_histograms):
        yield Histogram(name, definition, strict_type_checks=strict_type_checks)
1238278
def parsefile(self, filename):
        
        with open(filename, 'rb') as fd:
            return self.parse(fd.read())
994666
def parse(self, filename: str, language: str = None, contents: str = None,
              timeout: float = None) -> CompatParseResponse:

        

        return self._parse(filename, language, contents, timeout,
                           Mode.Value('ANNOTATED'))
1004524
private void load(String filename)
	{
		try
		{
			load(new FileInputStream(filename));
		}
		catch (FileNotFoundException e)
		{
			e.printStackTrace();
		}
	}
41928
def _load_class_names(self, filename, dirname):
        
        full_path = osp.join(dirname, filename)
        classes = []
        with open(full_path, 'r') as f:
            classes = [l.strip() for l in f.readlines()]
        return classes
717298
def loadInputs(self, filename, cols = None, everyNrows = 1,
                   delim = ' ', checkEven = 1):
        
        self.loadInputsFromFile(filename, cols, everyNrows,
                                delim, checkEven)
290676
def _load_from_configs(self, filename):
    
    config_filename = os.path.join(self._config_path, filename)
    if os.path.exists(config_filename):
      try:
        f = open(config_filename, 'r')
        content = ''.join(f.readlines())
        f.close()
        return content
      except Exception as err:
        raise err
    else:
      raise IOError("File not found: {}".format(config_filename))
1039104
def add_file(self, filename):
        
        with (open(filename, 'rb')) as f:
            data = f.read()
        # below won't handle the same name files
        # in different paths
        fname = os.path.basename(filename)
        self.files[fname] = base64.b64encode(data)
1171134
def load(self, filename=None):
        """"""
        assert not self.__flag_loaded, "File can be loaded only once"
        if filename is None:
            filename = self.default_filename
        assert filename is not None, \
            "{0!s} class has no default filename".format(self.__class__.__name__)

        # Convention: trying to open empty file is an error,
        # because it could be of (almost) any type.

        size = os.path.getsize(filename)
        if size == 0:
            raise RuntimeError("Empty file: '{0!s}'".format(filename))

        self._test_magic(filename)
        self._do_load(filename)
        self.filename = filename
        self.__flag_loaded = True
142410
def load(filename):
        
        # parse a zipped file
        if zipfile.is_zipfile(filename):
            zfile = zipfile.ZipFile(filename, 'r')
            try:
                xml = ElementTree.fromstring(zfile.read('scaffold.xml'))
            except StandardError:
                logger.exception('Failed to load scaffold: {0}'.format(filename))
                zfile.close()
                return None
            zfile.close()

        # parse a standard xml file
        else:
            try:
                xml = ElementTree.parse(filename).getroot()
            except StandardError:
                logger.exception('Failed to load scaffold: {0}'.format(filename))
                return None

        # generate a scaffold
        scaffold = Scaffold()
        scaffold.setSource(filename)
        scaffold.setName(xml.get('name', 'Missing'))
        scaffold.setGroup(xml.get('group', 'Default'))
        scaffold.setLanguage(xml.get('lang', 'Python'))
        scaffold.setIcon(xml.get('icon', ''))

        # define properties
        xprops = xml.find('properties')
        if xprops is not None:
            for xprop in xprops:
                scaffold.addProperty(Property.fromXml(xprop))

        return scaffold
46721
def parse(self, filename):
        
        with io.open(filename, 'r', encoding='utf-8') as _:
            lines = _.readlines()

        all_source_files = set()
        source_map = {}

        lineno = 0
        root = None
        index = None
        cur_level = -1
        parent_queue = []

        for line in lines:
            try:
                level, line = dedent(line)
                if line.startswith('#'):
                    lineno += 1
                    continue
                elif line.startswith('\\#'):
                    line = line[1:]
            except IndentError as exc:
                error('bad-indent', 'Invalid indentation', filename=filename,
                      lineno=lineno, column=exc.column)

            if not line:
                lineno += 1
                continue

            source_file = dequote(line)

            if not source_file:
                lineno += 1
                continue

            if source_file in all_source_files:
                error('sitemap-duplicate', 'Filename listed twice',
                      filename=filename, lineno=lineno, column=level * 8 + 1)

            all_source_files.add(source_file)
            source_map[source_file] = (lineno, level * 8 + 1)

            page = OrderedDict()

            if root is not None and level == 0:
                error('sitemap-error', 'Sitemaps only support one root',
                      filename=filename, lineno=lineno, column=0)

            if root is None:
                root = page
                index = source_file
            else:
                lvl_diff = cur_level - level
                while lvl_diff >= 0:
                    parent_queue.pop()
                    lvl_diff -= 1

                parent_queue[-1][source_file] = page

            parent_queue.append(page)

            cur_level = level

            lineno += 1

        return Sitemap(root, filename, index, source_map)
1332957
def parse_file(self, file_or_fname):
        
        with self._context():
            if hasattr(file_or_fname, 'read'):
                self.filename = getattr(
                    file_or_fname, 'name', file_or_fname.__class__.__name__)
                self.p.ParseFile(file_or_fname)
            else:
                self.filename = file_or_fname
                with open(file_or_fname, 'rb') as f:
                    self.p.ParseFile(f)
        return self._root
965291
def load(cls, filename, schema_only=False):
        
        o = open(filename)
        s = o.read()
        a = cls.parse(s, schema_only=schema_only)
        if not schema_only:
            a._filename = filename
        o.close()
        return a
1231682
def load_config(filename):
    

    if filename is None:
        filename = ''

    abs_filename = os.path.join(os.getcwd(), filename)

    global FILE

    # find the config file
    if os.path.isfile(filename):
        FILE = filename
    elif os.path.isfile(abs_filename):
        FILE = abs_filename
    elif os.path.isfile(FILE):
        pass
    else:
        if os.path.dirname(filename):
            file_not_found = filename
        else:
            file_not_found = abs_filename
        file_not_found_message(file_not_found)

    # load config
    init(FILE)
1001591
def load(self, filename):
        
        dir_name = os.path.dirname(filename)
        mod_name = os.path.basename(filename).split('.')[0]
        self.filename = mod_name
        sys.path.insert(0, dir_name)
        mod = __import__(mod_name)
        sys.path.remove(dir_name) # do not pollute the path.
        pipers, xtras, pipes = mod.pipeline()
        self.add_pipers(pipers, xtras)
        self.add_pipes(pipes)