<s> '''<STR_LIT>''' <EOL> import sys <EOL> import os <EOL> import dumpstyle <EOL> from pygments . token import STANDARD_TYPES <EOL> from pygments import styles as pstyles <EOL> classnames = set ( ) <EOL> for name in list ( pstyles . get_all_styles ( ) ) : <EOL> css = os . popen ( '<STR_LIT>' % name , '<STR_LIT:r>' ) . read ( ) <EOL> for line in css . splitlines ( ) : <EOL> line = line . strip ( ) <EOL> sname = "<STR_LIT>" + line . split ( '<STR_LIT:U+0020>' ) [ <NUM_LIT:0> ] [ <NUM_LIT:1> : ] <EOL> classnames . add ( sname ) <EOL> def css2rl ( css ) : <EOL> dstyles = { } <EOL> for key in STANDARD_TYPES : <EOL> dstyles [ "<STR_LIT>" + STANDARD_TYPES [ key ] ] = { '<STR_LIT>' : '<STR_LIT:code>' } <EOL> seenclassnames = set ( ) <EOL> styles = [ ] <EOL> for line in css . splitlines ( ) : <EOL> line = line . strip ( ) <EOL> sname = "<STR_LIT>" + line . split ( '<STR_LIT:U+0020>' ) [ <NUM_LIT:0> ] [ <NUM_LIT:1> : ] <EOL> seenclassnames . add ( sname ) <EOL> style = dstyles . get ( sname , { '<STR_LIT>' : '<STR_LIT:code>' } ) <EOL> options = line . split ( '<STR_LIT:{>' ) [ <NUM_LIT:1> ] . split ( '<STR_LIT:}>' ) [ <NUM_LIT:0> ] . split ( '<STR_LIT:;>' ) <EOL> for option in options : <EOL> option = option . strip ( ) <EOL> option , argument = option . split ( '<STR_LIT::>' ) <EOL> option = option . strip ( ) <EOL> argument = argument . strip ( ) <EOL> if option == '<STR_LIT>' : <EOL> style [ '<STR_LIT>' ] = argument . strip ( ) <EOL> if option == '<STR_LIT>' : <EOL> style [ '<STR_LIT>' ] = argument . strip ( ) <EOL> if option == '<STR_LIT>' and argument == '<STR_LIT>' : <EOL> if '<STR_LIT>' in style and style [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> style [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> else : <EOL> style [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if option == '<STR_LIT>' and argument == '<STR_LIT>' : <EOL> if '<STR_LIT>' in style and style [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> style [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> else : <EOL> style [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if style . get ( '<STR_LIT>' , None ) is None : <EOL> style [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> styles . append ( [ sname , style ] ) <EOL> for sname in classnames - seenclassnames : <EOL> style = dstyles . get ( sname , { '<STR_LIT>' : '<STR_LIT:code>' } ) <EOL> style [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> styles . append ( [ sname , style ] ) <EOL> return dumpstyle . dumps ( { '<STR_LIT>' : styles } ) <EOL> for name in list ( pstyles . get_all_styles ( ) ) : <EOL> css = os . popen ( '<STR_LIT>' % name , '<STR_LIT:r>' ) . read ( ) <EOL> open ( name + '<STR_LIT>' , '<STR_LIT:w>' ) . write ( css2rl ( css ) ) </s>
