<s> from collections import OrderedDict <EOL> from . . roles import add_role , AUXILIARY <EOL> def add_annotation ( var , annotation ) : <EOL> annotations = getattr ( var . tag , '<STR_LIT>' , [ ] ) <EOL> if any ( old_annotation . __class__ == annotation . __class__ <EOL> for old_annotation in annotations ) : <EOL> raise ValueError <EOL> else : <EOL> var . tag . annotations = annotations + [ annotation ] <EOL> class Annotation ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . auxiliary_variables = [ ] <EOL> self . updates = OrderedDict ( ) <EOL> def add_auxiliary_variable ( self , variable , roles = None , name = None ) : <EOL> """<STR_LIT>""" <EOL> add_annotation ( variable , self ) <EOL> if name is not None : <EOL> variable . name = name <EOL> variable . tag . name = name <EOL> add_role ( variable , AUXILIARY ) <EOL> if roles is not None : <EOL> for role in roles : <EOL> add_role ( variable , role ) <EOL> self . auxiliary_variables . append ( variable ) </s>
