<s> """<STR_LIT>""" <EOL> from django . shortcuts import redirect <EOL> from kitchen . backends . plugins import is_view <EOL> def build_link ( data , link ) : <EOL> data . setdefault ( '<STR_LIT>' , { } ) <EOL> data [ '<STR_LIT>' ] . setdefault ( '<STR_LIT:data>' , { } ) <EOL> data [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] . setdefault ( '<STR_LIT>' , [ ] ) <EOL> data [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] [ '<STR_LIT>' ] . append ( link ) <EOL> def inject ( node ) : <EOL> """<STR_LIT>""" <EOL> link = { <EOL> '<STR_LIT:url>' : "<STR_LIT>" . format ( node [ '<STR_LIT>' ] ) , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:title>' : '<STR_LIT>' , <EOL> } <EOL> build_link ( node , link ) <EOL> for guest in node . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' , [ ] ) : <EOL> link = { <EOL> '<STR_LIT:url>' : "<STR_LIT>" . format ( <EOL> node [ '<STR_LIT>' ] , guest [ '<STR_LIT>' ] ) , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:title>' : '<STR_LIT>' , <EOL> } <EOL> build_link ( guest , link ) <EOL> @ is_view ( '<STR_LIT>' ) <EOL> def links ( request , hosts ) : <EOL> try : <EOL> fqdn = request . GET [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> return None <EOL> current_node = None <EOL> for host in hosts : <EOL> if fqdn == host [ '<STR_LIT>' ] : <EOL> current_node = host <EOL> break <EOL> for node in host . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' , [ ] ) : <EOL> if fqdn == node [ '<STR_LIT>' ] : <EOL> current_node = node <EOL> break <EOL> if current_node : <EOL> break <EOL> if current_node : <EOL> try : <EOL> links = current_node [ '<STR_LIT>' ] [ '<STR_LIT:data>' ] [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> return None <EOL> for link in links : <EOL> if link . get ( '<STR_LIT:title>' ) == '<STR_LIT>' : <EOL> return redirect ( link [ '<STR_LIT:url>' ] ) <EOL> else : <EOL> return None </s>
