<s> """<STR_LIT>""" <EOL> import os <EOL> import sys <EOL> import nose . plugins <EOL> import pkg_resources <EOL> from paste . deploy import loadapp <EOL> import pylons <EOL> from pylons . i18n . translation import _get_translator <EOL> pylonsapp = None <EOL> class PylonsPlugin ( nose . plugins . Plugin ) : <EOL> """<STR_LIT>""" <EOL> enabled = False <EOL> enableOpt = '<STR_LIT>' <EOL> name = '<STR_LIT>' <EOL> def options ( self , parser , env = os . environ ) : <EOL> """<STR_LIT>""" <EOL> env_opt = '<STR_LIT>' % self . name . upper ( ) <EOL> env_opt . replace ( '<STR_LIT:->' , '<STR_LIT:_>' ) <EOL> parser . add_option ( "<STR_LIT>" % self . name , <EOL> dest = self . enableOpt , type = "<STR_LIT:string>" , <EOL> default = "<STR_LIT>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def configure ( self , options , conf ) : <EOL> """<STR_LIT>""" <EOL> self . config_file = None <EOL> self . conf = conf <EOL> if hasattr ( options , self . enableOpt ) : <EOL> self . enabled = bool ( getattr ( options , self . enableOpt ) ) <EOL> self . config_file = getattr ( options , self . enableOpt ) <EOL> def begin ( self ) : <EOL> """<STR_LIT>""" <EOL> global pylonsapp <EOL> path = os . getcwd ( ) <EOL> sys . path . insert ( <NUM_LIT:0> , path ) <EOL> pkg_resources . working_set . add_entry ( path ) <EOL> self . app = pylonsapp = loadapp ( '<STR_LIT>' + self . config_file , <EOL> relative_to = path ) <EOL> conf = getattr ( pylonsapp , '<STR_LIT>' ) <EOL> if conf : <EOL> pylons . config . _push_object ( conf ) <EOL> if '<STR_LIT>' in conf : <EOL> pylons . app_globals . _push_object ( conf [ '<STR_LIT>' ] ) <EOL> translator = _get_translator ( pylons . config . get ( '<STR_LIT>' ) ) <EOL> pylons . translator . _push_object ( translator ) </s>
