The HDX Python Utilities Library provides a range of helpful utilities for Python developers. Note that these are not specific to HDX.
- Easy downloading of files with support for authentication, streaming and hashing
- Retrieval of data from url with saving to file or from data previously saved
- Date utilities
- Loading and saving JSON and YAML (maintaining order)
- Loading and saving HXLated csv and/or JSON
- Dictionary and list utilities
- HTML utilities (inc. BeautifulSoup helper)
- Compare files (eg. for testing)
- Simple emailing
- Easy logging setup and error logging
- State utility
- Path utilities
- URL utilities
- Text processing
- Stable file hashing
- Matching utilities
- Encoding utilities
- Check valid UUID
- Easy building and packaging
For more information, please read the documentation.
This library is part of the Humanitarian Data Exchange (HDX) project. If you have humanitarian related data, please upload your datasets to HDX.
Development is currently done using Python 3.13. The environment can be created with:
uv syncThis creates a .venv folder with the versions specified in the project's uv.lock file.
pre-commit will be installed when syncing uv. It is run every time you make a git commit if you call it like this:
pre-commit installWith pre-commit, all code is formatted according to ruff guidelines.
To check if your changes pass pre-commit without committing, run:
pre-commit run --all-filesuv is used for package management. If
you’ve introduced a new package to the source code (i.e. anywhere in src/),
please add it to the project.dependencies section of pyproject.toml with
any known version constraints.
To add packages required only for testing, add them to the
[dependency-groups].
Any changes to the dependencies will be automatically reflected in
uv.lock with pre-commit, but you can re-generate the files without committing by
executing:
uv lock --upgradeuv is used for project management. The project can be built using:
uv buildLinting and syntax checking can be run with:
uv run ruff checkTo run the tests and view coverage, execute:
uv run pytestThe documentation, including API documentation, is generated using ReadtheDocs and
MkDocs with Material. As you change the source code, remember to update the
documentation at documentation/index.md.