Given a xml config file, return the corresponding json
object if it exists.
549944
private Object convertFile(Object name) throws IOException, JSONException{
    if (name instanceof String) {
      String file = (String) name;
      JSONObject json = getJsonConfig(file);
      if (json!=null) {
        return json;
      }
    } else if (name instanceof Path) {
        Path file = (Path)name;
        JSONObject json = getJsonConfig(file);
        if (json != null) {
          return json;
        }
    } 
    return name;
  }
106711
def load_config(filename):
    '''
    
    '''
    try:
        with open(filename, 'r') as config_file:
            return json.loads(config_file.read())
    except IOError:
        pass
154823
def load_json(file, new_root_dir=None, decompression=False):
    """"""
    if decompression:
        with open(file, 'rb') as f:
            my_object = load(f, decompression=decompression)
    else:
        with open(file, 'r') as f:
            my_object = load(f, decompression=decompression)
    if new_root_dir:
        my_object.root_dir = new_root_dir

    return my_object
1310033
def loadJson(self, filename):
        
        jsonConfig = {}
        if os.path.isfile(filename):
            jsonConfig = json.loads(' '.join(open(filename, 'r').readlines()))
        return jsonConfig
865405
def config_load(ctx, param, value):
    """"""
    if ctx.obj is None:
        ctx.obj = {}

    ctx.obj['config_path'] = value
    ctx.obj['config'] = read_config(value)
    return value
721984
def read_json(self):
        
        with reading_ancillary_files(self):
            if self.json_uri is None:
                metadata = self._read_json_db()
            else:
                metadata = self._read_json_file()
            if 'properties' in metadata:
                for name, prop in list(metadata['properties'].items()):
                    try:
                        self.set(prop['name'], prop['value'], prop['xml_path'])
                    except KeyError:
                        # we just skip if we don't have something, we want
                        # to have as much as possible read from the JSON
                        pass
        return metadata
1270989
def _retrieve(self, config_file=None):
        """"""
        with open(config_file or _DEFAULT_PATH, 'r') as f:
            creds = json.load(f)
        self._key = creds.get('key')
        self._base_url = creds.get('base_url')
        self._username = creds.get('username')
1249334
def load_config(name, base='conf'):
    """"""
    fname = pjoin(base, name + '.json')
    if not os.path.exists(fname):
        return {}
    try:
        with open(fname) as f:
            cfg = json.load(f)
    except Exception as e:
        warn("Couldn't load %s: %s" % (fname, e))
        cfg = {}
    return cfg
202373
def _load_json_config(self):
        
        try:
            return json.loads(self._read_config())
        except ValueError as error:
            raise ValueError(
                'Could not read configuration file: {}'.format(error))
235769
def load_config():
    

    configfile = get_configfile()

    if not os.path.exists(configfile):
        data = {
            'apikey': 'GET KEY AT: https://www.filemail.com/apidoc/ApiKey.aspx'
            }

        save_config(data)

    with open(configfile, 'rb') as f:
        return json.load(f)
642554
def load_xml_conf(self, xml_file, id):
        '''
        
        '''

        # converting nutch-site.xml to key:value pairs
        import xml.etree.ElementTree as ET
        tree = ET.parse(xml_file)
        params = {}
        for prop in tree.getroot().findall(".//property"):
            params[prop.find('./name').text.strip()] = prop.find('./value').text.strip()
        return self.proxy.Configs().create(id, configData=params)
615173
def load_config(self):
        
        conf_file = os.path.join(self._conf_dir, "dql.json")
        if not os.path.exists(conf_file):
            return {}
        with open(conf_file, "r") as ifile:
            return json.load(ifile)
1081343
def get_json(self, path, watch=None):
        """"""
        data, _ = self.get(path, watch)
        return load_json(data) if data else None
305958
def json(self):
        """"""
        attributes = {
            'type': self.type,
            'filename': self.filename,
            'line_number': self.lineno,
            'hashed_secret': self.secret_hash,
        }

        if self.is_secret is not None:
            attributes['is_secret'] = self.is_secret

        return attributes
1187085
def parse_config_file(config_file_path):
  
  extension = os.path.splitext(config_file_path)[1]
  if extension == '.pyc':
    raise ValueError("Skipping .pyc file as config")
  if extension == '.json':
    with open(config_file_path) as config_file:
      try:
        mapping = json.load(config_file)
      except ValueError as e:
        logger.error("Did not load json configs", e)
        raise SyntaxError('Unable to parse config file:%s due to malformed JSON. Aborting' %(config_file_path))
  elif extension == '.py':
    mapping = {}
    file_dict = load_module(config_file_path)
    for attr_name in dir(file_dict):
      if not (attr_name.startswith('_') or attr_name.startswith('__')):
        attr = getattr(file_dict, attr_name)
        if type(attr) is dict:
          mapping.update(attr)
  else:
    with open(config_file_path) as config_file:
      lines = [line.rstrip() for line in config_file if line.rstrip() != "" and not line.startswith("#")]
      mapping = parse_config_list(lines)

  return mapping
579202
def parse(string, is_file=False, obj=False):
        
        try:
            if obj is False:
                if is_file:
                    return system_json.load(string)
                return system_json.loads(string, encoding='utf8')
            else:
                if is_file:
                    return system_json.load(
                        string,
                        object_hook=lambda d: namedtuple('j', d.keys())
                        (*d.values()), ensure_ascii=False, encoding='utf8')
                return system_json.loads(
                    string,
                    object_hook=lambda d: namedtuple('j', d.keys())
                    (*d.values()), encoding='utf8')
        except (Exception, BaseException) as error:
            try:
                if current_app.config['DEBUG']:
                    raise error
            except RuntimeError as flask_error:
                raise error
            return None
1051763
def parsed_file(config_file):
    """"""
    parser = ConfigParser(allow_no_value=True)
    parser.readfp(config_file)
    return parser