<s> import logging <EOL> from pylons import request , response , session , tmpl_context as c <EOL> from pylons . controllers . util import abort , redirect_to <EOL> from anygit . lib import helpers <EOL> from anygit . lib . base import BaseController , render <EOL> from anygit import models <EOL> from anygit . client import fetch <EOL> log = logging . getLogger ( __name__ ) <EOL> class IndexController ( BaseController ) : <EOL> def index ( self ) : <EOL> return render ( '<STR_LIT>' , controller = '<STR_LIT:index>' ) <EOL> def about ( self ) : <EOL> return render ( '<STR_LIT>' , controller = '<STR_LIT:index>' ) <EOL> def do_request ( self ) : <EOL> urls = request . params . get ( '<STR_LIT:url>' , '<STR_LIT>' ) . strip ( ) <EOL> if not urls : <EOL> helpers . error ( '<STR_LIT>' ) <EOL> for url in urls . split ( '<STR_LIT:\n>' ) : <EOL> url = models . Repository . canonicalize ( url . strip ( ) ) <EOL> if not url : <EOL> continue <EOL> if models . Repository . exists ( url = url ) : <EOL> repo = models . Repository . get_by_attributes ( url = url ) <EOL> if repo . approved : <EOL> helpers . flash ( '<STR_LIT>' <EOL> '<STR_LIT>' % url ) <EOL> else : <EOL> if not url . startswith ( '<STR_LIT>' ) : <EOL> helpers . flash ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % url ) <EOL> elif not fetch . check_validity ( repo ) : <EOL> helpers . error ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % url ) <EOL> else : <EOL> repo . approved = True <EOL> repo . save ( ) <EOL> helpers . flash ( "<STR_LIT>" <EOL> "<STR_LIT>" % url ) <EOL> else : <EOL> repo = models . Repository . create ( url = url ) <EOL> if not url . startswith ( '<STR_LIT>' ) : <EOL> helpers . flash ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % url ) <EOL> elif not fetch . check_validity ( repo ) : <EOL> helpers . error ( "<STR_LIT>" % url ) <EOL> else : <EOL> repo . approved = True <EOL> repo . save ( ) <EOL> helpers . flash ( '<STR_LIT>' % url ) <EOL> models . flush ( ) <EOL> redirect_to ( '<STR_LIT:/>' ) </s>
