<s> import py <EOL> redir = py . magic . autopath ( ) . dirpath ( '<STR_LIT>' ) <EOL> def checkexist ( path ) : <EOL> print "<STR_LIT>" , path <EOL> assert path . ext == '<STR_LIT>' <EOL> assert path . new ( ext = '<STR_LIT>' ) . check ( file = <NUM_LIT:1> ) <EOL> def checkredirection ( oldname , newname ) : <EOL> print "<STR_LIT>" , newname <EOL> if not newname . startswith ( '<STR_LIT>' ) : <EOL> newpath = redir . dirpath ( newname . split ( '<STR_LIT:#>' ) [ <NUM_LIT:0> ] ) <EOL> checkexist ( newpath ) <EOL> if py . test . config . option . generateredirections and '<STR_LIT:#>' not in oldname : <EOL> generate_redirection ( oldname , newname ) <EOL> def test_eval ( ) : <EOL> d = eval ( redir . read ( mode = '<STR_LIT:r>' ) ) <EOL> return d <EOL> def test_redirections ( ) : <EOL> d = test_eval ( ) <EOL> for oldname , newname in d . items ( ) : <EOL> yield checkredirection , oldname , newname <EOL> def test_navlist ( ) : <EOL> navlist = eval ( redir . dirpath ( '<STR_LIT>' ) . read ( ) ) <EOL> for entry in navlist : <EOL> yield checkexist , redir . dirpath ( entry ) <EOL> def generate_redirection ( oldname , newname ) : <EOL> print "<STR_LIT>" , oldname <EOL> oldpath = redir . dirpath ( oldname ) <EOL> url = newname <EOL> oldpath . write ( """<STR_LIT>""" % ( url , url , url ) ) </s>
