ubelt

Package Layout

  • ubelt package
    • Submodules
      • ubelt.__main__ module
      • ubelt._win32_links module
        • _win32_can_symlink()
        • _symlink()
        • _win32_symlink2()
        • _win32_symlink()
        • _win32_junction()
        • _win32_is_junction()
        • _is_reparse_point()
        • _win32_read_junction()
        • _win32_rmtree()
        • _win32_is_hardlinked()
        • _win32_dir()
      • ubelt.orderedset module
        • OrderedSet
          • OrderedSet.copy()
          • OrderedSet.add()
          • OrderedSet.append()
          • OrderedSet.update()
          • OrderedSet.index()
          • OrderedSet.get_loc()
          • OrderedSet.get_indexer()
          • OrderedSet.pop()
          • OrderedSet.discard()
          • OrderedSet.clear()
          • OrderedSet.union()
          • OrderedSet.intersection()
          • OrderedSet.difference()
          • OrderedSet.issubset()
          • OrderedSet.issuperset()
          • OrderedSet.symmetric_difference()
          • OrderedSet._update_items()
          • OrderedSet.difference_update()
          • OrderedSet.intersection_update()
          • OrderedSet.symmetric_difference_update()
          • OrderedSet._abc_impl
        • oset
      • ubelt.progiter module
        • ProgIter
          • ProgIter.set_extra()
          • ProgIter._reset_internals()
          • ProgIter.begin()
          • ProgIter.end()
          • ProgIter._iterate()
          • ProgIter._homogeneous_check()
          • ProgIter._slow_path_step_body()
          • ProgIter.step()
          • ProgIter._adjust_frequency()
          • ProgIter._measure_time()
          • ProgIter._update_message_template()
          • ProgIter._build_message_template()
          • ProgIter.format_message()
          • ProgIter.format_message_parts()
          • ProgIter.ensure_newline()
          • ProgIter.display_message()
          • ProgIter._tryflush()
          • ProgIter._write()
      • ubelt.util_arg module
        • argval()
        • argflag()
      • ubelt.util_cache module
        • Cacher
          • Cacher.VERBOSE
          • Cacher.FORCE_DISABLE
          • Cacher._rectify_cfgstr()
          • Cacher._condense_cfgstr()
          • Cacher.fpath
          • Cacher.get_fpath()
          • Cacher.exists()
          • Cacher.existing_versions()
          • Cacher.clear()
          • Cacher.tryload()
          • Cacher.load()
          • Cacher.save()
          • Cacher._backend_load()
          • Cacher._backend_dump()
          • Cacher.ensure()
        • CacheStamp
          • CacheStamp.fpath
          • CacheStamp.clear()
          • CacheStamp._get_certificate()
          • CacheStamp._rectify_products()
          • CacheStamp._rectify_hash_prefixes()
          • CacheStamp._product_info()
          • CacheStamp._product_file_stats()
          • CacheStamp._product_file_hash()
          • CacheStamp.expired()
          • CacheStamp._check_certificate_hashes()
          • CacheStamp._expires()
          • CacheStamp._new_certificate()
          • CacheStamp.renew()
        • _localnow()
        • _byte_str()
      • ubelt.util_cmd module
        • cmd()
      • ubelt.util_colors module
        • highlight_code()
        • _pygments_highlight()
        • _rich_highlight()
        • color_text()
      • ubelt.util_const module
      • ubelt.util_deprecate module
        • schedule_deprecation()
      • ubelt.util_dict module
        • AutoDict
          • AutoDict._base
          • AutoDict.to_dict()
        • AutoOrderedDict
        • dzip()
        • ddict
        • dict_hist()
        • dict_subset()
        • dict_union()
        • dict_isect()
        • dict_diff()
        • find_duplicates()
        • group_items()
        • invert_dict()
        • map_keys()
        • map_vals()
        • map_values()
        • sorted_keys()
        • sorted_vals()
        • sorted_values()
        • odict
        • named_product()
        • varied_values()
        • SetDict
          • SetDict.copy()
          • SetDict.union()
          • SetDict.intersection()
          • SetDict.difference()
          • SetDict.symmetric_difference()
        • UDict
          • UDict.subdict()
          • UDict.take()
          • UDict.invert()
          • UDict.map_keys()
          • UDict.map_values()
          • UDict.sorted_keys()
          • UDict.sorted_values()
          • UDict.peek_key()
          • UDict.peek_value()
        • sdict
        • udict
      • ubelt.util_download module
        • download()
        • grabdata()
      • ubelt.util_download_manager module
        • DownloadManager
          • DownloadManager.submit()
          • DownloadManager.as_completed()
          • DownloadManager.shutdown()
      • ubelt.util_format module
        • repr2()
        • urepr()
        • FormatterExtensions
      • ubelt.util_func module
        • identity()
        • inject_method()
        • compatible()
      • ubelt.util_futures module
        • Executor
          • Executor.submit()
          • Executor.shutdown()
          • Executor.map()
        • JobPool
          • JobPool.submit()
          • JobPool.shutdown()
          • JobPool._clear_completed()
          • JobPool.as_completed()
          • JobPool.join()
      • ubelt.util_hash module
        • hash_data()
        • hash_file()
      • ubelt.util_import module
        • split_modpath()
        • modname_to_modpath()
        • modpath_to_modname()
        • import_module_from_name()
        • import_module_from_path()
      • ubelt.util_indexable module
        • _lazy_numpy()
        • Difference
          • Difference.path
          • Difference.value1
          • Difference.value2
          • Difference._asdict()
          • Difference._field_defaults
          • Difference._fields
          • Difference._make()
          • Difference._replace()
        • IndexableWalker
          • IndexableWalker.send()
          • IndexableWalker.throw()
          • IndexableWalker._walk()
          • IndexableWalker.allclose()
          • IndexableWalker.diff()
          • IndexableWalker._abc_impl
        • _make_isclose_fn()
        • indexable_allclose()
      • ubelt.util_io module
        • readfrom()
        • writeto()
        • touch()
        • delete()
      • ubelt.util_links module
        • symlink()
      • ubelt.util_list module
        • allsame()
        • argmax()
        • argmin()
        • argsort()
        • argunique()
        • boolmask()
        • chunks
          • chunks._new_iterator()
          • chunks.noborder()
          • chunks.cycle()
          • chunks.replicate()
        • compress()
        • flatten()
        • iter_window()
        • iterable()
        • peek()
        • take()
        • unique()
        • unique_flags()
      • ubelt.util_memoize module
        • memoize()
        • memoize_method
        • memoize_property()
      • ubelt.util_mixins module
        • NiceRepr
      • ubelt.util_path module
        • Path
          • Path.appdir()
          • Path.augment()
          • Path.delete()
          • Path.ensuredir()
          • Path.mkdir()
          • Path.expand()
          • Path.expandvars()
          • Path.ls()
          • Path.shrinkuser()
          • Path.chmod()
          • Path.touch()
          • Path.walk()
          • Path.endswith()
          • Path.startswith()
          • Path._request_copy_function()
          • Path.copy()
          • Path.move()
        • TempDir
          • TempDir.ensure()
          • TempDir.cleanup()
          • TempDir.start()
        • augpath()
        • shrinkuser()
        • userhome()
        • ensuredir()
        • expandpath()
        • ChDir
      • ubelt.util_platform module
        • find_exe()
        • find_path()
        • ensure_app_cache_dir()
        • ensure_app_config_dir()
        • ensure_app_data_dir()
        • get_app_cache_dir()
        • get_app_config_dir()
        • get_app_data_dir()
        • platform_cache_dir()
        • platform_config_dir()
        • platform_data_dir()
      • ubelt.util_repr module
        • urepr()
        • ReprExtensions
          • ReprExtensions.register()
          • ReprExtensions.lookup()
          • ReprExtensions._register_pandas_extensions()
          • ReprExtensions._register_numpy_extensions()
          • ReprExtensions._register_builtin_extensions()
      • ubelt.util_str module
        • indent()
        • codeblock()
        • paragraph()
        • hzcat()
        • ensure_unicode()
      • ubelt.util_stream module
        • TeeStringIO
          • TeeStringIO.isatty()
          • TeeStringIO.fileno()
          • TeeStringIO.encoding
          • TeeStringIO.write()
          • TeeStringIO.flush()
        • CaptureStdout
          • CaptureStdout.log_part()
          • CaptureStdout.start()
          • CaptureStdout.stop()
          • CaptureStdout.close()
        • CaptureStream
      • ubelt.util_time module
        • timestamp()
        • timeparse()
        • Timer
          • Timer._default_time()
          • Timer.tic()
          • Timer.toc()
      • ubelt.util_zip module
        • zopen
          • zopen.zfile
          • zopen.namelist()
          • zopen._cleanup()
          • zopen._split_archive()
          • zopen._open()
        • split_archive()
    • Module contents
      • AutoDict
        • AutoDict._base
        • AutoDict.to_dict()
      • AutoOrderedDict
      • CacheStamp
        • CacheStamp.fpath
        • CacheStamp.clear()
        • CacheStamp._get_certificate()
        • CacheStamp._rectify_products()
        • CacheStamp._rectify_hash_prefixes()
        • CacheStamp._product_info()
        • CacheStamp._product_file_stats()
        • CacheStamp._product_file_hash()
        • CacheStamp.expired()
        • CacheStamp._check_certificate_hashes()
        • CacheStamp._expires()
        • CacheStamp._new_certificate()
        • CacheStamp.renew()
      • Cacher
        • Cacher.VERBOSE
        • Cacher.FORCE_DISABLE
        • Cacher._rectify_cfgstr()
        • Cacher._condense_cfgstr()
        • Cacher.fpath
        • Cacher.get_fpath()
        • Cacher.exists()
        • Cacher.existing_versions()
        • Cacher.clear()
        • Cacher.tryload()
        • Cacher.load()
        • Cacher.save()
        • Cacher._backend_load()
        • Cacher._backend_dump()
        • Cacher.ensure()
      • CaptureStdout
        • CaptureStdout.log_part()
        • CaptureStdout.start()
        • CaptureStdout.stop()
        • CaptureStdout.close()
      • CaptureStream
      • ChDir
      • DownloadManager
        • DownloadManager.submit()
        • DownloadManager.as_completed()
        • DownloadManager.shutdown()
      • Executor
        • Executor.submit()
        • Executor.shutdown()
        • Executor.map()
      • FormatterExtensions
      • IndexableWalker
        • IndexableWalker.send()
        • IndexableWalker.throw()
        • IndexableWalker._walk()
        • IndexableWalker.allclose()
        • IndexableWalker.diff()
        • IndexableWalker._abc_impl
      • JobPool
        • JobPool.submit()
        • JobPool.shutdown()
        • JobPool._clear_completed()
        • JobPool.as_completed()
        • JobPool.join()
      • NiceRepr
      • OrderedSet
        • OrderedSet.copy()
        • OrderedSet.add()
        • OrderedSet.append()
        • OrderedSet.update()
        • OrderedSet.index()
        • OrderedSet.get_loc()
        • OrderedSet.get_indexer()
        • OrderedSet.pop()
        • OrderedSet.discard()
        • OrderedSet.clear()
        • OrderedSet.union()
        • OrderedSet.intersection()
        • OrderedSet.difference()
        • OrderedSet.issubset()
        • OrderedSet.issuperset()
        • OrderedSet.symmetric_difference()
        • OrderedSet._update_items()
        • OrderedSet.difference_update()
        • OrderedSet.intersection_update()
        • OrderedSet.symmetric_difference_update()
        • OrderedSet._abc_impl
      • Path
        • Path.appdir()
        • Path.augment()
        • Path.delete()
        • Path.ensuredir()
        • Path.mkdir()
        • Path.expand()
        • Path.expandvars()
        • Path.ls()
        • Path.shrinkuser()
        • Path.chmod()
        • Path.touch()
        • Path.walk()
        • Path.endswith()
        • Path.startswith()
        • Path._request_copy_function()
        • Path.copy()
        • Path.move()
      • ProgIter
        • ProgIter.set_extra()
        • ProgIter._reset_internals()
        • ProgIter.begin()
        • ProgIter.end()
        • ProgIter._iterate()
        • ProgIter._homogeneous_check()
        • ProgIter._slow_path_step_body()
        • ProgIter.step()
        • ProgIter._adjust_frequency()
        • ProgIter._measure_time()
        • ProgIter._update_message_template()
        • ProgIter._build_message_template()
        • ProgIter.format_message()
        • ProgIter.format_message_parts()
        • ProgIter.ensure_newline()
        • ProgIter.display_message()
        • ProgIter._tryflush()
        • ProgIter._write()
      • ReprExtensions
        • ReprExtensions.register()
        • ReprExtensions.lookup()
        • ReprExtensions._register_pandas_extensions()
        • ReprExtensions._register_numpy_extensions()
        • ReprExtensions._register_builtin_extensions()
      • SetDict
        • SetDict.copy()
        • SetDict.union()
        • SetDict.intersection()
        • SetDict.difference()
        • SetDict.symmetric_difference()
      • TeeStringIO
        • TeeStringIO.isatty()
        • TeeStringIO.fileno()
        • TeeStringIO.encoding
        • TeeStringIO.write()
        • TeeStringIO.flush()
      • TempDir
        • TempDir.ensure()
        • TempDir.cleanup()
        • TempDir.start()
      • Timer
        • Timer._default_time()
        • Timer.tic()
        • Timer.toc()
      • UDict
        • UDict.subdict()
        • UDict.take()
        • UDict.invert()
        • UDict.map_keys()
        • UDict.map_values()
        • UDict.sorted_keys()
        • UDict.sorted_values()
        • UDict.peek_key()
        • UDict.peek_value()
      • allsame()
      • argflag()
      • argmax()
      • argmin()
      • argsort()
      • argunique()
      • argval()
      • augpath()
      • boolmask()
      • chunks
        • chunks._new_iterator()
        • chunks.noborder()
        • chunks.cycle()
        • chunks.replicate()
      • cmd()
      • codeblock()
      • color_text()
      • compatible()
      • compress()
      • ddict
      • delete()
      • dict_diff()
      • dict_hist()
      • dict_isect()
      • dict_subset()
      • dict_union()
      • download()
      • dzip()
      • ensure_app_cache_dir()
      • ensure_app_config_dir()
      • ensure_app_data_dir()
      • ensure_unicode()
      • ensuredir()
      • expandpath()
      • find_duplicates()
      • find_exe()
      • find_path()
      • flatten()
      • get_app_cache_dir()
      • get_app_config_dir()
      • get_app_data_dir()
      • grabdata()
      • group_items()
      • hash_data()
      • hash_file()
      • highlight_code()
      • hzcat()
      • identity()
      • import_module_from_name()
      • import_module_from_path()
      • indent()
      • indexable_allclose()
      • inject_method()
      • invert_dict()
      • iter_window()
      • iterable()
      • map_keys()
      • map_vals()
      • map_values()
      • memoize()
      • memoize_method
      • memoize_property()
      • modname_to_modpath()
      • modpath_to_modname()
      • named_product()
      • odict
      • oset
      • paragraph()
      • peek()
      • platform_cache_dir()
      • platform_config_dir()
      • platform_data_dir()
      • readfrom()
      • repr2()
      • schedule_deprecation()
      • sdict
      • shrinkuser()
      • sorted_keys()
      • sorted_vals()
      • sorted_values()
      • split_archive()
      • split_modpath()
      • symlink()
      • take()
      • timeparse()
      • timestamp()
      • touch()
      • udict
      • unique()
      • unique_flags()
      • urepr()
      • userhome()
      • varied_values()
      • writeto()
      • zopen
        • zopen.zfile
        • zopen.namelist()
        • zopen._cleanup()
        • zopen._split_archive()
        • zopen._open()
  • ubelt
    • ubelt package
      • Submodules
        • ubelt.__main__ module
        • ubelt._win32_links module
          • _win32_can_symlink()
          • _symlink()
          • _win32_symlink2()
          • _win32_symlink()
          • _win32_junction()
          • _win32_is_junction()
          • _is_reparse_point()
          • _win32_read_junction()
          • _win32_rmtree()
          • _win32_is_hardlinked()
          • _win32_dir()
        • ubelt.orderedset module
          • OrderedSet
            • OrderedSet.copy()
            • OrderedSet.add()
            • OrderedSet.append()
            • OrderedSet.update()
            • OrderedSet.index()
            • OrderedSet.get_loc()
            • OrderedSet.get_indexer()
            • OrderedSet.pop()
            • OrderedSet.discard()
            • OrderedSet.clear()
            • OrderedSet.union()
            • OrderedSet.intersection()
            • OrderedSet.difference()
            • OrderedSet.issubset()
            • OrderedSet.issuperset()
            • OrderedSet.symmetric_difference()
            • OrderedSet._update_items()
            • OrderedSet.difference_update()
            • OrderedSet.intersection_update()
            • OrderedSet.symmetric_difference_update()
            • OrderedSet._abc_impl
          • oset
        • ubelt.progiter module
          • ProgIter
            • ProgIter.set_extra()
            • ProgIter._reset_internals()
            • ProgIter.begin()
            • ProgIter.end()
            • ProgIter._iterate()
            • ProgIter._homogeneous_check()
            • ProgIter._slow_path_step_body()
            • ProgIter.step()
            • ProgIter._adjust_frequency()
            • ProgIter._measure_time()
            • ProgIter._update_message_template()
            • ProgIter._build_message_template()
            • ProgIter.format_message()
            • ProgIter.format_message_parts()
            • ProgIter.ensure_newline()
            • ProgIter.display_message()
            • ProgIter._tryflush()
            • ProgIter._write()
        • ubelt.util_arg module
          • argval()
          • argflag()
        • ubelt.util_cache module
          • Cacher
            • Cacher.VERBOSE
            • Cacher.FORCE_DISABLE
            • Cacher._rectify_cfgstr()
            • Cacher._condense_cfgstr()
            • Cacher.fpath
            • Cacher.get_fpath()
            • Cacher.exists()
            • Cacher.existing_versions()
            • Cacher.clear()
            • Cacher.tryload()
            • Cacher.load()
            • Cacher.save()
            • Cacher._backend_load()
            • Cacher._backend_dump()
            • Cacher.ensure()
          • CacheStamp
            • CacheStamp.fpath
            • CacheStamp.clear()
            • CacheStamp._get_certificate()
            • CacheStamp._rectify_products()
            • CacheStamp._rectify_hash_prefixes()
            • CacheStamp._product_info()
            • CacheStamp._product_file_stats()
            • CacheStamp._product_file_hash()
            • CacheStamp.expired()
            • CacheStamp._check_certificate_hashes()
            • CacheStamp._expires()
            • CacheStamp._new_certificate()
            • CacheStamp.renew()
          • _localnow()
          • _byte_str()
        • ubelt.util_cmd module
          • cmd()
        • ubelt.util_colors module
          • highlight_code()
          • _pygments_highlight()
          • _rich_highlight()
          • color_text()
        • ubelt.util_const module
        • ubelt.util_deprecate module
          • schedule_deprecation()
        • ubelt.util_dict module
          • AutoDict
            • AutoDict._base
            • AutoDict.to_dict()
          • AutoOrderedDict
          • dzip()
          • ddict
          • dict_hist()
          • dict_subset()
          • dict_union()
          • dict_isect()
          • dict_diff()
          • find_duplicates()
          • group_items()
          • invert_dict()
          • map_keys()
          • map_vals()
          • map_values()
          • sorted_keys()
          • sorted_vals()
          • sorted_values()
          • odict
          • named_product()
          • varied_values()
          • SetDict
            • SetDict.copy()
            • SetDict.union()
            • SetDict.intersection()
            • SetDict.difference()
            • SetDict.symmetric_difference()
          • UDict
            • UDict.subdict()
            • UDict.take()
            • UDict.invert()
            • UDict.map_keys()
            • UDict.map_values()
            • UDict.sorted_keys()
            • UDict.sorted_values()
            • UDict.peek_key()
            • UDict.peek_value()
          • sdict
          • udict
        • ubelt.util_download module
          • download()
          • grabdata()
        • ubelt.util_download_manager module
          • DownloadManager
            • DownloadManager.submit()
            • DownloadManager.as_completed()
            • DownloadManager.shutdown()
        • ubelt.util_format module
          • repr2()
          • urepr()
          • FormatterExtensions
        • ubelt.util_func module
          • identity()
          • inject_method()
          • compatible()
        • ubelt.util_futures module
          • Executor
            • Executor.submit()
            • Executor.shutdown()
            • Executor.map()
          • JobPool
            • JobPool.submit()
            • JobPool.shutdown()
            • JobPool._clear_completed()
            • JobPool.as_completed()
            • JobPool.join()
        • ubelt.util_hash module
          • hash_data()
          • hash_file()
        • ubelt.util_import module
          • split_modpath()
          • modname_to_modpath()
          • modpath_to_modname()
          • import_module_from_name()
          • import_module_from_path()
        • ubelt.util_indexable module
          • _lazy_numpy()
          • Difference
            • Difference.path
            • Difference.value1
            • Difference.value2
            • Difference._asdict()
            • Difference._field_defaults
            • Difference._fields
            • Difference._make()
            • Difference._replace()
          • IndexableWalker
            • IndexableWalker.send()
            • IndexableWalker.throw()
            • IndexableWalker._walk()
            • IndexableWalker.allclose()
            • IndexableWalker.diff()
            • IndexableWalker._abc_impl
          • _make_isclose_fn()
          • indexable_allclose()
        • ubelt.util_io module
          • readfrom()
          • writeto()
          • touch()
          • delete()
        • ubelt.util_links module
          • symlink()
        • ubelt.util_list module
          • allsame()
          • argmax()
          • argmin()
          • argsort()
          • argunique()
          • boolmask()
          • chunks
            • chunks._new_iterator()
            • chunks.noborder()
            • chunks.cycle()
            • chunks.replicate()
          • compress()
          • flatten()
          • iter_window()
          • iterable()
          • peek()
          • take()
          • unique()
          • unique_flags()
        • ubelt.util_memoize module
          • memoize()
          • memoize_method
          • memoize_property()
        • ubelt.util_mixins module
          • NiceRepr
        • ubelt.util_path module
          • Path
            • Path.appdir()
            • Path.augment()
            • Path.delete()
            • Path.ensuredir()
            • Path.mkdir()
            • Path.expand()
            • Path.expandvars()
            • Path.ls()
            • Path.shrinkuser()
            • Path.chmod()
            • Path.touch()
            • Path.walk()
            • Path.endswith()
            • Path.startswith()
            • Path._request_copy_function()
            • Path.copy()
            • Path.move()
          • TempDir
            • TempDir.ensure()
            • TempDir.cleanup()
            • TempDir.start()
          • augpath()
          • shrinkuser()
          • userhome()
          • ensuredir()
          • expandpath()
          • ChDir
        • ubelt.util_platform module
          • find_exe()
          • find_path()
          • ensure_app_cache_dir()
          • ensure_app_config_dir()
          • ensure_app_data_dir()
          • get_app_cache_dir()
          • get_app_config_dir()
          • get_app_data_dir()
          • platform_cache_dir()
          • platform_config_dir()
          • platform_data_dir()
        • ubelt.util_repr module
          • urepr()
          • ReprExtensions
            • ReprExtensions.register()
            • ReprExtensions.lookup()
            • ReprExtensions._register_pandas_extensions()
            • ReprExtensions._register_numpy_extensions()
            • ReprExtensions._register_builtin_extensions()
        • ubelt.util_str module
          • indent()
          • codeblock()
          • paragraph()
          • hzcat()
          • ensure_unicode()
        • ubelt.util_stream module
          • TeeStringIO
            • TeeStringIO.isatty()
            • TeeStringIO.fileno()
            • TeeStringIO.encoding
            • TeeStringIO.write()
            • TeeStringIO.flush()
          • CaptureStdout
            • CaptureStdout.log_part()
            • CaptureStdout.start()
            • CaptureStdout.stop()
            • CaptureStdout.close()
          • CaptureStream
        • ubelt.util_time module
          • timestamp()
          • timeparse()
          • Timer
            • Timer._default_time()
            • Timer.tic()
            • Timer.toc()
        • ubelt.util_zip module
          • zopen
            • zopen.zfile
            • zopen.namelist()
            • zopen._cleanup()
            • zopen._split_archive()
            • zopen._open()
          • split_archive()
      • Module contents
        • AutoDict
          • AutoDict._base
          • AutoDict.to_dict()
        • AutoOrderedDict
        • CacheStamp
          • CacheStamp.fpath
          • CacheStamp.clear()
          • CacheStamp._get_certificate()
          • CacheStamp._rectify_products()
          • CacheStamp._rectify_hash_prefixes()
          • CacheStamp._product_info()
          • CacheStamp._product_file_stats()
          • CacheStamp._product_file_hash()
          • CacheStamp.expired()
          • CacheStamp._check_certificate_hashes()
          • CacheStamp._expires()
          • CacheStamp._new_certificate()
          • CacheStamp.renew()
        • Cacher
          • Cacher.VERBOSE
          • Cacher.FORCE_DISABLE
          • Cacher._rectify_cfgstr()
          • Cacher._condense_cfgstr()
          • Cacher.fpath
          • Cacher.get_fpath()
          • Cacher.exists()
          • Cacher.existing_versions()
          • Cacher.clear()
          • Cacher.tryload()
          • Cacher.load()
          • Cacher.save()
          • Cacher._backend_load()
          • Cacher._backend_dump()
          • Cacher.ensure()
        • CaptureStdout
          • CaptureStdout.log_part()
          • CaptureStdout.start()
          • CaptureStdout.stop()
          • CaptureStdout.close()
        • CaptureStream
        • ChDir
        • DownloadManager
          • DownloadManager.submit()
          • DownloadManager.as_completed()
          • DownloadManager.shutdown()
        • Executor
          • Executor.submit()
          • Executor.shutdown()
          • Executor.map()
        • FormatterExtensions
        • IndexableWalker
          • IndexableWalker.send()
          • IndexableWalker.throw()
          • IndexableWalker._walk()
          • IndexableWalker.allclose()
          • IndexableWalker.diff()
          • IndexableWalker._abc_impl
        • JobPool
          • JobPool.submit()
          • JobPool.shutdown()
          • JobPool._clear_completed()
          • JobPool.as_completed()
          • JobPool.join()
        • NiceRepr
        • OrderedSet
          • OrderedSet.copy()
          • OrderedSet.add()
          • OrderedSet.append()
          • OrderedSet.update()
          • OrderedSet.index()
          • OrderedSet.get_loc()
          • OrderedSet.get_indexer()
          • OrderedSet.pop()
          • OrderedSet.discard()
          • OrderedSet.clear()
          • OrderedSet.union()
          • OrderedSet.intersection()
          • OrderedSet.difference()
          • OrderedSet.issubset()
          • OrderedSet.issuperset()
          • OrderedSet.symmetric_difference()
          • OrderedSet._update_items()
          • OrderedSet.difference_update()
          • OrderedSet.intersection_update()
          • OrderedSet.symmetric_difference_update()
          • OrderedSet._abc_impl
        • Path
          • Path.appdir()
          • Path.augment()
          • Path.delete()
          • Path.ensuredir()
          • Path.mkdir()
          • Path.expand()
          • Path.expandvars()
          • Path.ls()
          • Path.shrinkuser()
          • Path.chmod()
          • Path.touch()
          • Path.walk()
          • Path.endswith()
          • Path.startswith()
          • Path._request_copy_function()
          • Path.copy()
          • Path.move()
        • ProgIter
          • ProgIter.set_extra()
          • ProgIter._reset_internals()
          • ProgIter.begin()
          • ProgIter.end()
          • ProgIter._iterate()
          • ProgIter._homogeneous_check()
          • ProgIter._slow_path_step_body()
          • ProgIter.step()
          • ProgIter._adjust_frequency()
          • ProgIter._measure_time()
          • ProgIter._update_message_template()
          • ProgIter._build_message_template()
          • ProgIter.format_message()
          • ProgIter.format_message_parts()
          • ProgIter.ensure_newline()
          • ProgIter.display_message()
          • ProgIter._tryflush()
          • ProgIter._write()
        • ReprExtensions
          • ReprExtensions.register()
          • ReprExtensions.lookup()
          • ReprExtensions._register_pandas_extensions()
          • ReprExtensions._register_numpy_extensions()
          • ReprExtensions._register_builtin_extensions()
        • SetDict
          • SetDict.copy()
          • SetDict.union()
          • SetDict.intersection()
          • SetDict.difference()
          • SetDict.symmetric_difference()
        • TeeStringIO
          • TeeStringIO.isatty()
          • TeeStringIO.fileno()
          • TeeStringIO.encoding
          • TeeStringIO.write()
          • TeeStringIO.flush()
        • TempDir
          • TempDir.ensure()
          • TempDir.cleanup()
          • TempDir.start()
        • Timer
          • Timer._default_time()
          • Timer.tic()
          • Timer.toc()
        • UDict
          • UDict.subdict()
          • UDict.take()
          • UDict.invert()
          • UDict.map_keys()
          • UDict.map_values()
          • UDict.sorted_keys()
          • UDict.sorted_values()
          • UDict.peek_key()
          • UDict.peek_value()
        • allsame()
        • argflag()
        • argmax()
        • argmin()
        • argsort()
        • argunique()
        • argval()
        • augpath()
        • boolmask()
        • chunks
          • chunks._new_iterator()
          • chunks.noborder()
          • chunks.cycle()
          • chunks.replicate()
        • cmd()
        • codeblock()
        • color_text()
        • compatible()
        • compress()
        • ddict
        • delete()
        • dict_diff()
        • dict_hist()
        • dict_isect()
        • dict_subset()
        • dict_union()
        • download()
        • dzip()
        • ensure_app_cache_dir()
        • ensure_app_config_dir()
        • ensure_app_data_dir()
        • ensure_unicode()
        • ensuredir()
        • expandpath()
        • find_duplicates()
        • find_exe()
        • find_path()
        • flatten()
        • get_app_cache_dir()
        • get_app_config_dir()
        • get_app_data_dir()
        • grabdata()
        • group_items()
        • hash_data()
        • hash_file()
        • highlight_code()
        • hzcat()
        • identity()
        • import_module_from_name()
        • import_module_from_path()
        • indent()
        • indexable_allclose()
        • inject_method()
        • invert_dict()
        • iter_window()
        • iterable()
        • map_keys()
        • map_vals()
        • map_values()
        • memoize()
        • memoize_method
        • memoize_property()
        • modname_to_modpath()
        • modpath_to_modname()
        • named_product()
        • odict
        • oset
        • paragraph()
        • peek()
        • platform_cache_dir()
        • platform_config_dir()
        • platform_data_dir()
        • readfrom()
        • repr2()
        • schedule_deprecation()
        • sdict
        • shrinkuser()
        • sorted_keys()
        • sorted_vals()
        • sorted_values()
        • split_archive()
        • split_modpath()
        • symlink()
        • take()
        • timeparse()
        • timestamp()
        • touch()
        • udict
        • unique()
        • unique_flags()
        • urepr()
        • userhome()
        • varied_values()
        • writeto()
        • zopen
          • zopen.zfile
          • zopen.namelist()
          • zopen._cleanup()
          • zopen._split_archive()
          • zopen._open()
ubelt
  • ubelt package
  • ubelt._win32_links module
  • View page source

ubelt._win32_links module¶

For dealing with symlinks, junctions, and hard-links on windows.

Note

The terminology used here was written before I really understood the difference between symlinks, hardlinks, and junctions. As such it may be inconsistent or incorrect in some places. This might be fixed in the future.

References

[SO18883892]

https://stackoverflow.com/questions/18883892/batch-file-windows-cmd-exe-test-if-a-directory-is-a-link-symlink

[SO21561850]

https://stackoverflow.com/questions/21561850/python-test-for-junction-point-target

[WinTwoFilesSame]

http://timgolden.me.uk/python/win32_how_do_i/see_if_two_files_are_the_same_file.html

[SO6260149]

https://stackoverflow.com/questions/6260149/os-symlink-support-in-windows

[WinDesktopAA365006]

https://msdn.microsoft.com/en-us/library/windows/desktop/aa365006(v=vs.85).aspx

[SU902082]

https://superuser.com/a/902082/215232

Weird Behavior:
  • [ ] In many cases using the win32 API seems to result in privilege errors

    but using shell commands does not have this problem.

ubelt._win32_links._win32_can_symlink(verbose=0, force=False, testing=False)[source]¶
Parameters:
  • verbose (int) – verbosity level

  • force (bool) – flag

  • testing (bool) – flag

Example

>>> # xdoctest: +REQUIRES(WIN32)
>>> import ubelt as ub
>>> _win32_can_symlink(verbose=3, force=True, testing=True)
ubelt._win32_links._symlink(path, link, overwrite=0, verbose=0)[source]¶

Windows helper for ub.symlink

ubelt._win32_links._win32_symlink2(path, link, allow_fallback=True, verbose=0)[source]¶

Perform a real symbolic link if possible. However, on most versions of windows you need special privileges to create a real symlink. Therefore, we try to create a symlink, but if that fails we fallback to using a junction.

AFAIK, the main difference between symlinks and junctions are that symlinks can reference relative or absolute paths, where as junctions always reference absolute paths. Not 100% on this though. Windows is weird.

Note that junctions will not register as links via islink, but I believe real symlinks will.

ubelt._win32_links._win32_symlink(path, link, verbose=0)[source]¶

Creates real symlink. This will only work in versions greater than Windows Vista. Creating real symlinks requires admin permissions or at least specially enabled symlink permissions. On Windows 10 enabling developer mode should give you these permissions.

ubelt._win32_links._win32_junction(path, link, verbose=0)[source]¶

On older (pre 10) versions of windows we need admin privileges to make symlinks, however junctions seem to work.

For paths we do a junction (softlink) and for files we use a hard link

Example

>>> # xdoc: +REQUIRES(WIN32)
>>> import ubelt as ub
>>> root = ub.Path.appdir('ubelt', 'win32_junction').ensuredir()
>>> ub.delete(root)
>>> ub.ensuredir(root)
>>> fpath = join(root, 'fpath.txt')
>>> dpath = join(root, 'dpath')
>>> fjunc = join(root, 'fjunc.txt')
>>> djunc = join(root, 'djunc')
>>> ub.touch(fpath)
>>> ub.ensuredir(dpath)
>>> ub.ensuredir(join(root, 'djunc_fake'))
>>> ub.ensuredir(join(root, 'djunc_fake with space'))
>>> ub.touch(join(root, 'djunc_fake with space file'))
>>> _win32_junction(fpath, fjunc)
>>> _win32_junction(dpath, djunc)
>>> # thank god colons are not allowed
>>> djunc2 = join(root, 'djunc2 [with pathological attrs]')
>>> _win32_junction(dpath, djunc2)
>>> _win32_is_junction(djunc)
>>> ub.writeto(join(djunc, 'afile.txt'), 'foo')
>>> assert ub.readfrom(join(dpath, 'afile.txt')) == 'foo'
>>> ub.writeto(fjunc, 'foo')
ubelt._win32_links._win32_is_junction(path)[source]¶

Determines if a path is a win32 junction

Note

on PyPy this is bugged and will currently return True for a symlinked directory.

Return type:

bool

Example

>>> # xdoctest: +REQUIRES(WIN32)
>>> from ubelt._win32_links import _win32_junction, _win32_is_junction
>>> import ubelt as ub
>>> root = ub.Path.appdir('ubelt', 'win32_junction').ensuredir()
>>> ub.delete(root)
>>> ub.ensuredir(root)
>>> dpath = root / 'dpath'
>>> djunc = root / 'djunc'
>>> dpath.ensuredir()
>>> _win32_junction(dpath, djunc)
>>> assert _win32_is_junction(djunc) is True
>>> assert _win32_is_junction(dpath) is False
>>> assert _win32_is_junction('notafile') is False
ubelt._win32_links._is_reparse_point(path)[source]¶

Check if a directory is a reparse point in windows.

Note: a reparse point seems like it could be a junction or symlink.

[SO54678399]

https://stackoverflow.com/a/54678399/887074

ubelt._win32_links._win32_read_junction(path)[source]¶

Returns the location that the junction points, raises ValueError if path is not a junction.

Example

>>> # xdoc: +REQUIRES(WIN32)
>>> import ubelt as ub
>>> root = ub.Path.appdir('ubelt', 'win32_junction').ensuredir()
>>> ub.delete(root)
>>> ub.ensuredir(root)
>>> dpath = join(root, 'dpath')
>>> djunc = join(root, 'djunc')
>>> ub.ensuredir(dpath)
>>> _win32_junction(dpath, djunc)
>>> path = djunc
>>> pointed = _win32_read_junction(path)
>>> print('pointed = {!r}'.format(pointed))
ubelt._win32_links._win32_rmtree(path, verbose=0)[source]¶

rmtree for win32 that treats junctions like directory symlinks. The junction removal portion may not be safe on race conditions.

There is a known issue [CPythonBug31226] that prevents shutil.rmtree() from deleting directories with junctions.

References

[CPythonBug31226]

https://bugs.python.org/issue31226

ubelt._win32_links._win32_is_hardlinked(fpath1, fpath2)[source]¶

Test if two hard links point to the same location

Example

>>> # xdoc: +REQUIRES(WIN32)
>>> import ubelt as ub
>>> root = ub.Path.appdir('ubelt', 'win32_hardlink').ensuredir()
>>> ub.delete(root)
>>> ub.ensuredir(root)
>>> fpath1 = join(root, 'fpath1')
>>> fpath2 = join(root, 'fpath2')
>>> ub.touch(fpath1)
>>> ub.touch(fpath2)
>>> fjunc1 = _win32_junction(fpath1, join(root, 'fjunc1'))
>>> fjunc2 = _win32_junction(fpath2, join(root, 'fjunc2'))
>>> assert _win32_is_hardlinked(fjunc1, fpath1)
>>> assert _win32_is_hardlinked(fjunc2, fpath2)
>>> assert not _win32_is_hardlinked(fjunc2, fpath1)
>>> assert not _win32_is_hardlinked(fjunc1, fpath2)
ubelt._win32_links._win32_dir(path, star='')[source]¶

Using the windows cmd shell to get information about a directory

Previous Next

© Copyright 2024, Jon Crall.

Built with Sphinx using a theme provided by Read the Docs.