<s> import urllib <EOL> from django . core . exceptions import ValidationError <EOL> def is_editable ( proposal , user ) : <EOL> return ( ( not proposal . scheduled ) and <EOL> ( ( proposal . proposer == user and proposal . status != '<STR_LIT:A>' ) or <EOL> topiclead ( user , proposal . topic ) ) ) <EOL> def linkify ( blueprints ) : <EOL> links = { } <EOL> for bp in blueprints . split ( ) : <EOL> ( project , name ) = bp . split ( '<STR_LIT:/>' ) <EOL> links [ bp ] = "<STR_LIT>" % ( project , name ) <EOL> return links <EOL> def topiclead ( user , topic ) : <EOL> return ( user . username == topic . lead_username ) or user . is_staff <EOL> def _is_valid_lp_name ( value ) : <EOL> return value . replace ( '<STR_LIT:->' , '<STR_LIT>' ) . isalnum ( ) <EOL> def validate_bp ( value ) : <EOL> bps = value . split ( ) <EOL> for bp in bps : <EOL> members = bp . split ( "<STR_LIT:/>" ) <EOL> if len ( members ) != <NUM_LIT:2> : <EOL> raise ValidationError ( u'<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> ( project , bpname ) = list ( members ) <EOL> if not _is_valid_lp_name ( project ) : <EOL> raise ValidationError ( u'<STR_LIT>' % project ) <EOL> if not _is_valid_lp_name ( bpname ) : <EOL> raise ValidationError ( u'<STR_LIT>' % bpname ) <EOL> f = urllib . urlopen ( "<STR_LIT>" <EOL> % ( project , bpname ) ) <EOL> f . close ( ) <EOL> if f . getcode ( ) != <NUM_LIT:200> : <EOL> raise ValidationError ( u'<STR_LIT>' <EOL> '<STR_LIT>' <EOL> % ( project , bpname ) ) </s>
