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.items
          • OrderedSet.map
          • 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._abc_impl
          • OrderedSet.issuperset()
          • OrderedSet.symmetric_difference()
          • OrderedSet._update_items()
          • OrderedSet.difference_update()
          • OrderedSet.intersection_update()
          • OrderedSet.symmetric_difference_update()
        • oset
      • ubelt.progiter module
        • ProgIter
          • ProgIter.stream
          • ProgIter.iterable
          • ProgIter.desc
          • ProgIter.total
          • ProgIter.freq
          • ProgIter.initial
          • ProgIter.enabled
          • ProgIter.adjust
          • ProgIter.show_percent
          • ProgIter.show_times
          • ProgIter.show_rate
          • ProgIter.show_eta
          • ProgIter.show_total
          • ProgIter.show_wall
          • ProgIter.eta_window
          • ProgIter.time_thresh
          • ProgIter.clearline
          • ProgIter.chunksize
          • ProgIter.rel_adjust_limit
          • ProgIter.extra
          • ProgIter._extra_fn
          • ProgIter.started
          • ProgIter.finished
          • ProgIter.homogeneous
          • ProgIter._likely_homogeneous
          • ProgIter._abc_impl
          • ProgIter._est_seconds_left
          • ProgIter.__call__()
          • 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.dpath
          • Cacher.fname
          • Cacher.depends
          • Cacher.cfgstr
          • Cacher.verbose
          • Cacher.ext
          • Cacher.meta
          • Cacher.enabled
          • Cacher.protocol
          • Cacher.hasher
          • Cacher.log
          • Cacher.backend
          • 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()
          • Cacher.__call__()
        • CacheStamp
          • CacheStamp.cacher
          • CacheStamp.product
          • CacheStamp.hasher
          • CacheStamp.expires
          • CacheStamp.hash_prefix
          • 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._pool
          • DownloadManager.download_root
          • DownloadManager.cache
          • DownloadManager._dl_func
          • DownloadManager.submit()
          • DownloadManager.as_completed()
          • DownloadManager.shutdown()
      • ubelt.util_format module
        • repr2()
        • urepr()
        • FormatterExtensions
      • ubelt.util_func module
        • SupportsBool
          • SupportsBool._abc_impl
          • SupportsBool._is_protocol
        • identity()
        • inject_method()
        • compatible()
      • ubelt.util_futures module
        • Executor
          • Executor.backend
          • Executor.submit()
          • Executor.shutdown()
          • Executor.map()
        • JobPool
          • JobPool.executor
          • JobPool.transient
          • JobPool.jobs
          • 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.data
          • IndexableWalker.dict_cls
          • IndexableWalker.list_cls
          • IndexableWalker.indexable_cls
          • IndexableWalker._walk_gen
          • IndexableWalker.send()
          • IndexableWalker.throw()
          • IndexableWalker.keys()
          • IndexableWalker.values()
          • IndexableWalker._abc_impl
          • IndexableWalker._walk()
          • IndexableWalker.allclose()
          • IndexableWalker.diff()
        • _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.remainder
          • chunks.items
          • chunks.chunksize
          • chunks.bordermode
          • chunks._new_iterator()
          • chunks.noborder()
          • chunks.cycle()
          • chunks.replicate()
          • chunks._abc_impl
        • 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.relative_to()
          • Path.walk()
          • Path.endswith()
          • Path.startswith()
          • Path._request_copy_function()
          • Path.copy()
          • Path.move()
        • TempDir
          • TempDir.dpath
          • 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._get_stream()
          • CaptureStdout._set_stream()
          • CaptureStdout.cap_stdout
          • CaptureStdout.orig_stdout
        • CaptureStderr
          • CaptureStderr._get_stream()
          • CaptureStderr._set_stream()
        • CaptureStream
          • CaptureStream._get_stream()
          • CaptureStream._set_stream()
          • CaptureStream._make_proxy()
          • CaptureStream.log_part()
          • CaptureStream.start()
          • CaptureStream.stop()
          • CaptureStream.close()
      • ubelt.util_time module
        • timestamp()
        • timeparse()
        • Timer
          • Timer._default_time()
          • Timer.label
          • Timer.verbose
          • Timer.newline
          • Timer.tstart
          • Timer.elapsed
          • Timer.write
          • Timer.flush
          • Timer.ns
          • Timer._time
          • Timer.tic()
          • Timer.toc()
      • ubelt.util_zip module
        • zopen
          • zopen.fpath
          • zopen.ext
          • zopen.name
          • zopen.mode
          • zopen._zfpath
          • zopen._temp_dpath
          • zopen._zfile_read
          • zopen._handle
          • zopen.zfile
          • zopen.namelist()
          • zopen._cleanup()
          • zopen._split_archive()
          • zopen._open()
        • split_archive()
    • Module contents
      • AutoDict
        • AutoDict._base
        • AutoDict.to_dict()
      • AutoOrderedDict
      • CacheStamp
        • CacheStamp.cacher
        • CacheStamp.product
        • CacheStamp.hasher
        • CacheStamp.expires
        • CacheStamp.hash_prefix
        • 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.dpath
        • Cacher.fname
        • Cacher.depends
        • Cacher.cfgstr
        • Cacher.verbose
        • Cacher.ext
        • Cacher.meta
        • Cacher.enabled
        • Cacher.protocol
        • Cacher.hasher
        • Cacher.log
        • Cacher.backend
        • 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()
        • Cacher.__call__()
      • CaptureStdout
        • CaptureStdout._get_stream()
        • CaptureStdout._set_stream()
        • CaptureStdout.cap_stdout
        • CaptureStdout.orig_stdout
      • CaptureStream
        • CaptureStream._get_stream()
        • CaptureStream._set_stream()
        • CaptureStream._make_proxy()
        • CaptureStream.log_part()
        • CaptureStream.start()
        • CaptureStream.stop()
        • CaptureStream.close()
      • ChDir
      • DownloadManager
        • DownloadManager._pool
        • DownloadManager.download_root
        • DownloadManager.cache
        • DownloadManager._dl_func
        • DownloadManager.submit()
        • DownloadManager.as_completed()
        • DownloadManager.shutdown()
      • Executor
        • Executor.backend
        • Executor.submit()
        • Executor.shutdown()
        • Executor.map()
      • FormatterExtensions
      • IndexableWalker
        • IndexableWalker.data
        • IndexableWalker.dict_cls
        • IndexableWalker.list_cls
        • IndexableWalker.indexable_cls
        • IndexableWalker._walk_gen
        • IndexableWalker.send()
        • IndexableWalker.throw()
        • IndexableWalker.keys()
        • IndexableWalker.values()
        • IndexableWalker._abc_impl
        • IndexableWalker._walk()
        • IndexableWalker.allclose()
        • IndexableWalker.diff()
      • JobPool
        • JobPool.executor
        • JobPool.transient
        • JobPool.jobs
        • JobPool.submit()
        • JobPool.shutdown()
        • JobPool._clear_completed()
        • JobPool.as_completed()
        • JobPool.join()
      • NiceRepr
      • OrderedSet
        • OrderedSet.items
        • OrderedSet.map
        • 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._abc_impl
        • OrderedSet.issuperset()
        • OrderedSet.symmetric_difference()
        • OrderedSet._update_items()
        • OrderedSet.difference_update()
        • OrderedSet.intersection_update()
        • OrderedSet.symmetric_difference_update()
      • Path
        • Path.appdir()
        • Path.augment()
        • Path.delete()
        • Path.ensuredir()
        • Path.mkdir()
        • Path.expand()
        • Path.expandvars()
        • Path.ls()
        • Path.shrinkuser()
        • Path.chmod()
        • Path.touch()
        • Path.relative_to()
        • Path.walk()
        • Path.endswith()
        • Path.startswith()
        • Path._request_copy_function()
        • Path.copy()
        • Path.move()
      • ProgIter
        • ProgIter.stream
        • ProgIter.iterable
        • ProgIter.desc
        • ProgIter.total
        • ProgIter.freq
        • ProgIter.initial
        • ProgIter.enabled
        • ProgIter.adjust
        • ProgIter.show_percent
        • ProgIter.show_times
        • ProgIter.show_rate
        • ProgIter.show_eta
        • ProgIter.show_total
        • ProgIter.show_wall
        • ProgIter.eta_window
        • ProgIter.time_thresh
        • ProgIter.clearline
        • ProgIter.chunksize
        • ProgIter.rel_adjust_limit
        • ProgIter.extra
        • ProgIter._extra_fn
        • ProgIter.started
        • ProgIter.finished
        • ProgIter.homogeneous
        • ProgIter._abc_impl
        • ProgIter.__call__()
        • 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.dpath
        • TempDir.ensure()
        • TempDir.cleanup()
        • TempDir.start()
      • Timer
        • Timer._default_time()
        • Timer.label
        • Timer.verbose
        • Timer.newline
        • Timer.tstart
        • Timer.elapsed
        • Timer.write
        • Timer.flush
        • Timer.ns
        • Timer._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()
        • chunks._abc_impl
      • 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.fpath
        • zopen.ext
        • zopen.name
        • zopen.mode
        • 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.items
            • OrderedSet.map
            • 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._abc_impl
            • OrderedSet.issuperset()
            • OrderedSet.symmetric_difference()
            • OrderedSet._update_items()
            • OrderedSet.difference_update()
            • OrderedSet.intersection_update()
            • OrderedSet.symmetric_difference_update()
          • oset
        • ubelt.progiter module
          • ProgIter
            • ProgIter.stream
            • ProgIter.iterable
            • ProgIter.desc
            • ProgIter.total
            • ProgIter.freq
            • ProgIter.initial
            • ProgIter.enabled
            • ProgIter.adjust
            • ProgIter.show_percent
            • ProgIter.show_times
            • ProgIter.show_rate
            • ProgIter.show_eta
            • ProgIter.show_total
            • ProgIter.show_wall
            • ProgIter.eta_window
            • ProgIter.time_thresh
            • ProgIter.clearline
            • ProgIter.chunksize
            • ProgIter.rel_adjust_limit
            • ProgIter.extra
            • ProgIter._extra_fn
            • ProgIter.started
            • ProgIter.finished
            • ProgIter.homogeneous
            • ProgIter._likely_homogeneous
            • ProgIter._abc_impl
            • ProgIter._est_seconds_left
            • ProgIter.__call__()
            • 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.dpath
            • Cacher.fname
            • Cacher.depends
            • Cacher.cfgstr
            • Cacher.verbose
            • Cacher.ext
            • Cacher.meta
            • Cacher.enabled
            • Cacher.protocol
            • Cacher.hasher
            • Cacher.log
            • Cacher.backend
            • 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()
            • Cacher.__call__()
          • CacheStamp
            • CacheStamp.cacher
            • CacheStamp.product
            • CacheStamp.hasher
            • CacheStamp.expires
            • CacheStamp.hash_prefix
            • 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._pool
            • DownloadManager.download_root
            • DownloadManager.cache
            • DownloadManager._dl_func
            • DownloadManager.submit()
            • DownloadManager.as_completed()
            • DownloadManager.shutdown()
        • ubelt.util_format module
          • repr2()
          • urepr()
          • FormatterExtensions
        • ubelt.util_func module
          • SupportsBool
            • SupportsBool._abc_impl
            • SupportsBool._is_protocol
          • identity()
          • inject_method()
          • compatible()
        • ubelt.util_futures module
          • Executor
            • Executor.backend
            • Executor.submit()
            • Executor.shutdown()
            • Executor.map()
          • JobPool
            • JobPool.executor
            • JobPool.transient
            • JobPool.jobs
            • 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.data
            • IndexableWalker.dict_cls
            • IndexableWalker.list_cls
            • IndexableWalker.indexable_cls
            • IndexableWalker._walk_gen
            • IndexableWalker.send()
            • IndexableWalker.throw()
            • IndexableWalker.keys()
            • IndexableWalker.values()
            • IndexableWalker._abc_impl
            • IndexableWalker._walk()
            • IndexableWalker.allclose()
            • IndexableWalker.diff()
          • _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.remainder
            • chunks.items
            • chunks.chunksize
            • chunks.bordermode
            • chunks._new_iterator()
            • chunks.noborder()
            • chunks.cycle()
            • chunks.replicate()
            • chunks._abc_impl
          • 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.relative_to()
            • Path.walk()
            • Path.endswith()
            • Path.startswith()
            • Path._request_copy_function()
            • Path.copy()
            • Path.move()
          • TempDir
            • TempDir.dpath
            • 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._get_stream()
            • CaptureStdout._set_stream()
            • CaptureStdout.cap_stdout
            • CaptureStdout.orig_stdout
          • CaptureStderr
            • CaptureStderr._get_stream()
            • CaptureStderr._set_stream()
          • CaptureStream
            • CaptureStream._get_stream()
            • CaptureStream._set_stream()
            • CaptureStream._make_proxy()
            • CaptureStream.log_part()
            • CaptureStream.start()
            • CaptureStream.stop()
            • CaptureStream.close()
        • ubelt.util_time module
          • timestamp()
          • timeparse()
          • Timer
            • Timer._default_time()
            • Timer.label
            • Timer.verbose
            • Timer.newline
            • Timer.tstart
            • Timer.elapsed
            • Timer.write
            • Timer.flush
            • Timer.ns
            • Timer._time
            • Timer.tic()
            • Timer.toc()
        • ubelt.util_zip module
          • zopen
            • zopen.fpath
            • zopen.ext
            • zopen.name
            • zopen.mode
            • zopen._zfpath
            • zopen._temp_dpath
            • zopen._zfile_read
            • zopen._handle
            • zopen.zfile
            • zopen.namelist()
            • zopen._cleanup()
            • zopen._split_archive()
            • zopen._open()
          • split_archive()
      • Module contents
        • AutoDict
          • AutoDict._base
          • AutoDict.to_dict()
        • AutoOrderedDict
        • CacheStamp
          • CacheStamp.cacher
          • CacheStamp.product
          • CacheStamp.hasher
          • CacheStamp.expires
          • CacheStamp.hash_prefix
          • 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.dpath
          • Cacher.fname
          • Cacher.depends
          • Cacher.cfgstr
          • Cacher.verbose
          • Cacher.ext
          • Cacher.meta
          • Cacher.enabled
          • Cacher.protocol
          • Cacher.hasher
          • Cacher.log
          • Cacher.backend
          • 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()
          • Cacher.__call__()
        • CaptureStdout
          • CaptureStdout._get_stream()
          • CaptureStdout._set_stream()
          • CaptureStdout.cap_stdout
          • CaptureStdout.orig_stdout
        • CaptureStream
          • CaptureStream._get_stream()
          • CaptureStream._set_stream()
          • CaptureStream._make_proxy()
          • CaptureStream.log_part()
          • CaptureStream.start()
          • CaptureStream.stop()
          • CaptureStream.close()
        • ChDir
        • DownloadManager
          • DownloadManager._pool
          • DownloadManager.download_root
          • DownloadManager.cache
          • DownloadManager._dl_func
          • DownloadManager.submit()
          • DownloadManager.as_completed()
          • DownloadManager.shutdown()
        • Executor
          • Executor.backend
          • Executor.submit()
          • Executor.shutdown()
          • Executor.map()
        • FormatterExtensions
        • IndexableWalker
          • IndexableWalker.data
          • IndexableWalker.dict_cls
          • IndexableWalker.list_cls
          • IndexableWalker.indexable_cls
          • IndexableWalker._walk_gen
          • IndexableWalker.send()
          • IndexableWalker.throw()
          • IndexableWalker.keys()
          • IndexableWalker.values()
          • IndexableWalker._abc_impl
          • IndexableWalker._walk()
          • IndexableWalker.allclose()
          • IndexableWalker.diff()
        • JobPool
          • JobPool.executor
          • JobPool.transient
          • JobPool.jobs
          • JobPool.submit()
          • JobPool.shutdown()
          • JobPool._clear_completed()
          • JobPool.as_completed()
          • JobPool.join()
        • NiceRepr
        • OrderedSet
          • OrderedSet.items
          • OrderedSet.map
          • 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._abc_impl
          • OrderedSet.issuperset()
          • OrderedSet.symmetric_difference()
          • OrderedSet._update_items()
          • OrderedSet.difference_update()
          • OrderedSet.intersection_update()
          • OrderedSet.symmetric_difference_update()
        • Path
          • Path.appdir()
          • Path.augment()
          • Path.delete()
          • Path.ensuredir()
          • Path.mkdir()
          • Path.expand()
          • Path.expandvars()
          • Path.ls()
          • Path.shrinkuser()
          • Path.chmod()
          • Path.touch()
          • Path.relative_to()
          • Path.walk()
          • Path.endswith()
          • Path.startswith()
          • Path._request_copy_function()
          • Path.copy()
          • Path.move()
        • ProgIter
          • ProgIter.stream
          • ProgIter.iterable
          • ProgIter.desc
          • ProgIter.total
          • ProgIter.freq
          • ProgIter.initial
          • ProgIter.enabled
          • ProgIter.adjust
          • ProgIter.show_percent
          • ProgIter.show_times
          • ProgIter.show_rate
          • ProgIter.show_eta
          • ProgIter.show_total
          • ProgIter.show_wall
          • ProgIter.eta_window
          • ProgIter.time_thresh
          • ProgIter.clearline
          • ProgIter.chunksize
          • ProgIter.rel_adjust_limit
          • ProgIter.extra
          • ProgIter._extra_fn
          • ProgIter.started
          • ProgIter.finished
          • ProgIter.homogeneous
          • ProgIter._abc_impl
          • ProgIter.__call__()
          • 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.dpath
          • TempDir.ensure()
          • TempDir.cleanup()
          • TempDir.start()
        • Timer
          • Timer._default_time()
          • Timer.label
          • Timer.verbose
          • Timer.newline
          • Timer.tstart
          • Timer.elapsed
          • Timer.write
          • Timer.flush
          • Timer.ns
          • Timer._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()
          • chunks._abc_impl
        • 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.fpath
          • zopen.ext
          • zopen.name
          • zopen.mode
          • zopen.zfile
          • zopen.namelist()
          • zopen._cleanup()
          • zopen._split_archive()
          • zopen._open()
ubelt
  • ubelt package
  • ubelt.util_links module
  • View page source

ubelt.util_links module¶

Cross-platform logic for dealing with symlinks. Basic functionality should work on all operating systems including everyone’s favorite pathological OS (note that there is an additional helper file for this case), but there are some corner cases depending on your version. Recent versions of Windows tend to work, but there certain system settings that cause issues. Any POSIX system works without difficulty.

Example

>>> import pytest
>>> import ubelt as ub
>>> if ub.WIN32:
>>>     pytest.skip()  # hack for windows for now. Todo cleaner xdoctest conditional
>>> import ubelt as ub
>>> from os.path import normpath, join
>>> dpath = ub.Path.appdir('ubelt', normpath('demo/symlink')).ensuredir()
>>> real_path = dpath / 'real_file.txt'
>>> link_path = dpath / 'link_file.txt'
>>> ub.touch(real_path)
>>> result = ub.symlink(real_path, link_path, overwrite=True, verbose=3)
>>> parts = result.split(os.path.sep)
>>> print(parts[-1])

link_file.txt

ubelt.util_links.symlink(real_path: str | PathLike, link_path: str | PathLike, overwrite: bool = False, verbose: int = 0) → str | PathLike[source]¶

Create a link link_path that mirrors real_path.

This function attempts to create a real symlink, but will fall back on a hard link or junction if symlinks are not supported.

Parameters:
  • real_path (str | PathLike) – path to real file or directory

  • link_path (str | PathLike) – path to desired location for symlink

  • overwrite (bool) – overwrite existing symlinks. This will not overwrite real files on systems with proper symlinks. However, on older versions of windows junctions are indistinguishable from real files, so we cannot make this guarantee. Defaults to False.

  • verbose (int) – verbosity level. Defaults to 0.

Returns:

link path

Return type:

str | PathLike

Note

In the future we may rework and rename this function to something like link, pathlink, fslink, etc… to indicate that it may perform multiple types of links. We may also allow the user to specify which type of link (e.g. symlink, hardlink, reflink, junction) they would like to use.

Note

On systems that do not contain support for symlinks (e.g. some versions / configurations of Windows), this function will fall back on hard links or junctions [WikiNTFSLinks], [WikiHardLink]. The differences between the two are explained in [WikiSymLink].

If symlinks are not available, then link_path and real_path must exist on the same filesystem. Given that, this function always works in the sense that (1) link_path will mirror the data from real_path, (2) updates to one will effect the other, and (3) no extra space will be used.

More details can be found in ubelt._win32_links. On systems that support symlinks (e.g. Linux), none of the above applies.

Note

This function may contain a bug when creating a relative link

References

[WikiSymLink]

https://en.wikipedia.org/wiki/Symbolic_link

[WikiHardLink]

https://en.wikipedia.org/wiki/Hard_link

[WikiNTFSLinks]

https://en.wikipedia.org/wiki/NTFS_links

Example

>>> import pytest
>>> import ubelt as ub
>>> if ub.WIN32:
>>>     pytest.skip()  # hack for windows for now. Todo cleaner xdoctest conditional
>>> import ubelt as ub
>>> dpath = ub.Path.appdir('ubelt', 'test_symlink0').delete().ensuredir()
>>> real_path = (dpath / 'real_file.txt')
>>> link_path = (dpath / 'link_file.txt')
>>> real_path.write_text('foo')
>>> result = ub.symlink(real_path, link_path)
>>> assert ub.Path(result).read_text() == 'foo'
>>> dpath.delete()  # clenaup

Example

>>> import pytest
>>> import ubelt as ub
>>> if ub.WIN32:
>>>     pytest.skip()  # hack for windows for now. Todo cleaner xdoctest conditional
>>> import ubelt as ub
>>> from ubelt.util_links import _dirstats
>>> dpath = ub.Path.appdir('ubelt', 'test_symlink1').delete().ensuredir()
>>> _dirstats(dpath)
>>> real_dpath = (dpath / 'real_dpath').ensuredir()
>>> link_dpath = real_dpath.augment(stem='link_dpath')
>>> real_path = (dpath / 'afile.txt')
>>> link_path = (dpath / 'afile.txt')
>>> real_path.write_text('foo')
>>> result = ub.symlink(real_dpath, link_dpath)
>>> assert link_path.read_text() == 'foo', 'read should be same'
>>> link_path.write_text('bar')
>>> _dirstats(dpath)
>>> assert link_path.read_text() == 'bar', 'very bad bar'
>>> assert real_path.read_text() == 'bar', 'changing link did not change real'
>>> real_path.write_text('baz')
>>> _dirstats(dpath)
>>> assert real_path.read_text() == 'baz', 'very bad baz'
>>> assert link_path.read_text() == 'baz', 'changing real did not change link'
>>> ub.delete(link_dpath, verbose=1)
>>> _dirstats(dpath)
>>> assert not link_dpath.exists(), 'link should not exist'
>>> assert real_path.exists(), 'real path should exist'
>>> _dirstats(dpath)
>>> ub.delete(dpath, verbose=1)
>>> _dirstats(dpath)
>>> assert not real_path.exists()

Example

>>> import pytest
>>> import ubelt as ub
>>> if ub.WIN32:
>>>     pytest.skip()  # hack for windows for now. Todo cleaner xdoctest conditional
>>> # Specifying bad paths should error.
>>> import ubelt as ub
>>> import pytest
>>> dpath = ub.Path.appdir('ubelt', 'test_symlink2').ensuredir()
>>> real_path = dpath / 'real_file.txt'
>>> link_path = dpath / 'link_file.txt'
>>> real_path.write_text('foo')
>>> with pytest.raises(ValueError, match='link_path .* cannot be empty'):
>>>     ub.symlink(real_path, '')
>>> with pytest.raises(ValueError, match='real_path .* cannot be empty'):
>>>     ub.symlink('', link_path)
Previous Next

© Copyright 2026, Jon Crall.

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