Parses a Disgenet file ad the one that can be downloaded from
http://www.disgenet.org/ds/DisGeNET/results/all_gene_disease_associations.tar.gz and writes corresponding json
objects.
146
public void parse() {
        Map<String, Disgenet> disgenetMap = new HashMap<>();

        BufferedReader reader;
        try {
            // Disgenet file is usually downloaded as a .tar.gz file
            if (disgenetFilePath.toFile().getName().endsWith("tar.gz")) {
                TarArchiveInputStream tarInput = new TarArchiveInputStream(
                        new GzipCompressorInputStream(new FileInputStream(disgenetFilePath.toFile())));
//                TarArchiveEntry currentEntry = tarInput.getNextTarEntry();
//                BufferedReader br = null;
                reader = new BufferedReader(new InputStreamReader(tarInput)); // Read directly from tarInput
            } else {
                reader = FileUtils.newBufferedReader(disgenetFilePath);
            }
//            if (disgenetFilePath.toFile().getName().endsWith("txt.gz")) {
//                reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(disgenetFilePath.toFile()))));
//            } else {
//                reader = Files.newBufferedReader(disgenetFilePath, Charset.defaultCharset());
//            }

            logger.info("Parsing Disgenet file " + disgenetFilePath + " ...");
            // first line is the header -> ignore it
            reader.readLine();
            long processedDisgenetLines = fillDisgenetMap(disgenetMap, reader);

            logger.info("Serializing parsed variants ...");
            Collection<Disgenet> allDisgenetRecords = disgenetMap.values();
            for (Disgenet disGeNetRecord : allDisgenetRecords) {
                serializer.serialize(disGeNetRecord);
            }
            logger.info("Done");
            this.printSummary(processedDisgenetLines, allDisgenetRecords.size());

        } catch (FileNotFoundException e) {
            logger.error("Disgenet file " + disgenetFilePath + " not found");
        } catch (IOException e) {
            logger.error("Error reading Disgenet file " + disgenetFilePath + ": " + e.getMessage());
        }
    }
738004
def read_dist_egginfo_json(dist, filename=DEFAULT_JSON):
    

    # use the given package's distribution to acquire the json file.
    if not dist.has_metadata(filename):
        logger.debug("no '%s' for '%s'", filename, dist)
        return

    try:
        result = dist.get_metadata(filename)
    except IOError:
        logger.error("I/O error on reading of '%s' for '%s'.", filename, dist)
        return

    try:
        obj = json.loads(result)
    except (TypeError, ValueError):
        logger.error(
            "the '%s' found in '%s' is not a valid json.", filename, dist)
        return

    logger.debug("found '%s' for '%s'.", filename, dist)
    return obj
590028
def _read_json_file(self):
        
        with open(self.json_uri) as metadata_file:
            try:
                metadata = json.load(metadata_file)
                return metadata
            except ValueError:
                message = tr('the file %s does not appear to be valid JSON')
                message = message % self.json_uri
                raise MetadataReadError(message)
880421
private Map<String, DependencyInfo> parseDepsFiles() throws IOException {
    DepsFileParser depsParser = createDepsFileParser();
    Map<String, DependencyInfo> depsFiles = new LinkedHashMap<>();
    for (SourceFile file : deps) {
      if (!shouldSkipDepsFile(file)) {
        List<DependencyInfo>
            depInfos = depsParser.parseFileReader(
                file.getName(), file.getCodeReader());
        if (depInfos.isEmpty()) {
          reportNoDepsInDepsFile(file.getName());
        } else {
          for (DependencyInfo info : depInfos) {
            depsFiles.put(info.getPathRelativeToClosureBase(), removeRelativePathProvide(info));
          }
        }
      }
    }

    // If a deps file also appears in srcs, our build tools will move it
    // into srcs.  So we need to scan all the src files for addDependency
    // calls as well.
    for (SourceFile src : srcs) {
      if (!shouldSkipDepsFile(src)) {
        List<DependencyInfo> srcInfos =
            depsParser.parseFileReader(src.getName(), src.getCodeReader());
        for (DependencyInfo info : srcInfos) {
          depsFiles.put(info.getPathRelativeToClosureBase(), removeRelativePathProvide(info));
        }
      }
    }

    return depsFiles;
  }
520062
def read_json(directory, data_files='data/js/tweets/*.js'):
    '''
    
    '''
    files = path.join(directory, data_files)

    for fname in iglob(files):
        with open(fname, 'r') as f:
            # Twitter's JSON first line is bogus
            data = f.readlines()[1:]
            data = "".join(data)
            tweetlist = json.loads(data)

        for tweet in tweetlist:
            yield tweet
745025
function parseMerkleDAG(dagNode) {
  const parsed = dagNode.toJSON()
  // add relevant data
  parsed.isDir = isDir(parsed.data)
  // remove irrelevant data
  delete parsed.data
  if (!parsed.isDir) {
    // if it's a big file it will have links to its other chunks
    delete parsed.links
  }
  return parsed
}
293549
private Feature[] parseForFeature(String jsonFile) {
        try (Reader reader = new InputStreamReader(new FileInputStream(jsonFile), StandardCharsets.UTF_8)) {
            Feature[] features = mapper.readValue(reader, Feature[].class);
            if (ArrayUtils.isEmpty(features)) {
                LOG.log(Level.INFO, "File '{}' does not contain features", jsonFile);
            }
            return features;
        } catch (JsonMappingException e) {
            throw new ValidationException(String.format("File '%s' is not proper Cucumber report!", jsonFile), e);
        } catch (IOException e) {
            // IO problem - stop generating and re-throw the problem
            throw new ValidationException(e);
        }
    }
1220477
private static void parseRenameFile(List<String> lines, URL url, Map<Class<?>, SerDeserializer> map) {
        // format allows multiple [deserializers] so file can be merged
        boolean deserializers = false;
        for (String line : lines) {
            try {
                if (line.equals("[deserializers]")) {
                    deserializers = true;
                } else if (deserializers) {
                    int equalsPos = line.indexOf('=');
                    String beanName = equalsPos >= 0 ? line.substring(0, equalsPos).trim() : line;
                    String deserName = equalsPos >= 0 ? line.substring(equalsPos + 1).trim() : line;
                    registerFromClasspath(beanName, deserName, map);
                } else {
                    throw new IllegalArgumentException("JodaBeans.ini must start with [deserializers]");
                }
            } catch (Exception ex) {
                System.err.println("ERROR: Invalid JodaBeans.ini: " + url + ": " + ex.getMessage());
            }
        }
    }
1299372
def from_json(json_file, sync=True, strict=True, use_dummy_io=False, **extra):
    
    with open(json_file) as f:
        config = json.load(f, object_pairs_hook=OrderedDict)

    return from_config(config, sync=sync, strict=strict, use_dummy_io=use_dummy_io, **extra)
1336550
def parse(self, limit=None):
        

        files_to_download, ftp = self._get_file_list(
            self.files['anat_entity']['path'],
            self.files['anat_entity']['pattern'])
        for dlname in files_to_download:
            localfile = '/'.join((self.rawdir, dlname))
            with gzip.open(localfile, 'rt', encoding='ISO-8859-1') as fh:
                LOG.info("Processing %s", localfile)
                self._parse_gene_anatomy(fh, limit)
        return
1083134
def loadjson(filename, asnparrays=False):
    
    with open(filename) as f:
        data = json.load(f)
    if asnparrays:
        for key, value in data.items():
            if type(value) is list:
                data[key] = np.asarray(value)
            if type(value) is dict:
                for key2, value2 in value.items():
                    if type(value2) is list:
                        data[key][key2] = np.asarray(value2)
    return data
434095
function parse(contents, retained, parser) {
    var errors = [], data = [], lines = 0;

    // optional parser
    if (!parser) parser = JSON;

    // process each line of the file
    contents.toString().split('\n').forEach(function(line) {
        if (!line) return;
        lines++;
        try {
            data.push(parser.parse(line));
        } catch (e) {
            e.line = line;
            errors.push(e);
        }
    });

    // if no errors/data, don't return an empty array
    var ret = {};
    if (errors.length) ret.errors = errors;
    if (data.length) ret.data = data;

    // if every line failed, probably not line-delimited
    if (errors.length == lines) ret.errors = retained;

    return ret;
}
988775
def _parse_file(self, file_obj):
        
        byte_data = file_obj.read(self.size)
        self._parse_byte_data(byte_data)
1241544
def from_json(data):
        
        memfiles = InMemoryFiles()
        memfiles.files = json.loads(data)
        return memfiles
821188
def parse(binary, **params):
    """"""
    binary = io.BytesIO(binary)
    collection = list()
    with tarfile.TarFile(fileobj=binary, mode='r') as tar:
        for tar_info in tar.getmembers():
            content_type, encoding = mimetypes.guess_type(tar_info.name)
            content = tar.extractfile(tar_info)
            content = content_encodings.get(encoding).decode(content)
            content = content_types.get(content_type).parse(content, **params)
            collection.apppend((tar_info.name, content))
    return collection
540143
def Parse(self, statentry, file_object, knowledge_base):
    """"""
    _ = knowledge_base
    kwargs = {}
    try:
      kwargs["aff4path"] = file_object.urn
    except AttributeError:
      pass

    direct_copy_items = [
        "Label", "Disabled", "UserName", "GroupName", "Program",
        "StandardInPath", "StandardOutPath", "StandardErrorPath",
        "LimitLoadToSessionType", "EnableGlobbing", "EnableTransactions",
        "OnDemand", "RunAtLoad", "RootDirectory", "WorkingDirectory", "Umask",
        "TimeOut", "ExitTimeOut", "ThrottleInterval", "InitGroups",
        "StartOnMount", "StartInterval", "Debug", "WaitForDebugger", "Nice",
        "ProcessType", "AbandonProcessGroup", "LowPriorityIO", "LaunchOnlyOnce"
    ]

    string_array_items = [
        "LimitLoadToHosts", "LimitLoadFromHosts", "LimitLoadToSessionType",
        "ProgramArguments", "WatchPaths", "QueueDirectories"
    ]

    flag_only_items = ["SoftResourceLimits", "HardResourceLimits", "Sockets"]

    plist = {}

    try:
      plist = biplist.readPlist(file_object)
    except (biplist.InvalidPlistException, ValueError, IOError) as e:
      plist["Label"] = "Could not parse plist: %s" % e

    # These are items that can be directly copied
    for key in direct_copy_items:
      kwargs[key] = plist.get(key)

    # These could be a string, they could be an array, we don't know and neither
    # does Apple so we check.
    for key in string_array_items:
      elements = plist.get(key)
      if isinstance(elements, string_types):
        kwargs[key] = [elements]
      else:
        kwargs[key] = elements

    # These are complex items that can appear in multiple data structures
    # so we only flag on their existence
    for key in flag_only_items:
      if plist.get(key):
        kwargs[key] = True

    if plist.get("inetdCompatability") is not None:
      kwargs["inetdCompatabilityWait"] = plist.get("inetdCompatability").get(
          "Wait")

    keepalive = plist.get("KeepAlive")
    if isinstance(keepalive, bool) or keepalive is None:
      kwargs["KeepAlive"] = keepalive
    else:
      keepalivedict = {}
      keepalivedict["SuccessfulExit"] = keepalive.get("SuccessfulExit")
      keepalivedict["NetworkState"] = keepalive.get("NetworkState")

      pathstates = keepalive.get("PathState")
      if pathstates is not None:
        keepalivedict["PathState"] = []
        for pathstate in pathstates:
          keepalivedict["PathState"].append(
              rdf_plist.PlistBoolDictEntry(
                  name=pathstate, value=pathstates[pathstate]))

      otherjobs = keepalive.get("OtherJobEnabled")
      if otherjobs is not None:
        keepalivedict["OtherJobEnabled"] = []
        for otherjob in otherjobs:
          keepalivedict["OtherJobEnabled"].append(
              rdf_plist.PlistBoolDictEntry(
                  name=otherjob, value=otherjobs[otherjob]))
      kwargs["KeepAliveDict"] = rdf_plist.LaunchdKeepAlive(**keepalivedict)

    envvars = plist.get("EnvironmentVariables")
    if envvars is not None:
      kwargs["EnvironmentVariables"] = []
      for envvar in envvars:
        kwargs["EnvironmentVariables"].append(
            rdf_plist.PlistStringDictEntry(name=envvar, value=envvars[envvar]))

    startcalendarinterval = plist.get("StartCalendarInterval")
    if startcalendarinterval is not None:
      if isinstance(startcalendarinterval, dict):
        kwargs["StartCalendarInterval"] = [
            rdf_plist.LaunchdStartCalendarIntervalEntry(
                Minute=startcalendarinterval.get("Minute"),
                Hour=startcalendarinterval.get("Hour"),
                Day=startcalendarinterval.get("Day"),
                Weekday=startcalendarinterval.get("Weekday"),
                Month=startcalendarinterval.get("Month"))
        ]
      else:
        kwargs["StartCalendarInterval"] = []
        for entry in startcalendarinterval:
          kwargs["StartCalendarInterval"].append(
              rdf_plist.LaunchdStartCalendarIntervalEntry(
                  Minute=entry.get("Minute"),
                  Hour=entry.get("Hour"),
                  Day=entry.get("Day"),
                  Weekday=entry.get("Weekday"),
                  Month=entry.get("Month")))

    yield rdf_plist.LaunchdPlist(**kwargs)
330209
def _parse_gene_coordinates(file):
        
        id_map = {}
        col = ['gene_curie', 'start', 'end', 'strand', 'build']
        if os.path.exists(os.path.join(os.path.dirname(__file__), file)):
            with open(os.path.join(os.path.dirname(__file__), file)) as tsvfile:
                reader = csv.reader(tsvfile, delimiter="\t")
                for row in reader:
                    id_map[row[col.index('gene_curie')]] = {
                        'start': row[col.index('start')],
                        'end': row[col.index('end')],
                        'strand': row[col.index('strand')],
                        'build': row[col.index('build')]
                    }
        return id_map