def read_string(self, python_string, description=None, section=None, **kwargs): '''Read a serialized description from a Python (.pycfg) string. Parameters ---------- python_string : string Python string with a serialized description. Returns ------- Description Configuration object. ''' if description is None: description = Description() header = kwargs.get('header', '') python_string = "%s\n\nallensdk_description = %s" % ( header, python_string) ns = {} code = compile(python_string, 'string', 'exec') exec(code, ns) data = ns['allensdk_description'] description.unpack(data, section) return description
def read_string(self, python_string, description=None, section=None, **kwargs): '''Read a serialized description from a Python (.pycfg) string. Parameters ---------- python_string : string Python string with a serialized description. Returns ------- Description Configuration object. ''' if description == None: description = Description() header = kwargs.get('header', '') python_string = "%s\n\nallensdk_description = %s" % (header, python_string) ns = {} code = compile(python_string, 'string', 'exec') exec(code, ns) data = ns['allensdk_description'] description.unpack(data, section) return description
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 is None: description = Description() data = JsonComments.read_string(json_string) description.unpack(data, section) return description
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 = JsonComments.read_string(json_string) description.unpack(data, section) return description