<s> import os <EOL> from io import StringIO <EOL> __all__ = ( '<STR_LIT>' , ) <EOL> debug_base = '<STR_LIT>' <EOL> debug_base_2 = '<STR_LIT>' <EOL> file_regex = r'<STR_LIT>' <EOL> def load ( text , path , out ) : <EOL> """<STR_LIT>""" <EOL> dirname = os . path . dirname ( path ) <EOL> out . set_path ( dirname , file_regex ) <EOL> if text . startswith ( '<STR_LIT>' ) : <EOL> text = text [ <NUM_LIT> : ] <EOL> try : <EOL> from xml . parsers . expat import ExpatError , ErrorString <EOL> except ImportError : <EOL> try : <EOL> import plist_parser <EOL> except ImportError : <EOL> out . write_line ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> return <EOL> else : <EOL> out . write_line ( "<STR_LIT>" ) <EOL> try : <EOL> data = plist_parser . parse_string ( text ) <EOL> except plist_parser . PropertyListParseError as e : <EOL> out . write_line ( debug_base_2 % ( path , str ( e ) ) ) <EOL> else : <EOL> return data <EOL> else : <EOL> import plistlib <EOL> try : <EOL> return plistlib . readPlistFromBytes ( text . encode ( '<STR_LIT:utf-8>' ) ) <EOL> except ExpatError as e : <EOL> out . write_line ( debug_base <EOL> % ( path , <EOL> ErrorString ( e . code ) , <EOL> e . lineno , <EOL> e . offset + <NUM_LIT:1> ) <EOL> ) <EOL> def to_csscheme ( data , out , skip_names ) : <EOL> with StringIO ( ) as stream : <EOL> name = data . get ( '<STR_LIT:name>' , "<STR_LIT>" ) <EOL> stream . write ( '<STR_LIT>' % name ) <EOL> uuid = data . get ( '<STR_LIT>' ) <EOL> if uuid : <EOL> stream . write ( '<STR_LIT>' % uuid ) <EOL> items = data [ '<STR_LIT>' ] <EOL> settings = None <EOL> for i , item in enumerate ( items ) : <EOL> if '<STR_LIT>' not in item : <EOL> if '<STR_LIT>' not in item : <EOL> out . write_line ( "<STR_LIT>" ) <EOL> return <EOL> settings = item [ '<STR_LIT>' ] <EOL> del items [ i ] <EOL> break <EOL> if not settings : <EOL> settings = [ ] <EOL> else : <EOL> settings = list ( settings . items ( ) ) <EOL> settings . sort ( key = lambda x : x [ <NUM_LIT:0> ] . lower ( ) ) <EOL> stream . write ( "<STR_LIT>" ) <EOL> for key , value in settings : <EOL> stream . write ( "<STR_LIT>" % ( key , value ) ) <EOL> stream . write ( "<STR_LIT>" ) <EOL> for item in items : <EOL> if '<STR_LIT>' not in item : <EOL> out . write_line ( "<STR_LIT>" ) <EOL> return <EOL> stream . write ( "<STR_LIT>" % item [ '<STR_LIT>' ] ) <EOL> if not skip_names and '<STR_LIT:name>' in item : <EOL> stream . write ( '<STR_LIT>' % item [ '<STR_LIT:name>' ] ) <EOL> if '<STR_LIT>' not in item : <EOL> out . write_line ( "<STR_LIT>" ) <EOL> return <EOL> for key , value in item [ '<STR_LIT>' ] . items ( ) : <EOL> stream . write ( "<STR_LIT>" % ( key , value ) ) <EOL> stream . write ( "<STR_LIT>" ) <EOL> return stream . getvalue ( ) </s>
