Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Clear solution solution in Clear category for YAML. More Types by joseke
"""
This whole function works on gradually adding more modules for specific tests that have been failed
"""
def yaml(inp):
out={}
for item in inp.split("\n") :
if item!="":
item=item.replace("\"","")
item=item.replace("\\","\"")
if item[item.find(":")+2:]=="" or item[item.find(":")+2:]=="null":#deals with null
out[item[:item.find(":")]]=None
elif item[item.find(":")+2:]=="true":#deals with true
out[item[:item.find(":")]]=True
elif item[item.find(":")+2:]=="false":#deals with false
out[item[:item.find(":")]]=False
else:
try:
out[item[:item.find(":")]]=int(item[item.find(":")+2:])#deals with ints
except:
out[item[:item.find(":")]]=item[item.find(":")+2:].strip()#deals with strings that arent the previous instances
return dict([(item,out[item]) for item in sorted(list(out.keys()),key=lambda item1: (str(isinstance(out[item1],int)),item1))])
#Because dictionaries are inherently unordered I instead sort the list of dict keys by their data type before defult sorting the rest.
#It then returns a list of tuple which I convert back into a dictionary to return.
July 31, 2020