#NEWLINE# def parse_requirement( s ) : #NEWLINE# #INDENT# def get_constraint( m ) : #NEWLINE# #INDENT# d = m . groupdict ( ) #NEWLINE# return ( d [ 'op' ] , d [ 'vn' ] ) #NEWLINE# #UNINDENT# result = None #NEWLINE# m = REQUIREMENT_RE . match ( s ) #NEWLINE# if m : #NEWLINE# #INDENT# d = m . groupdict ( ) #NEWLINE# name = d [ 'dn' ] #NEWLINE# cons = ( d [ 'c1' ] or d [ 'c2' ] ) #NEWLINE# if ( not d [ 'diref' ] ) : #NEWLINE# #INDENT# url = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# cons = None #NEWLINE# url = d [ 'diref' ] . strip ( ) #NEWLINE# #UNINDENT# if ( not cons ) : #NEWLINE# #INDENT# cons = None #NEWLINE# constr = '' #NEWLINE# rs = d [ 'dn' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( cons [ 0 ] not in '<>!=' ) : #NEWLINE# #INDENT# cons = ( '~=' + cons ) #NEWLINE# #UNINDENT# iterator = RELOP_IDENT_RE . finditer ( cons ) #NEWLINE# cons = [ get_constraint ( m ) for m in iterator ] #NEWLINE# rs = ( '%s (%s)' % ( name , ', ' . join ( [ ( '%s %s' % con ) for con in cons ] ) ) ) #NEWLINE# #UNINDENT# if ( not d [ 'ex' ] ) : #NEWLINE# #INDENT# extras = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# extras = COMMA_RE . split ( d [ 'ex' ] ) #NEWLINE# #UNINDENT# result = Container ( name = name , constraints = cons , extras = extras , requirement = rs , source = s , url = url ) #NEWLINE# #UNINDENT# return result