<s> from . bundled . traitlets import HasTraits , Enum , Instance , List <EOL> from . requirement import Requirement <EOL> from . package import PackageInfo <EOL> from . pool import Pool <EOL> class _Job ( HasTraits ) : <EOL> packages = List ( Instance ( PackageInfo ) ) <EOL> job_type = Enum ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> requirement = Instance ( Requirement ) <EOL> def __init__ ( self , packages , job_type , requirement , ** kw ) : <EOL> if packages is None : <EOL> packages = packages <EOL> super ( _Job , self ) . __init__ ( packages = packages , job_type = job_type , <EOL> requirement = requirement , ** kw ) <EOL> def __eq__ ( self , other ) : <EOL> if other is None : <EOL> return False <EOL> if len ( self . packages ) != len ( other . packages ) : <EOL> return False <EOL> else : <EOL> for left , right in zip ( self . packages , other . packages ) : <EOL> if left != right : <EOL> return False <EOL> return self . job_type == other . job_type and self . requirement == other . requirement <EOL> class Request ( HasTraits ) : <EOL> """<STR_LIT>""" <EOL> pool = Instance ( Pool ) <EOL> _jobs = List ( Instance ( Pool ) ) <EOL> def __init__ ( self , pool , ** kw ) : <EOL> super ( Request , self ) . __init__ ( pool = pool , _jobs = [ ] , ** kw ) <EOL> @ property <EOL> def jobs ( self ) : <EOL> return self . _jobs <EOL> def _add_job ( self , requirement , job_type ) : <EOL> packages = self . pool . what_provides ( requirement ) <EOL> self . jobs . append ( _Job ( packages , job_type , requirement ) ) <EOL> def install ( self , requirement ) : <EOL> self . _add_job ( requirement , "<STR_LIT>" ) <EOL> def update ( self , requirement ) : <EOL> self . _add_job ( requirement , "<STR_LIT>" ) <EOL> def remove ( self , requirement ) : <EOL> self . _add_job ( requirement , "<STR_LIT>" ) <EOL> def upgrade ( self ) : <EOL> self . jobs . append ( _Job ( [ ] , "<STR_LIT>" , None ) ) </s>
