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
Bot releases are visible (Hide)
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).
ub.IndexableWalker.diff
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 typePath.chmod
.Full Changelog: https://github.com/Erotemic/ubelt/compare/v1.3.5...refs/heads/release
Published by github-actions[bot] 7 months ago
pathlib.Path.chmod
in ubelt.Path.chmod
. Can nowubelt.cmd
to be a PathLike
object, which we willub.modname_to_modpath
now handles cases where editable packages have modules where the name is different than the package.ast.Num
Full Changelog: https://github.com/Erotemic/ubelt/compare/v1.3.4...v1.3.5
Published by Erotemic 12 months ago
highlight_code
which can be "pygments" or "rich".nobraces=1
for ubelt.urepr
.Published by Erotemic over 1 year ago
ub.hash_data
would error if it was given aChDir
.Published by Erotemic over 1 year ago
ub.hash_data
would error if it was given aPublished by Erotemic over 1 year ago
Path.copy
and Path.move
; they are now well enough tested.util_format
submodule has been renamed to util_repr
. Theutil_format
is now a deprecated alias for util_repr
.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 > 1Published by Erotemic over 1 year ago
ChDir
to util_path
.JobPool
so references to futures are released after they are yielded to the user.hash_data
. Note that it is unpadded, hence non-RFC compliant.pattern
as a convenience option to ubelt.Path.ls
.IndexableWalker.allclose
can now take unwrapped objects.ubelt.cmd
now respects cwd
when system=True
.Published by Erotemic almost 2 years ago
util_platform
ub.Path.copy
and ub.Path.move
ub.utext
which is a repr2 with new defaults.ub.IndexableWalker.allclose
method to replace indexable_allclose
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.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 itselfdict_hist
in the basic case by 2xindexable_allclose
where tolerances were not respected.modname_to_modpath
with exclude and editable installs.PythonPathContext
import_module_from_modname
with editable installs where it would try to match modules that had the requested module as a prefix.timeout
argument is now respected in the thread / process case of JobPool
Published by Erotemic about 2 years ago
ubelt.util_dict.UDict.take
.__add__
, __radd__
, startswith
, and endswith
methods to ubelt.Path
to makeubelt.SetDict
now promote the type.cls
keyword argument to ubelt.SetDict
methods.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
.__editable__
based install path with ub.modname_to_modpath
Published by Erotemic about 2 years ago
Published by Erotemic about 2 years ago
ub.compatible
.warncls
argument to ub.schedule_deprecation
.ubelt.symlink
ubelt.memoize_method
where the method name and docstring weretimeout
argument now works correctly with ub.cmd
when tee=True
.appname
to ubelt.download
which was supposed to exist as indicatedubelt.cmd
are now properly closed.ub.compatible
no longer errors on positional only functions, instead itubelt.symlink
with unintuitive behavior when an empty stringubelt.sorted_vals
and ubelt.map_vals
wereubelt.sorted_values
and ubelt.map_values
, but the old namesPath.augment
have been modified.Path.augment
, deprecate overloaded suffix
and introduce stemsuffix
Published by Erotemic over 2 years ago
util_deprecate
with the function schedule_deprecation
,Published by Erotemic over 2 years ago
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 #114Published by Erotemic over 2 years ago
ub.timeparse
can parse the result of ub.timestamp
into adatetime
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 productsub.CacheStamp
now takes an expires
keyword arg, which will keep the cache validub.CacheStamp
now takes an hash_prefix
keyword arg, which will check that itub.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 userub.JobPool
now contains a convenience method join
that executes all jobsub.timestamp
can now accept a datetime
object as an argument, and will returnubelt.util_download.grabdata
function now uses CacheStamp
instead ofubelt.util_hash.HashableExtensions
implementation was updated to usefunctools.singledispatch
instead of the custom solution. This seems fasterproduct
and cfgstr
arguments to CacheStamp.expired
product
and cfgstr
arguments to CacheStamp.renew
hasher
as an instance to functions like grabdata
or CacheStamp
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.Published by Erotemic over 2 years ago
Published by Erotemic over 2 years ago
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 itubelt.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 sortPublished by Erotemic almost 3 years ago
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
Published by Erotemic almost 3 years ago
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 bePublished by Erotemic almost 3 years ago
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 textPublished by Erotemic about 3 years ago
This is a minor release with documenation improvements and no functionality changes