#NEWLINE# def _get_system_assets( ) : #NEWLINE# #INDENT# '\n    Returns all system packages and all modules that should not be touched during module deletion\n\n    @return: tuple(packages, modules) to ignore\n    ' #NEWLINE# canon_sys_path = [ os . path . realpath ( package_dir ) for package_dir in sys . path ] #NEWLINE# std_lib = os . path . realpath ( sysconfig . get_python_lib ( standard_lib = True ) ) #NEWLINE# canon_sys_path = [ package_dir for package_dir in files if package_dir . startswith ( std_lib ) ] #NEWLINE# packages = [ ] #NEWLINE# package_dirs = [ ] #NEWLINE# modules = [ ] #NEWLINE# module_files = [ ] #NEWLINE# for ( top , files , files ) in os . walk ( std_lib ) : #NEWLINE# #INDENT# for nm in files : #NEWLINE# #INDENT# if ( nm == '__init__.py' ) : #NEWLINE# #INDENT# init_file = os . path . join ( top , nm ) #NEWLINE# package_dirs . append ( init_file [ : ( ( - len ( '__init__.py' ) ) - len ( os . sep ) ) ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( nm [ ( - 3 ) : ] in ( '.so' , '.py' ) ) or ( nm [ ( - 4 ) : ] in ( '.pyd' , '.dll' , '.pyw' ) ) or ( nm [ ( - 2 ) : ] == '.o' ) ) : #NEWLINE# #INDENT# module_file = os . path . join ( top , nm ) #NEWLINE# module_files . append ( module_file ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# for package_dir in package_dirs : #NEWLINE# #INDENT# for sys_path_dir in canon_sys_path : #NEWLINE# #INDENT# if package_dir . startswith ( sys_path_dir ) : #NEWLINE# #INDENT# package_parts = package_dir [ ( len ( sys_path_dir ) + len ( os . sep ) ) : ] . split ( os . sep ) #NEWLINE# for ( idx , part ) in enumerate ( package_parts ) : #NEWLINE# #INDENT# if ( part not in packages ) : #NEWLINE# #INDENT# if ( ( idx + 1 ) == len ( package_parts ) ) : #NEWLINE# #INDENT# packages . append ( '.' . join ( package_parts ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# for module_file in module_files : #NEWLINE# #INDENT# module_dir = os . path . dirname ( module_file ) #NEWLINE# for sys_path_dir in canon_sys_path : #NEWLINE# #INDENT# if ( module_dir == sys_path_dir ) : #NEWLINE# #INDENT# module_name_parts = os . path . basename ( module_file ) . split ( '.' ) #NEWLINE# module_name = module_name_parts [ 0 ] #NEWLINE# if ( ( module_name_parts [ 1 ] in ( 'so' , 'dll' , 'o' ) ) and module_name_parts [ 0 ] . endswith ( 'module' ) ) : #NEWLINE# #INDENT# module_name = module_name [ : ( - 6 ) ] #NEWLINE# #UNINDENT# modules . append ( module_name ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return ( packages , modules )