<s> import os <EOL> import json <EOL> resources = { } <EOL> with open ( '<STR_LIT>' ) as f : <EOL> for line in f : <EOL> try : <EOL> parts = line . split ( ) <EOL> first_part = parts [ <NUM_LIT:0> ] <EOL> if first_part . count ( '<STR_LIT:/>' ) == <NUM_LIT:4> : <EOL> name = first_part . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] . replace ( '<STR_LIT:_>' , '<STR_LIT:U+0020>' ) . lower ( ) [ : - <NUM_LIT:1> ] <EOL> if len ( name . split ( ) ) > <NUM_LIT:3> : <EOL> continue <EOL> pos = name . find ( '<STR_LIT:U+0020>' ) <EOL> if pos > - <NUM_LIT:1> : <EOL> name = name [ : pos ] <EOL> if '<STR_LIT>' in parts [ <NUM_LIT:2> ] : <EOL> continue <EOL> if '<STR_LIT>' in parts [ <NUM_LIT:2> ] : <EOL> continue <EOL> if name not in resources : <EOL> resources [ name ] = set ( ) <EOL> resources [ name ] . add ( parts [ <NUM_LIT:2> ] . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] [ : - <NUM_LIT:1> ] ) <EOL> except IndexError : <EOL> pass <EOL> stripped_resources = { } <EOL> for x in resources : <EOL> if any ( [ y in x for y in '<STR_LIT>' ] ) : <EOL> if '<STR_LIT:%>' not in x : <EOL> continue <EOL> pos = x . find ( '<STR_LIT:(>' ) <EOL> if pos > - <NUM_LIT:1> : <EOL> stripped_resources [ x [ : pos ] . strip ( ) ] = list ( resources [ x ] ) <EOL> else : <EOL> stripped_resources [ x . strip ( ) ] = list ( resources [ x ] ) <EOL> fname = os . path . join ( os . path . dirname ( __file__ ) , '<STR_LIT>' ) <EOL> with open ( fname , '<STR_LIT:w>' ) as f : <EOL> json . dump ( stripped_resources , f ) </s>
