<s> """<STR_LIT>""" <EOL> from lmi . scripts import software <EOL> from lmi . scripts . common import command <EOL> from lmi . scripts . common import errors <EOL> from lmi . scripts . common import get_logger <EOL> LOG = get_logger ( __name__ ) <EOL> class AllLister ( command . LmiLister ) : <EOL> CONNECTION_TIMEOUT = <NUM_LIT:15> * <NUM_LIT> <EOL> COLUMNS = [ ] <EOL> def execute ( self , ns , _allow_duplicates = False ) : <EOL> installed_nevras = None <EOL> if software . get_backend ( ns ) == software . BACKEND_PACKAGEKIT : <EOL> installed_nevras = set ( software . get_package_nevra ( p ) <EOL> for p in software . list_installed_packages ( ns ) ) <EOL> for pkg in software . find_package ( ns , <EOL> allow_duplicates = _allow_duplicates ) : <EOL> yield ( software . get_package_nevra ( pkg ) , ) <EOL> class InstalledLister ( command . LmiInstanceLister ) : <EOL> CONNECTION_TIMEOUT = <NUM_LIT:4> * <NUM_LIT> <EOL> PROPERTIES = ( ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> , ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> CALLABLE = software . list_installed_packages <EOL> class AvailableLister ( command . LmiInstanceLister ) : <EOL> CONNECTION_TIMEOUT = <NUM_LIT:15> * <NUM_LIT> <EOL> PROPERTIES = ( ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> , ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def execute ( self , ns , _repoid = None , _allow_duplicates = False ) : <EOL> for pkg in software . list_available_packages ( ns , <EOL> repoid = _repoid , allow_duplicates = _allow_duplicates ) : <EOL> yield pkg <EOL> class RepoLister ( command . LmiInstanceLister ) : <EOL> CONNECTION_TIMEOUT = <NUM_LIT:4> * <NUM_LIT> <EOL> DYNAMIC_PROPERTIES = True <EOL> def execute ( self , ns , _all , _disabled ) : <EOL> if _all : <EOL> properties = ( <EOL> ( '<STR_LIT>' , '<STR_LIT:Name>' ) , <EOL> ( '<STR_LIT:Name>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , lambda i : i . EnabledState == <NUM_LIT:2> ) ) <EOL> enabled = None <EOL> else : <EOL> properties = ( <EOL> ( '<STR_LIT>' , '<STR_LIT:Name>' ) , <EOL> ( '<STR_LIT:Name>' , '<STR_LIT>' ) ) <EOL> enabled = not _disabled <EOL> return ( properties , software . list_repositories ( ns , enabled ) ) <EOL> class FileLister ( command . LmiInstanceLister ) : <EOL> CONNECTION_TIMEOUT = <NUM_LIT:10> * <NUM_LIT> <EOL> DYNAMIC_PROPERTIES = True <EOL> def verify_options ( self , options ) : <EOL> file_types = { '<STR_LIT:all>' , '<STR_LIT:file>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' } <EOL> if ( options [ '<STR_LIT>' ] is not None <EOL> and options [ '<STR_LIT>' ] not in file_types ) : <EOL> raise errors . LmiInvalidOptions ( <EOL> '<STR_LIT>' % file_types ) <EOL> def execute ( self , ns , package , _type = None ) : <EOL> properties = [ <EOL> ( '<STR_LIT:Name>' ) , <EOL> ( '<STR_LIT>' , lambda i : <EOL> software . FILE_TYPES [ i . FileType ] <EOL> if i . FileExists <EOL> else '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , lambda i : i . FileSize ) , <EOL> ( '<STR_LIT>' , lambda i : len ( i . FailedFlags ) < <NUM_LIT:1> ) ] <EOL> if _type is not None : <EOL> del properties [ <NUM_LIT:1> ] <EOL> pkgs = list ( p . to_instance ( ) for p in software . find_package ( <EOL> ns , pkg_spec = package ) ) <EOL> pkgs = [ p for p in pkgs if software . is_package_installed ( p ) ] <EOL> if len ( pkgs ) < <NUM_LIT:1> : <EOL> raise errors . LmiFailed ( <EOL> '<STR_LIT>' % package ) <EOL> if len ( pkgs ) > <NUM_LIT:1> : <EOL> LOG ( ) . warn ( '<STR_LIT>' , package , <EOL> '<STR_LIT:U+002CU+0020>' . join ( p . ElementName for p in pkgs ) ) <EOL> return ( properties <EOL> , software . list_package_files ( ns , pkgs [ - <NUM_LIT:1> ] , file_type = _type ) ) <EOL> class Lister ( command . LmiCommandMultiplexer ) : <EOL> COMMANDS = { <EOL> '<STR_LIT:all>' : AllLister , <EOL> '<STR_LIT>' : InstalledLister , <EOL> '<STR_LIT>' : AvailableLister , <EOL> '<STR_LIT>' : RepoLister , <EOL> '<STR_LIT>' : FileLister <EOL> } <EOL> FALLBACK_COMMAND = AllLister <EOL> OWN_USAGE = __doc__ </s>
