#NEWLINE# def __init__( self , s ) : #NEWLINE# #INDENT# if ( self . version_class is None ) : #NEWLINE# #INDENT# raise ValueError ( 'Please specify a version class' ) #NEWLINE# #UNINDENT# self . _string = s = s . strip ( ) #NEWLINE# m = self . dist_re . match ( s ) #NEWLINE# if ( not m ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Not valid: %r' % s ) ) #NEWLINE# #UNINDENT# groups = m . groups ( '' ) #NEWLINE# self . name = groups [ 0 ] . strip ( ) #NEWLINE# self . key = self . name . lower ( ) #NEWLINE# clist = [ ] #NEWLINE# if groups [ 2 ] : #NEWLINE# #INDENT# constraints = [ c . strip ( ) for c in groups [ 2 ] . split ( ',' ) ] #NEWLINE# for c in constraints : #NEWLINE# #INDENT# m = self . comp_re . match ( c ) #NEWLINE# if ( not m ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Invalid %r in %r' % ( c , s ) ) ) #NEWLINE# #UNINDENT# groups = m . groups ( ) #NEWLINE# op = ( groups [ 0 ] or '~=' ) #NEWLINE# s = groups [ 1 ] #NEWLINE# if s . endswith ( '.*' ) : #NEWLINE# #INDENT# if ( constraints not in ( '==' , '!=' ) ) : #NEWLINE# #INDENT# raise ValueError ( ( "'.*' not allowed for %r constraints" % op ) ) #NEWLINE# #UNINDENT# ( vn , prefix ) = ( s [ : ( - 2 ) ] , True ) #NEWLINE# if ( not self . num_re . match ( vn ) ) : #NEWLINE# #INDENT# self . version_class ( vn ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# ( vn , prefix ) = ( self . version_class ( s ) , False ) #NEWLINE# #UNINDENT# clist . append ( ( op , vn , prefix ) ) #NEWLINE# #UNINDENT# #UNINDENT# self . _parts = tuple ( clist )