Changes in this release:
- HTTP code 422 is now more accurately returned as a
ServiceFailureerror instead of aNetworkFailure.
Changes in this release:
- Revise the retry algorithm in
timed_request()again. - Make
timed_request()print the response text in case of failures - Remove
extra_requiresfromsetup.pybecause it caused installation problems due to the syntax of the requirements file and I don't have patience for figuring out whatsetuptoolsneeds this time.
This release updates the version of the dateparser package in requirements.txt, to avoid a deprecation warning when using CommonPy's parsed_datetime(...) function.
This release updates the versions of dependencies in requirements.txt.
This version prevents certain exceptions from being buried and ignored, and improves the network failure retry algorithm.
Additions in this release:
- New function
networkin thenetwork_utilsmodule. It is a companion tonetand takes the same arguments, but returns only one value (the response). If an error occurs, it raises the error as an exception. This makes it possible for callers to usenetwork(...)in somewhat more Pythonic style thannet(...), by wrapping the call tonetwork(...)intry-except.
Changes in this release:
- Removed
slicefromdata_utilsmodule because it shadows a Python built-in. - Fixed
hostnameinnetwork_utilsto be more general and not hardwire a test forhttp. - Fixed a bunch of
flake8warnings.
Additions in this release:
- New class
CaseFoldSet, similar toCaseFoldDictbut … a set.
Changes in this release:
- Fixed a bug in the class documentation in the
README.mdfile. - Added missing dependency for twine in requirements-dev
- Now using lazy
imports in more places, for faster load times.
Changes in this release:
data_utils.flattenednow outputs[]as the value of dict or mapping keys whose original values are an empty sequence (e.g., when the value of a dict key is[]). Previously, it would outputNoneas the value, which was an unexpected transformation of the input.
Bug fixes in this release:
- Fixed a bug in
data_utils.flattenedthat caused it to ignore theseparatorargument in some cases. - Fixed a missing import of
freezeguninrequirements-dev.txt. - Pin the imported version of regex 2022.3.2, because more recent versions cause calls to
dateparserto encounter an error ("regex._regex_core.error: bad escape \d at position 7").
The main functional change in this release is that error objects returned by net(...) will have error message bodies returned by network services, where possible.
Internally, there has been some refactoring of the Makefile and addition of things like GitHub template files.
This release merely changes the version of httpx required by requirements.txt. No other changes.
This version adds a missing internal function definition in download(...).
This version changes pluralized so that it outputs 0 items instead of 0 item if the number of its argument has length 0.
This version adds more test cases and splits out the requirements for testing/development into a separate requirements file, requirements-dev.txt.
Changes in this release:
- New exception
ArgumentError. net(...)makes slightly finer distinctions betweenServiceFailureandNetworkFailurewhen it comes to addresses it can't connect to, and also raisesArgumentErrorin some cases such as passing adatakeyword argument to a networkget.on_localhost(...)logs slightly better debug messages.- There are more test cases.
CITATION.cffhas been corrected and no longer describes the wrong repository.
This version merely changes a version dependency in requirements.txt. No other changes.
Changes in this release:
- At some point between versions 0.18 and 0.21.1 (current version), the
httpxpackage changed the keyword argument namedallow_redirectstofollow_redirects, and ournetwork_utilsmodule functions broke as a result. This release updatesnetwork_utilsto account for the change. - The
requirements.txtfile now pins most dependencies to a specific version, to avoid situations where getting a newer version of a package might break existing code. - The copyright year has been updated in various files.
This version introduces the data_structures module, and a new class, CaseFoldDict.
Changes in this release:
- Fixed a missing f-string in an exception message, plus guarded a few more exception message strings with
antiformat. - Added
CITATION.cfffile. - Updated the
Makefile.
Improve flattened to handle lists of dict keys.
Add missing deprecation package to requirements.txt.
Changes in this release:
- Beginning with this release, the function
reset()is deprecated in favor of the functionreset_interrupts(). - The function
wait()resets the interrupt state before it begins waiting.
This release fixes some unexpected failures in flattened(...).
This release expands flattened(...) to deal with iterators and generators.
This release fixes a bug in version 1.6.0.
This release adds the new function flattened(...)
This release adds the new function print_boxed(...).
Changes in this version:
- In
net(...), in case of a connection error, don't do exponential back-off and retry. Retry only once and then give up, because connection errors often mean the server is not available and long waits are unhelpful to callers. - Change
net(...)to not test if a network is available if the given destination address is on the local host. This prevents incorrectly returningNetworkFailurewhen the current host is detached from the network and the failure is actually aServiceFailure(for example, if nothing is listening on the destination port on the local host). - Add new function
on_localhost(...), for testing whether a given network location indicates the local host.
Note: the previous release, 1.3.10, should not have added new functions in a patch release – API changes should result in changing the minor release number, not merely the patch number. The previous release number was a mistake; it should have been 1.4.0, but since it wasn't, this release is 1.4.0.
- Add new functions
download(...)anddownload_file(...).
- Don't import packages
dateparserandvalidator_collectionuntil actually necessary, to reduce application startup times.
- Fix problems on Windows involving the interrupt handler configured by
config_interrupt(...). First, the internal function used did not have a signature that was correct forwin32api.SetConsoleCtrlHandleron Windows. Second, the proper usage is to return a value, not raise an exception.
- Make
relative(...)fromfile_utilsmore robust against a problem on Windows, in which Python'sos.path.relpathgenerates an error when you try to use it on a network-mapped drive.
- Fix missing
requirements.txtentry forpywin32on Windows.
- Fix reference to missing function called by
relative(...).
- Fix undefined exceptions in network_utils due to a missing import.
- Fix broken references to os.path functions.
- Add a check for a common mistake in parameters to
net(...).
- Remove reference to HTTPX exception
RequestBodyUnavailable, which no longer seems to exist in current versions of the HTTPX package. - Remove use of exception
UserCancelledinnetwork_utils.py, because its definition no longer existed elsewhere and on review it seemed unecessary in the context where it was used.
- Fixed issue #2: httpx Timeout needs a default value.
- Bump the required version of httpx to 0.16.
- Changed name
filter_by_extension(...)tofiltered_by_extension(...)to follow the style of other functions that return values. - Made trivial changes to the Makefile
- Added new function
config_path(...) - Added more unit tests
This version makes antiformat(...) more robust against values that are not strings, by applying str(...) to the incoming value.
This version adds a start at a module of string utilities, and introduces antiformat(..): a function that will quote instances of { and } braces in a string so that the string can be passed safely to format.
- Rename a few functions to follow a more consistent naming convention.
- Update
requirements.txtfile. - Add more documentation.
- Call this a 1.0.0 release.
- Fix bug in
filename_basename(...). - Improve
plural(...)by usingpluralize(...)from Boltons package. - Remove tests for removed module http_code.
- Miscellaneous other minor fixes and tweaks.
- Add a new module,
network_utils. - Start a collection of exceptions that may be returned by this package.
- Add additional dependency requirements to
requirements.txt.
- Add a new module,
module_utils. - Add functions to the
file_utilsmodule. - The package
__init__.pyfile no longer imports the individual modules. (Users are expected to use the approachfrom commonpy.modulename import functionname.)
Changed the order of arguments to function config_interrupt in the interrupt module to be in a more convenient order for most use cases.
This release adds the module interrupt. This module includes wait(...), a replacement for sleep(...) that is interruptible and works with multiple threads. It also provides methods to cause an interruption (including doing it by issuing a ^C to the program), check whether an interruption occurred, and other related operations.
Fixed some issues with the README.md file and started adding some documentation about the functions.
First release of various utilities developed for other Caltech Library projects over the last couple of years.