def coloringfromstring(s):
try:<EOL><INDENT>AST = compiler.parse(s)<EOL><DEDENT>except SyntaxError:<EOL><INDENT>return<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>if len(AST.getChildren()) > <NUM_LIT:1>:<EOL><INDENT>ST = AST.getChildren()[<NUM_LIT:1>]<EOL>if isinstance(ST, Stmt) and isinstance(ST.getChildren()[<NUM_LIT:0>],<EOL>Discard):<EOL><INDENT>d = ST.getChildren()[<NUM_LIT:0>].asList()[<NUM_LIT:0>]<EOL><DEDENT><DEDENT><DEDENT>except (TypeError, AttributeError):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>if isinstance(d,Dict) and len(d.items) > <NUM_LIT:0>:<EOL><INDENT>if all([isctype(i[<NUM_LIT:0>],str) for i in d.items]):<EOL><INDENT>if all([isinstance(i[<NUM_LIT:1>],List) for i in d.items]):<EOL><INDENT>if all([all([isctype(j,str) for j in i[<NUM_LIT:1>]]) for i in <EOL>d.items]):<EOL><INDENT>return eval(s)<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>
Attempts to convert a string representation of a coloring dictionary (as 
would be read from a file header, for instance) into an actual coloring 
dictionary.