read a file and inject a string of swagger (str, str) -> null
482
function useMain (mdFile, swagger) {
  const mainOpts = {
    position: argv.position,
    title: argv.title
  }
  opts.yaml ? mainOpts.yaml = true : mainOpts.json = true

  fs.readFile(mdFile, { encoding: 'utf8' }, function (err, md) {
    assert.ifError(err)
    const compiled = remark()
      .use(main(swagger, mainOpts))
      .process(md)

    const rs = fromString(compiled)
    const ws = argv.w ? fs.createWriteStream(mdFile) : stdout
    pump(rs, ws, handleErr)
  })
}
1296884
static Swagger validate( File jsonFile ) throws Exception {

		// Validate with the Swagger parser
		SwaggerDeserializationResult res = new SwaggerParser().readWithInfo( jsonFile.getAbsolutePath(), null, true );
		if( ! res.getMessages().isEmpty()) {
			for( String s : res.getMessages())
				System.out.println( s );

			throw new Exception( "Errors were found in a Swagger definition: " + jsonFile.getAbsolutePath());
		}

		return res.getSwagger();
	}
766938
def main(source):
    
    if source is None:
        click.echo(
            "You need to supply a file or url to a schema to a swagger schema, for"
            "the validator to work."
        )
        return 1
    try:
        load(source)
        click.echo("Validation passed")
        return 0
    except ValidationError as e:
        raise click.ClickException(str(e))
677662
def load(cls, filename):
        
        jobject = javabridge.static_call(
            "weka/experiment/Experiment", "read", "(Ljava/lang/String;)Lweka/experiment/Experiment;",
            filename)
        return Experiment(jobject=jobject)
351922
function readFile(file) {

    if (file && fs.existsSync(file)) {
        return fs.readFileSync(file);
    }

    return null;
}
534680
private Object _readJson(String path) throws ZooKeeperException {
        String jsonString = getData(path);
        try {
            return jsonString != null ? SerializationUtils.fromJsonString(jsonString) : null;
        } catch (Exception e) {
            if (e instanceof ZooKeeperException) {
                throw (ZooKeeperException) e;
            } else {
                throw new ZooKeeperException(e);
            }
        }
    }
294635
function fileReader(moduleMeta) {
  // Read file from disk and return a module meta
  return pstream(readFile(moduleMeta.path))
    .then(function(text) {
      return {
        source: text
      };
    }, log2console);
}
920358
async function readFile(path, encoding) {
	const url = browser.extension.getURL(realpath(path));

	return new Promise((resolve, reject) => {
		const xhr = new global.XMLHttpRequest;
		xhr.responseType = encoding == null ? 'arraybuffer' : 'text';
		xhr.addEventListener('load', () => resolve(xhr.response));
		xhr.addEventListener('error', reject);
		xhr.open('GET', url);
		xhr.send();
	});
}
289991
private String loadfromFromFile(String queryName) throws IllegalStateException {
		try (final InputStream is = getClass().getResourceAsStream(scriptsFolder + queryName + ".sql");) {
		    String sql = StringUtils.join(IOUtils.readLines(is, StandardCharsets.UTF_8), IOUtils.LINE_SEPARATOR);
		    
		    // Look for tokens
		    final String[] tokens = StringUtils.substringsBetween(sql, "${", "}");
		    if (tokens != null && tokens.length > 0) {
    		    final Map<String, String> values = Arrays.stream(tokens).collect(Collectors.toMap(
    	            Function.identity(),
    	            this::load,
    	            (o, n) -> o
    	        ));
		    
		        sql = StrSubstitutor.replace(sql, values);
		    }
		    
			return sql;
		} catch (Exception e) {
			throw new IllegalStateException("Could not load query " + scriptsFolder + queryName, e);
		}
	}
392138
def load_stream(filename):
    """"""
    rawfile = pkg_resources.resource_stream(__name__, filename)
    if six.PY2:
        return rawfile
    return io.TextIOWrapper(rawfile, 'utf-8')
1152565
function readfile(fullpath, options, cb) {
    if (2 === arguments.length) { cb = options; }
    get(self.endpoint + '/contents' + fullpath + self.refparam, function(err, json) {
      if (err) return cb(err);
      cb(null, Buffer.from(json.content, 'base64'));
    });
  }
944448
function init(app, context, swagger) {
        logger.log('debug', '%s|adding|routes|context=%s', meta.module, context, meta);
        if (swagger) {
            describeModels(swagger);
            swagger.addPost({
                'spec': {
                    "path" : context + format + '/lex/phrase', 
                    "notes" : "To use only the lexer to tokenize a phrase. The output of the lexer can be pass directly to the tokenizer.",
                    "method": "POST",
                    "summary" : "Split a phrase into tokens.",
                    "nickname" : "lexer",
                    "responseClass" : "Tokens",
                    "params" : [
                        swagger.params.post("phrase", "A phrase to be tokenized", '{"phrase":"Hello world"}'),
                    ],
                    "errorResponses" : [
                        swagger.errors.notFound('phrase'),
                        swagger.errors.invalid('phrase')
                    ]
                },
                'action': function(req, res) {
                    if (!req.body)
                        throw swagger.error(400, 'Missing body of the request');
                    if (!req.body.phrase)
                        throw swagger.error(400, 'Missing the "phrase" in the body of the request');
                    pos.rest.lexPhrase(req, res);
                }
            }).addPost({
                'spec': {
                    "path" : context + format + '/tag/words',
                    "notes" : "To use the tagger on a list of tokens.",
                    "method": "POST",
                    "summary" : "Tag each tokenized word.",
                    "nickname" : "word-tagger",
                    "responseClass" : "Tags",
                    "params" : [
                        swagger.params.post("words", "A list of tokenized words to be tagged", '{"words":["hello","world"]}'),
                    ],
                    "errorResponses" : [
                        swagger.errors.notFound('words'),
                        swagger.errors.invalid('words')
                    ]
                },
                'action': function(req, res) {
                    if (!req.body)
                        throw swagger.error(400, 'Missing body of the request');
                    if (!req.body.words)
                        throw swagger.error(400, 'Missing the "words" array in the body of the request');
                    pos.rest.tagWords(req, res);
                }
            }).addPost({
                'spec': {
                    "path" : context + format + '/tag/phrase',
                    "notes" : "Use the lexer on the phrase and, tag the resulting tokens.",
                    "method": "POST",
                    "summary" : "Tokenize a phrase and then tag each token.",
                    "nickname" : "tagger",
                    "responseClass" : "Tags",
                    "params" : [
                        swagger.params.post("phrase", "A phrase to be tokenized and tagged", '{"phrase":"Hello world"}'),
                    ],
                    "errorResponses" : [
                        swagger.errors.notFound('phrase'),
                        swagger.errors.invalid('phrase')
                    ]
                },
                'action': function(req, res) {
                    if (!req.body)
                        throw swagger.error(400, 'Missing body of the request');
                    if (!req.body.phrase)
                        throw swagger.error(400, 'Missing the "phrase" in the body of the request');
                    pos.rest.tagPhrase(req, res);
                }
            });
        } else {
            router.add(app, context + '/pos.json/lex/phrase', 'POST', pos.rest.lexPhrase);
            router.add(app, context + '/pos.json/tag/words',  'POST', pos.rest.tagWords);
            router.add(app, context + '/pos.json/tag/phrase', 'POST', pos.rest.tagPhrase);
        }
    }
500711
async function parseDocument(rawData) {
  try {
    return utils.unthrowableParseJson(rawData) || SwaggerParser.YAML.parse(rawData);
  } catch (err) {
    return null;
  }
}
980433
function inferFileMetadata (file) {
  file.mimeType = lowercase(mime.lookup(file.url) || null);
  file.encoding = lowercase(mime.charset(file.mimeType) || null);
}
360510
def load(filename: str, format: str = None):
    """"""

    path = Path(filename).resolve()

    with path.open() as file:
        data = file.read()

    if format is None:
        loader, error_class = _load_autodetect, InvalidMofileFormat
    else:
        try:
            loader, error_class = formats[format]
        except KeyError:
            raise InvalidMofileFormat(f'Unknown file format: {format}')

    try:
        config = loader(data)
    except error_class as e:
        raise InvalidMofileFormat(f'Unable to load task file: {e}')

    return Project(config, path.parent)
375201
def _read(self, directory, filename, session, path, name, extension,
              spatial=None, spatialReferenceID=None, replaceParamFile=None):
        
        yml_events = []
        with open(path) as fo:
            yml_events = yaml.load(fo)

        for yml_event in yml_events:
            if os.path.exists(os.path.join(directory, yml_event.subfolder)):
                orm_event = yml_event.as_orm()
                if not self._similar_event_exists(orm_event.subfolder):
                    session.add(orm_event)
                    self.events.append(orm_event)

        session.commit()
1132121
def load_swagger_json(swagger_json, ptr_str="$ref"):
        
        refs = []

        def store_refs(d):
            if len(d) == 1 and ptr_str in d:
                refs.append(d)
            return d

        swagger_content = json.load(swagger_json, object_hook=store_refs)
        for ref in refs:
            _, target = ref.popitem()
            assert target[0] == "#"
            ref.update(resolve_pointer(swagger_content, target[1:]))
        return swagger_content