def _rebuild_mod_path(orig_path, package_name, module):
 sys_path = [_normalize_cached(p) for p in sys.path]
 def safe_sys_path_index(entry):
  '\n        Workaround for #520 and #513.\n        '
  try:
   return sys_path.index(entry)
  except ValueError:
   return float('inf')
 def position_in_sys_path(path):
  '\n        Return the ordinal of the path based on its position in sys.path\n        '
  path_parts = path.split(os.sep)
  module_parts = (package_name.count('.') + 1)
  parts = path_parts[:(- module_parts)]
  return safe_sys_path_index(_normalize_cached(os.sep.join(parts)))
 orig_path.sort(key=position_in_sys_path)
 module.__path__[:] = [_normalize_cached(p) for p in orig_path]

def _rebuild_mod_path ( orig_path , package_name , module ) : sys_path = [ _normalize_cached ( p ) for p in sys . path ] def safe_sys_path_index ( entry ) : try : return sys_path . index ( entry ) except ValueError : return float ( 'inf' ) def position_in_sys_path ( path ) : path_parts = path . split ( os . sep ) module_parts = ( package_name . count ( '.' ) + 1 ) parts = path_parts [ : ( - module_parts ) ] return safe_sys_path_index ( _normalize_cached ( os . sep . join ( parts ) ) ) orig_path . sort ( key = position_in_sys_path ) module . __path__ [ : ] = [ _normalize_cached ( p ) for p in orig_path ]
rebuild module .