Parse an file into a OpenAPI Schema model.
770964
public function parseSchema(string $openApiSpecPath): OpenApi
    {
        $openApiSpecContents = file_get_contents($openApiSpecPath);
        $jsonException = null;
        $yamlException = null;

        try {
            return $this->deserialize($openApiSpecContents, $openApiSpecPath);
        } catch (\Exception $exception) {
            $jsonException = $exception;
        }

        try {
            $content = Yaml::parse(
                $openApiSpecContents,
                Yaml::PARSE_OBJECT | Yaml::PARSE_OBJECT_FOR_MAP | Yaml::PARSE_DATETIME | Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE
            );

            return $this->denormalize($content, $openApiSpecPath);
        } catch (YamlException $yamlException) {
            throw new \LogicException(sprintf(
                "Could not parse schema in JSON nor YAML format:\n- JSON error: \"%s\"\n- YAML error: \"%s\"\n",
                $jsonException->getMessage(),
                $yamlException->getMessage()
            ));
        }
    }
247668
def metamodel_from_file(file_name, **kwargs):
    
    with codecs.open(file_name, 'r', 'utf-8') as f:
        lang_desc = f.read()

    metamodel = metamodel_from_str(lang_desc=lang_desc,
                                   file_name=file_name,
                                   **kwargs)

    return metamodel
980598
def parse(self, file_obj, parsed_files=None):
        '''
        
        '''
        host = {'host': ['*'], 'config': {}}
        for line in file_obj:
            # Strip any leading or trailing whitespace from the line.
            # Refer to https://github.com/paramiko/paramiko/issues/499
            line = line.strip()
            if not line or line.startswith('#'):
                continue

            match = re.match(self.SETTINGS_REGEX, line)
            if not match:
                raise Exception('Unparsable line {}'.format(line))
            key = match.group(1).lower()
            value = match.group(2)

            if key == 'host':
                self._config.append(host)
                host = {
                    'host': self._get_hosts(value),
                    'config': {}
                }
            elif key == 'proxycommand' and value.lower() == 'none':
                # Store 'none' as None; prior to 3.x, it will get stripped out
                # at the end (for compatibility with issue #415). After 3.x, it
                # will simply not get stripped, leaving a nice explicit marker.
                host['config'][key] = None
            elif key == 'include':
                # support for Include directive in ssh_config
                path = value
                # the path can be relative to its parent configuration file
                if os.path.isabs(path) is False and path[0] != '~':
                    folder = os.path.dirname(file_obj.name)
                    path = os.path.join(folder, path)

                # expand the user home path
                path = os.path.expanduser(path)
                if parsed_files is None:
                    parsed_files = []

                # parse every included file
                for filename in glob.iglob(path):
                    if os.path.isfile(filename):
                        if filename in parsed_files:
                            raise Exception('Include loop detected in ssh config file: %s' % filename)
                        with open(filename) as fd:
                            parsed_files.append(filename)
                            self.parse(fd, parsed_files)

            else:
                if value.startswith('"') and value.endswith('"'):
                    value = value[1:-1]

                # identityfile, localforward, remoteforward keys are special
                # cases, since they are allowed to be specified multiple times
                # and they should be tried in order of specification.
                if key in ['identityfile', 'localforward', 'remoteforward']:
                    if key in host['config']:
                        host['config'][key].append(value)
                    else:
                        host['config'][key] = [value]
                elif key not in host['config']:
                    host['config'][key] = value
        self._config.append(host)
150535
def parse(data)
      REQUIRED_FIELDS.each do |field|
        if !data[field]
          raise ArgumentError, "Committee: no #{field} section in spec data."
        end
      end

      if data['swagger'] != '2.0'
        raise ArgumentError, "Committee: driver requires OpenAPI 2.0."
      end

      schema = Schema.new
      schema.driver = self

      schema.base_path = data['basePath'] || ''

      # Arbitrarily choose the first media type found in these arrays. This
      # appraoch could probably stand to be improved, but at least users will
      # for now have the option of turning media type validation off if they so
      # choose.
      schema.consumes = data['consumes'].first
      schema.produces = data['produces'].first

      schema.definitions, store = parse_definitions!(data)
      schema.routes = parse_routes!(data, schema, store)

      schema
    end
1120839
def parse_from_file(filename, nodata=False):
    
    header = None
    with open(filename, "rb") as file:
        header = read_machine_header(file)
        meta_raw = file.read(header['meta_len'])
        meta = __parse_meta(meta_raw, header)
        data = b''
        if not nodata:
            data = __decompress(meta, file.read(header['data_len']))

        return header, meta, data
120440
def from_file(path):
        """"""
        with open(path) as stream:
            obj = yaml.safe_load(stream)
        Config.lint(obj)
        return Config(config_dict=obj)
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
1187149
def Parse(self, stat, file_object, knowledge_base):
    """"""
    _, _ = stat, knowledge_base
    lines = [
        l.strip()
        for l in utils.ReadFileBytesAsUnicode(file_object).splitlines()
    ]
    for index, line in enumerate(lines):
      user = self.ParseLine(index, line)
      if user is not None:
        yield user
1046362
def _parse(self, source, name, filename):
        """"""
        return Parser(self, source, name, encode_filename(filename)).parse()
1052045
def from_file(cls, path, encoding, dialect, fields, converters, field_index):
        """"""

        return cls(open(path, 'r', encoding=encoding), dialect, fields, converters, field_index)
309705
function parser(file, callback) {
  // file exit conditions
  if(file.isNull()) {
    return callback(null, file); // pass along
  }

  if(file.isStream()) {
    return callback(new Error('Streaming not supported'));
  }

  try {

    var
      /** @type {string} */
      text     = String(file.contents.toString('utf8')),
      lines    = text.split('\n'),
      filename = file.path.substring(0, file.path.length - 4),
      key      = 'server/documents',
      position = filename.indexOf(key)
    ;

    // exit conditions
    if(!lines) {
      return;
    }
    if(position < 0) {
      return callback(null, file);
    }

    filename = filename.substring(position + key.length + 1, filename.length);

    var
      lineCount = lines.length,
      active    = false,
      yaml      = [],
      categories = [
        'UI Element',
        'UI Global',
        'UI Collection',
        'UI View',
        'UI Module',
        'UI Behavior'
      ],
      index,
      meta,
      line
    ;

    for(index = 0; index < lineCount; index++) {

      line = lines[index];

      // Wait for metadata block to begin
      if(!active) {
        if(startsWith(line, '---')) {
          active = true;
        }
        continue;
      }
      // End of metadata block, stop parsing.
      if(startsWith(line, '---')) {
        break;
      }
      yaml.push(line);
    }


    // Parse yaml.
    meta = YAML.parse(yaml.join('\n'));
    if(meta && meta.type && meta.title && inArray(meta.type, categories) ) {
      meta.category = meta.type;
      meta.filename = filename;
      meta.url      = '/' + filename;
      meta.title    = meta.title;
      // Primary key will by filepath
      data[meta.element] = meta;
    }
    else {
      // skip
      // console.log(meta);
    }


  }

  catch(error) {
    console.log(error, filename);
  }

  callback(null, file);

}
449610
def parse_file(self, filename, encoding=None, debug=False):
        """"""
        stream = codecs.open(filename, "r", encoding)
        try:
            return self.parse_stream(stream, debug)
        finally:
            stream.close()
355914
def _parse_rdf(self, file):
        
        store = Graph()
        store.parse(file)

        print len(store)
1093962
def parse_file(self, inputstring, addhash=True):
        """"""
        if addhash:
            use_hash = self.genhash(False, inputstring)
        else:
            use_hash = None
        return self.parse(inputstring, self.file_parser, {"nl_at_eof_check": True}, {"header": "file", "use_hash": use_hash})
1353808
def _parse_file(self):
        """"""

        # We need to set the CPU type to pull in the right register definitions
        # only preprocess the file (-E) and get rid of gcc extensions that aren't
        # supported in ISO C.
        args = utilities.build_includes(self.arch.includes())

        # args.append('-mcpu=%s' % self.arch.property('chip'))
        args.append('-E')
        args.append('-D__attribute__(x)=')
        args.append('-D__extension__=')
        self.ast = parse_file(self.filepath, use_cpp=True, cpp_path='arm-none-eabi-gcc', cpp_args=args)
935961
def parse_files(self, req, name, field):
        """"""
        files = ((k, v) for k, v in req.POST.items() if hasattr(v, "file"))
        return core.get_value(MultiDict(files), name, field)
472008
private void parseFile(File schemaSourceFile, CourierParseResult result)
      throws IOException
  {
    if (wasResolved(schemaSourceFile))
    {
      return;
    }

    final List<DataSchema> schemas = parseSchema(schemaSourceFile, result);

    for (DataSchema schema : schemas)
    {
      validateSchemaWithFilePath(schemaSourceFile, schema);
      result.getSchemaAndLocations().put(schema, new FileDataSchemaLocation(schemaSourceFile));
      result.getSourceFiles().add(schemaSourceFile);
    }
  }