A Python utility library with a stdlib like feel and extra batteries. Paths, Progress, Dicts, Downloads, Caching, Hashing: ubelt makes it easy!
util_deprecate
with the function schedule_deprecation
,
which is generally useful for library maintenance.ubelt.Cacher
when depends is not specified.ub.timestamp
/ ub.timeparse
now respects a default_timezone
argument and handles datetime.date
objects.ub.find_exe
test failed on Gentoo. Fixed by #114ub.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
.pathlib.Path
with ub.repr2
ub.repr2
extensions via ub.repr2.register
ub.hash_data
extensions via ub.hash_data.register
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.ubelt.util_download.grabdata
function now uses CacheStamp
instead of
implementing its own stamp solution.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.product
and cfgstr
arguments to CacheStamp.expired
product
and cfgstr
arguments to CacheStamp.renew
hasher
as an instance to functions like grabdata
or CacheStamp
can cause unexpected hashes as they may be used more than once.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.Path.appdir
which functions like the get_app_*_dir
methods in util_platform
.tail
argument to :func:ubelt.Path.augment
and :func:ubelt.util_path.augpath
backend
option to Cacher.IndexableWalker
behavior has been changed, each time iter
is called it
resets its global state.ubelt.util_dict.dict_diff
now preserves original dictionary order in Python 3.7+.ub.hash_data
can now hash slice objects.ubelt.util_format.repr2
may no longer sort
dictionaries by default. Looking into a backwards compatible way to work around this.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
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).
ubelt.Path
extensions for delete
timeout
parameter to ubelt.download
ubelt.Path
, as an extension and quicker-to-type version of pathlib.Path with extra functionality.progkw
as argument to JobPool.as_completed
to control progress reportingprogkw
as argument to ub.download
/ ub.grabdat
to control progress reportingutil_zip
with the zopen
function. Access a file inside a zipfile with a standard open
like interface.ubelt.hash_data
now handles non-numeric float values.ubelt.chunks
now works correctly when nchunks is specified._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.default
keyword argument to signature of ub.peek
map
function to the executor classes.ub.Executor
now correctly returns itself from __enter__
time_thresh
, where it was never used (modified adjustment rules).ub.download
should now generate less stdout textThis is a minor release with documenation improvements and no functionality changes
ub.repr2
named_product
, varied_values
to util_dict
compatible
to util_func
util_indexable
and IndexableWalker
(ported from kwcoco)util_futures
with ub.JobPool
and ub.Executor
(ported from kwcoco)util_download_manager
with simple implementation of ub.DownloadManager
ubelt
properubelt.download
now errors earlier if the parent directory does not existdownload
and ByteIO objects in 3.8os.readlink
behaviorModified corner cases in ub.repr2
to move towards behavior that is easier
to reason about.
Remove support for Python 3.4