a >h @sBddlmZddlZddlZddlmZmZGdddeeZdS))PathN)Plugin RedHatPluginc@seZdZdZdZddZdS) UnpackagedzDCollects a list of files that are not handled by the package manager unpackagedc sdd}dfdd }fdd}jdds2dSd }|g}tfd d jjjDD]}|||7}qrfd d |D}||}|d|Wdn1s0YdS)NcSstjddS)z3Return a list of directories in $PATH. PATH:)osenvironsplitr r A/usr/lib/python3.9/site-packages/sos/report/plugins/unpackaged.pyget_env_path_listsz-Unpackaged.collect..get_env_path_listc sg}tj|ddD]\}}}|rD|D]fdd|D|dd<q$|D]h}||}z"tt|jrxt|}Wnt yYqHYn0| ||tj |gqH|D]&}||}| |tj |gqq|S)zReturn a list of all files present on the system, excluding any directories listed in `exclude`. :param path: the starting path :param exclude: list of paths to exclude T)topdowncsg|]}|vr|qSr r ).0dexcr r (z@Unpackaged.collect..all_files_system..N) r walk path_joinstatS_ISLNKlstatst_moderresolve Exceptionappendpathrealpath)rZexcludeZ file_listrootdirsfilesnameselfrr all_files_systems&    z,Unpackaged.collect..all_files_systemcshg}|D]Z}|}|}d}|rT|dkrTt|}|d|7}|d7}q ||dq|S)z4Format the unpackaged list as a string. r z ->  )rZ path_islinkr readlinkr)r#ZexpandedfileoutZlinksr%r r format_output9s   z)Unpackaged.collect..format_outputT)cmdrc3s0|](tfddDrtjVqdS)c3s|]}|VqdS)N) startswith)rpxr r Vrz/Unpackaged.collect...N)anyr rr )r)pathsr2r r4Ssz%Unpackaged.collect..csg|]\}}|vr|qSr r )rr3Zrp)all_frpmr r r[rz&Unpackaged.collect..)N) Ztest_predicateZcollection_filesetZpolicyZmangle_package_pathZpackage_managerZ all_fileswritejoin) r&rr'r.ZufileZ all_fsystemrZ not_packagedZnot_packaged_expandedr )r7r6r&r collects$     zUnpackaged.collectN)__name__ __module__ __qualname__Z short_descZ plugin_namer<r r r r rsr)pathlibrr rZsos.report.pluginsrrrr r r r  s