Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def worksheet_from_json(json_string):
#use jsonlib for read ops because of better performance
#keep simplejson for write ops as it's more robust
worksheet_dict = jsonlib.read(json_string)
worksheet = Worksheet()
for (key, value) in worksheet_dict.iteritems():
if key == "_console_text":
worksheet._console_text = value
elif key == "_usercode_error":
worksheet._usercode_error = value
else:
col_str, row_str = key.split(",")
cell = Cell()
cell._formula = value["formula"]
cell._python_formula = value.get("python_formula")
cell.dependencies = map(tuple, value.get("dependencies", []))
cell.error = value.get("error")
cell._value = value.get("value", undefined)
cell.formatted_value = value["formatted_value"]
worksheet[int(col_str), int(row_str)] = cell
def load(self):
import jsonlib
inp = openCompressed(self.fileName,"rb")
#nodes = json.loads(buf,object_hook=lambda o: TaxaNode(**o) if "idpar" in o else o)
#return dict( ((node.id,node) for node in nodes) )
nodes = {}
for line in inp:
node = jsonlib.read(line.strip(),use_float=True)
nodes[node["id"]] = TaxaNode(**node)
inp.close()
return nodes
def fastloadfile(filename): return jsonlib.read(myopen(filename).read(), use_float=True)
def fastload(file): return jsonlib.read(file.read(), use_float=True)
def fastloads(str): return jsonlib.read(str, use_float=True)
fastdumps = jsonlib.write
def fastload(file): return jsonlib.read(file.read(), use_float=True)
except:
def load(self):
import jsonlib
inp = openCompressed(self.fileName,"rb")
buf = inp.read()
inp.close()
#nodes = json.loads(buf,object_hook=lambda o: TaxaNode(**o) if "idpar" in o else o)
#return dict( ((node.id,node) for node in nodes) )
data = jsonlib.read(buf,use_float=True)
data["nodes"] = dict( ((node["id"],TaxaNode(**node)) for node in data["nodes"]) )
data["merged"] = dict( (item for item in data["merged"]) )
return data