ubelt

A Python utility library with a stdlib like feel and extra batteries. Paths, Progress, Dicts, Downloads, Caching, Hashing: ubelt makes it easy!

APACHE-2.0 License

Downloads
71.8K
Stars
713
Committers
4

Bot releases are visible (Hide)

ubelt - Version 1.3.6 Latest Release

Published by github-actions[bot] 5 months ago

For new stuff: there is a quality of life improvements in ub.Path.chmod, you can use string-codes like ub.Path(...).chmod('+x') now! I think that's pretty neat. There isalso new functionality in ub.IndexableWalker.diff, which lets you compare similar, nested structures.

This update also vendors part of jaraco.windows so no-dependency versions of ubelt can now be installed on windows. The jaraco.windows can still be used, but it is now a truly optional dependency.

For fixed stuff: It looks like editable installs now use type annotations in their MAPPER files, so modname_to_modpath has been updated to account for this. This fixes several issues in experienced by consumers of this package.

There is also a fix that almost nobody will ever notice, but it blocked the above update from getting released for several weeks by causing a single CI job to fail. The library now handles new corner cases on pypy on windows with path related things (getting tests to pass was here far too much work - I nearly dropped pypy or windows support in frustration).

Version 1.3.6 - Released 2024-06-08

Added:

  • Add ub.IndexableWalker.diff

Fixed:

  • Added workarounds for copy / symlinks via ub.Path and ub.symlink on pypy.
  • ub.import_module_from_path now correctly accepts PathLike objects.
  • ub.modname_to_modpath fixed in cases where editable installs use type
    annotations in their MAPPING definition.

Added

  • Support for UNIX special permission (suid/sgid/svtx) codes in Path.chmod.

Changed

  • Moved windows dependencies from requires to optional. Windows users that make
    use of these will need to update their ubelt install or explicitly depend on
    them as well.

What's Changed

Full Changelog: https://github.com/Erotemic/ubelt/compare/v1.3.5...refs/heads/release

ubelt - Version 1.3.5

Published by github-actions[bot] 7 months ago

Added:

  • New wrapper around pathlib.Path.chmod in ubelt.Path.chmod. Can now
    specify string codes like "u+x" or "+rw". Old stat logic works as it
    previously did.

Changed:

  • Allow the argument to ubelt.cmd to be a PathLike object, which we will
    expect to be an executable.

Fixed

  • ub.modname_to_modpath now handles cases where editable packages have modules where the name is different than the package.
  • Fixed deprecated usage of ast.Num

What's Changed

Full Changelog: https://github.com/Erotemic/ubelt/compare/v1.3.4...v1.3.5

ubelt - Version 1.3.4

Published by Erotemic 12 months ago

Added

  • Add backend option to highlight_code which can be "pygments" or "rich".
  • Support for Python 3.12

Changed

  • Improve speed of inplace dictionary set operations.

Fixed

  • Align in the case of nobraces=1 for ubelt.urepr.
ubelt - Version 1.3.3

Published by Erotemic over 1 year ago

Fixed

  • Bug where the first call to ub.hash_data would error if it was given a
    ndarray with object type.
  • Actually exposed ChDir.

Changed

  • Docs and typing improvements
ubelt - Version 1.3.2

Published by Erotemic over 1 year ago

Fixed

  • Bug where the first call to ub.hash_data would error if it was given a
    ndarray with object type.

Notes

  • Skipped a release version due to a bad github tag.
ubelt - Version 1.3.0

Published by Erotemic over 1 year ago

Version 1.3.0 - 2022-06-14

Changed

  • Removed experimental warning from Path.copy and Path.move; they are now well enough tested.
  • The util_format submodule has been renamed to util_repr. The
    util_format is now a deprecated alias for util_repr.
  • Stub out merge methods for SetDict.
  • Renamed FormatterExtensions to ReprExtensions, with the former now being a deprecated alias.
  • ubelt.cmd now returns an object that ducktypes subprocess.CompletedProcess.
  • ubelt.cmd now contains a capture argument which will disable capturing of output.
  • ubelt.cmd ...detaching now only prints if verbosity is > 1
ubelt - Version 1.2.4

Published by Erotemic over 1 year ago

Version 1.2.4

Added

  • Added ChDir to util_path.
  • Add transient option to JobPool so references to futures are released after they are yielded to the user.
  • Added "base32" as an option for hash_data. Note that it is unpadded, hence non-RFC compliant.
  • Added pattern as a convenience option to ubelt.Path.ls.

Changed

  • Updated vendored ProgIter to match progiter 1.3.0
  • The download progress bar now gives more relevant information and updates less frequently.
  • IndexableWalker.allclose can now take unwrapped objects.

Fixed

  • ubelt.cmd now respects cwd when system=True.
ubelt - Version 1.2.3

Published by Erotemic almost 2 years ago

Added

  • Support for FreeBSD in util_platform
  • ub.Path.copy and ub.Path.move
  • Tentative Python 3.11 support
  • ub.utext which is a repr2 with new defaults.
  • ub.IndexableWalker.allclose method to replace indexable_allclose

Changed

  • ub.schedule_deprecation can now accept the strings "soon" or "now" for "when" arguments.
  • ub.schedule_deprecation can now accept stacklevel as as an argument.
  • ub.Path.apppdir can now be called without arguments.
  • Deprecate TempDir
  • ub.Timer can now accept ns as a keyword to enable nanosecond resolution.
  • ProgIter.format_message return value has changed.
  • ub.Path.mkdir now returns itself
  • Speedup dict_hist in the basic case by 2x

Fixed

  • Issue in indexable_allclose where tolerances were not respected.
  • Issue in modname_to_modpath with exclude and editable installs.
  • Incompatibility with pathlib in PythonPathContext
  • Fixed issue in progiter with line clears
  • Issue in import_module_from_modname with editable installs where it would try to match modules that had the requested module as a prefix.
  • The timeout argument is now respected in the thread / process case of JobPool
ubelt - Version 1.2.2

Published by Erotemic about 2 years ago

Added

  • Add ubelt.util_dict.UDict.take.
  • Added __add__, __radd__, startswith, and endswith methods to ubelt.Path to make
    it a better drop-in replacement for string based paths.

Changed

  • Reverse dunder methods of ubelt.SetDict now promote the type.
  • Add cls keyword argument to ubelt.SetDict methods.
  • Deprecate: ensure_app_cache_dir, ensure_app_config_dir, ensure_app_data_dir,
    get_app_cache_dir, get_app_config_dir, get_app_data_dir, readfrom, writeto, ensure_unicode.
  • Initial work on new Path methods for move and copy.
  • CacheStamp.renew now does nothing and returns None if the stamp is disabled.
  • AutoDict, SetDict, and UDict are now always ordered. In Python 3.6 it inherits from OrderedDict. Otherwise it uses regular dict, which will be ordered in 3.7+
  • AutoDict now inherits from UDict.
  • PathLike objects can now be used in args to ub.cmd when the command is an iterable.

Deprecated

  • deprecate AutoOrderedDict, which is now indistinguishable from AutoDict

Fixed

  • Tentative fixes for new __editable__ based install path with ub.modname_to_modpath
ubelt - Version 1.2.1

Published by Erotemic about 2 years ago

Version 1.2.1 - Released 2022-08-06

Fixed

  • Implemented inplace and reverse versions of dictionary set operations
  • Added copy to setdict
ubelt - Version 1.2.0

Published by Erotemic about 2 years ago

Version 1.2.0 - Released 2022-08-02

Added

  • Added keywords argument to ub.compatible.
  • Added warncls argument to ub.schedule_deprecation.
  • Experimental SetDict, UDict and aliases sdict, udict.

Fixed

  • Race condition on win32 in ubelt.symlink
  • Issue with ubelt.memoize_method where the method name and docstring were
    not wrapped correctly.
  • The timeout argument now works correctly with ub.cmd when tee=True.
  • Added appname to ubelt.download which was supposed to exist as indicated
    by the docs, but didn't.
  • The resources used by ubelt.cmd are now properly closed.

Changed

  • ub.compatible no longer errors on positional only functions, instead it
    returns the keyword-compatible arguments.
  • An issue in ubelt.symlink with unintuitive behavior when an empty string
    was given as the link path. This now raises an error.
  • The main implementations of ubelt.sorted_vals and ubelt.map_vals were
    renamed to ubelt.sorted_values and ubelt.map_values, but the old names
    are still available as aliases.
  • Positional arguments in Path.augment have been modified.
  • In Path.augment, deprecate overloaded suffix and introduce stemsuffix
    as an alternative.
  • Added cls to a lot of util_dict funcs
ubelt - ## Version 1.1.2 - Released 2022-06-30

Published by Erotemic over 2 years ago

Added

  • Added new module util_deprecate with the function schedule_deprecation,
    which is generally useful for library maintenance.

Fixed

  • Fixed issue where ubelt Cacher triggered its own warnings
  • Fixed deprecated usage of LooseVersion

Changed

  • Tentative deprecation or backwards incompatible change in ub.Path.augment with suffix or prefix keywords
ubelt - Version 1.1.1

Published by Erotemic over 2 years ago

Version 1.1.1 - Released 2022-06-09

Changed

  • Removed warning from ubelt.Cacher when depends is not specified.
  • ub.timestamp / ub.timeparse now respects a default_timezone argument and handles datetime.date objects.
  • Type stubs are now included in the distribution

Fixed

  • Issue #113, where a ub.find_exe test failed on Gentoo. Fixed by #114
  • Issue where older versions of CacheStamp would be interpreted as 1.1 stamps.
ubelt - Version 1.1.0

Published by Erotemic over 2 years ago

Version 1.1.0 - Released 2022-06-03

Added

  • New method: ub.timeparse can parse the result of ub.timestamp into a
    datetime object. Can optionally use dateutil.parser.parse under the hood.
  • ub.Path.ls a convenience function that aliases list(path.iterdir()).
  • ub.Path.walk to wrap os.walk.

Changed

  • Register pathlib.Path with ub.repr2
  • Can now register global ub.repr2 extensions via ub.repr2.register
  • Can now register global ub.hash_data extensions via ub.hash_data.register
  • Removed deprecated arguments from ubelt.cmd.
  • ub.CacheStamp will now check the mtime and size to quickly check if the products
    have changed and force expiration.
  • ub.CacheStamp now takes an expires keyword arg, which will keep the cache valid
    only for the specified amount of time.
  • ub.CacheStamp now takes an hash_prefix keyword arg, which will check that it
    matches the hash of the product.
  • ub.cmd now has a system argument for modularity with os.system.
  • ub.cmd now accepts a timeout argument (tee support is pending).
  • ub.JobPool now contains a protected _prog variable allowing the user
    finer-grained progress controls.
  • ub.JobPool now contains a convenience method join that executes all jobs
    and returns a list of results.
  • ub.timestamp can now accept a datetime object as an argument, and will return
    the timestamp for that object.
  • The ubelt.util_download.grabdata function now uses CacheStamp instead of
    implementing its own stamp solution.
  • The ubelt.util_hash.HashableExtensions implementation was updated to use
    functools.singledispatch instead of the custom solution. This seems faster
    and should not have any API impact.

Deprecated

  • product and cfgstr arguments to CacheStamp.expired
  • product and cfgstr arguments to CacheStamp.renew
  • Passing hasher as an instance to functions like grabdata or CacheStamp
    can cause unexpected hashes as they may be used more than once.

Fixed

  • ub.hash_data now recognizes subclasses of registered types.
  • ub.timestamp() has been outputting incorrect (negated) UTC offsets. This is now fixed.
  • ub.timestamp() now works correctly when the year has less than 4 digits.
ubelt - Version 1.0.1

Published by Erotemic over 2 years ago

Version 1.0.1 - Released 2022-02-20

Fixed

  • Bug where six was used but not listed as a dependency. Six is now removed as a dependency.
  • Fixed out of date docs in some places.
ubelt - Version 1.0.0

Published by Erotemic over 2 years ago

Version 1.0.0 - Released 2022-02-15

Added

  • :func:ubelt.Path.appdir which functions like the get_app_*_dir methods in util_platform.
  • Add tail argument to :func:ubelt.Path.augment and :func:ubelt.util_path.augpath
  • Add json backend option to Cacher.

Changed

  • IndexableWalker behavior has been changed, each time iter is called it
    resets its global state.
  • Remove support for Python 2.7 and Python 3.5
  • Removed deprecated functions scheduled for removal.
  • :func:ubelt.util_dict.dict_diff now preserves original dictionary order in Python 3.7+.
  • ub.hash_data can now hash slice objects.
  • INTENTION OF BREAKING CHANGE NOTIFICATION: ubelt.util_format.repr2 may no longer sort
    dictionaries by default. Looking into a backwards compatible way to work around this.
ubelt - Version 0.11.1

Published by Erotemic almost 3 years ago

Version 0.11.1

This is the last planned release for the 0.x branch of ubelt. Adds a few minor updates and doc fixes to the tools introduced in 0.11.0.

The next 1.0.x branch will no longer support Python 2.7 and Python 3.5. This has a positive impact on import time:

https://twitter.com/erotemic/status/1480069712981680128

image

Note that moving forward we may remove support for Python 3.x branches as they reach end of life without incrementing the major version. Python 3.6 end of life is (23 Dec 2021), and Python 3.7 end of life is (27 Jun 2023).

Added

  • More ubelt.Path extensions for delete
  • Add timeout parameter to ubelt.download
ubelt - Version 0.11.0

Published by Erotemic almost 3 years ago

Version 0.11.0 - Released 2022-01-03

Added

  • Added ubelt.Path, as an extension and quicker-to-type version of pathlib.Path with extra functionality.
  • Added progkw as argument to JobPool.as_completed to control progress reporting
  • Added progkw as argument to ub.download / ub.grabdat to control progress reporting
  • Added util_zip with the zopen function. Access a file inside a zipfile with a standard open like interface.

Fixed

  • ubelt.hash_data now handles non-numeric float values.
  • ubelt.chunks now works correctly when nchunks is specified.

Changed

  • Changed default of _hashable_sequence types arg from True to False to be
    consistent, but kept existing types=True behavior in hashable extensions. Changes
    should be backwards compatible, but in the future we may introduce a breaking
    change to make hash behavior more consistent.
ubelt - Version 0.10.2

Published by Erotemic almost 3 years ago

Version 0.10.2 - Released 2021-12-07

Added

  • Added pyi type annotation files. (Used a custom script to export docstring type annotations)
  • Added default keyword argument to signature of ub.peek

Fixed

  • Added map function to the executor classes.
  • ub.Executor now correctly returns itself from __enter__
  • Docstrings now have better type annotations
  • ProgIter had a bug in time_thresh, where it was never used (modified adjustment rules).
  • Fixed performance regression in ProgIter (now less overhead than tqdm)

Changed

  • New CI GPG Keys: Erotemic-CI: 70858F4D01314BF21427676F3D568E6559A34380 for
    reference the old signing key was 98007794ED130347559354B1109AC852D297D757.
  • Verbose test from symlink previously showed "real -> link" which makes no
    sense because a link should be the object that "is pointing". Thus it now
    shows "link -> real"
  • ub.download should now generate less stdout text
  • New in-repo "dev" benchmarks
ubelt - Version 0.10.1

Published by Erotemic about 3 years ago

This is a minor release with documenation improvements and no functionality changes

Package Rankings
Top 25.43% on Conda-forge.org
Top 6.56% on Proxy.golang.org
Top 2.31% on Pypi.org