Exemplo n.º 1
0
 def read_string(self, json_string, description=None, section=None, **kwargs):
     '''Parse a complete or partial configuration.
     
     Parameters
     ----------
     json_string : string
         Input to parse.
     description : Description, optional
         Where to put the parsed configuration.  If None a new one is created.
     section : string, optional
         Where to put the parsed configuration within the description.
     
     Returns
     -------
     Description
         The input description with parsed configuration added.
     
     Section is only specified for "bare" objects that are to be added to a section array.
     '''
     if description == None:
         description = Description()
     
     data = JsonUtil.read_json_string(json_string)
     
     description.unpack(data, section)
     
     return description
Exemplo n.º 2
0
 def from_json_string(self, json_string):
     '''Read a configuration from a JSON format string.
     
     Parameters
     ----------
     json_string : string
         A JSON-formatted string containing an application configuration.
     
     Returns
     -------
     string
         An application configuration in INI format
     '''
     description = JsonUtil.read_json_string(json_string)
     
     return self.to_config_string(description)
Exemplo n.º 3
0
 def from_json_file(self, json_path):
     '''Read an application configuration from a JSON format file.
     
     Parameters
     ----------
     json_path : string
         Path to the JSON file.
     
     Returns
     -------
     string
         An application configuration in INI format
     
     '''
     description = JsonUtil.read_json_file(json_path)
     
     return self.to_config_string(description)