<s> '''<STR_LIT>''' <EOL> config = '''<STR_LIT>''' <EOL> if not config . strip ( ) : <EOL> try : <EOL> config_file = open ( '<STR_LIT>' , '<STR_LIT:r>' ) <EOL> try : <EOL> config = config_file . read ( ) <EOL> finally : <EOL> config_file . close ( ) <EOL> except : <EOL> config = '<STR_LIT>' <EOL> def auto_in ( apps ) : <EOL> routes = [ <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> for domain , path in [ x . strip ( ) . split ( ) for x in apps . split ( '<STR_LIT:\n>' ) if x . strip ( ) and not x . strip ( ) . startswith ( '<STR_LIT:#>' ) ] : <EOL> if not path . startswith ( '<STR_LIT:/>' ) : <EOL> path = '<STR_LIT:/>' + path <EOL> if path . endswith ( '<STR_LIT:/>' ) : <EOL> path = path [ : - <NUM_LIT:1> ] <EOL> app = path . split ( '<STR_LIT:/>' ) [ <NUM_LIT:1> ] <EOL> routes += [ <EOL> ( '<STR_LIT>' % domain , '<STR_LIT:%s>' % path ) , <EOL> ( '<STR_LIT>' % <EOL> domain , '<STR_LIT>' % app ) , <EOL> ( '<STR_LIT>' % <EOL> domain , '<STR_LIT>' % app ) , <EOL> ( '<STR_LIT>' % <EOL> domain , '<STR_LIT>' % path ) , <EOL> ] <EOL> return routes <EOL> def auto_out ( apps ) : <EOL> routes = [ ] <EOL> for domain , path in [ x . strip ( ) . split ( ) for x in apps . split ( '<STR_LIT:\n>' ) if x . strip ( ) and not x . strip ( ) . startswith ( '<STR_LIT:#>' ) ] : <EOL> if not path . startswith ( '<STR_LIT:/>' ) : <EOL> path = '<STR_LIT:/>' + path <EOL> if path . endswith ( '<STR_LIT:/>' ) : <EOL> path = path [ : - <NUM_LIT:1> ] <EOL> app = path . split ( '<STR_LIT:/>' ) [ <NUM_LIT:1> ] <EOL> routes += [ <EOL> ( '<STR_LIT>' % app , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' % app , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' % path , '<STR_LIT>' ) , <EOL> ] <EOL> return routes <EOL> routes_in = auto_in ( config ) <EOL> routes_out = auto_out ( config ) <EOL> def __routes_doctest ( ) : <EOL> '''<STR_LIT>''' <EOL> pass <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> try : <EOL> import gluon . main <EOL> except ImportError : <EOL> import sys <EOL> import os <EOL> os . chdir ( os . path . dirname ( os . path . dirname ( __file__ ) ) ) <EOL> sys . path . append ( os . path . dirname ( os . path . dirname ( __file__ ) ) ) <EOL> import gluon . main <EOL> from gluon . rewrite import regex_select , load , filter_url , regex_filter_out <EOL> regex_select ( ) <EOL> load ( routes = __file__ ) <EOL> import doctest <EOL> doctest . testmod ( ) </s>
