Skip to main content

Utilities for Workbench modules

Project description

Utilities for CJWorkbench modules.

Workbench modules may optionally depend on the latest version of this Python package for its handy utilities:

  • cjwmodule.arrow.condition: functions to create Arrow table masks.
  • cjwmodule.arrow.format: functions to convert Arrow arrays to text.
  • cjwmodule.arrow.types: types your Arrow module may accept and return.
  • cjwmodule.arrow.testing: helpers for programming tests.
  • cjwmodule.http: HTTP helpers, including the handy httpfile format.
  • cjwmodule.i18n: A trans() function for producing translatable text.
  • cjwmodule.testing: Functions to help in unit testing.
  • cjwmodule.util.colnames: Functions to help build a valid table's column names.
  • cjwmodule.spec: Functions to load and validate module spec files.
  • cjwmodule.types: Types your module may accept and return.

Developing

  1. Run tox to confirm that unit tests pass
  2. Write a failing unit test in tests/. (tox should fail now.)
  3. Make it pass by editing code in cjwmodule/
  4. Run poetry run extract-messages if i18n data changed
  5. Run tox to confirm that unit tests pass again
  6. Submit a pull request

Preserve a consistent API. Workbench will upgrade this dependency without module authors' consent. Add new features; fix bugs. Don't alter existing behavior.

I18n

Marking strings for translation

Strings in cjwmodule can be marked for translation using cjwmodule.i18n._trans_cjwmodule. Each translation message must have a (unique) ID. ICU is supported for the content. For example,

from cjwmodule.i18n import _trans_cjwmodule

err = "Error 404"

with_arguments = _trans_cjwmodule(
    "greatapi.exception.message",
    "Something is wrong: {error}",
    {"error": err}
)

without_arguments = _trans_cjwmodule(
    "greatapi.exception.general",
    "Something is wrong",
)

Workbench is wired to accept the return value of _trans_cjwmodule wherever an error/warning or quick fix is expected.

Creating po catalogs

Calls to _trans_cjwmodule can (and must) be parsed to create cjwmodule's .po files. Update the .po files with:

poetry run extract-messages

Unit testing

In case a _trans_cjwmodule invocation needs to be unit tested, you can use cjwmodule.testing.i18n.cjwmodule_i18n_message like this:

from cjwmodule.testing.i18n import cjwmodule_i18n_message
import with_arguments, without_arguments

assert with_arguments == cjwmodule_i18n_message("greatapi.exception.message", {"error": "Error 404"})
assert without_arguments == cjwmodule_i18n_message("greatapi.exception.general")

Message deprecation

For backwards compatibility, messages in cjwmodule's po files are never deleted!

Publishing

  1. Prepend notes to CHANGELOG.md about the new version
  2. git commit
  3. git push and wait for Travis to report success
  4. git tag v1.x.y && git push --tags
  5. Wait for Travis to push our changes to PyPI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cjwmodule-4.1.12.tar.gz (43.8 kB view details)

Uploaded Source

Built Distribution

cjwmodule-4.1.12-py3-none-any.whl (52.3 kB view details)

Uploaded Python 3

File details

Details for the file cjwmodule-4.1.12.tar.gz.

File metadata

  • Download URL: cjwmodule-4.1.12.tar.gz
  • Upload date:
  • Size: 43.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.3 Linux/5.4.0-1042-gcp

File hashes

Hashes for cjwmodule-4.1.12.tar.gz
Algorithm Hash digest
SHA256 38fa54384bf84f469d5e241ac958c7abb5fde360e7d4df0d8ca64312a7087f02
MD5 96c29040e13b0ce462e561ed2a4192c9
BLAKE2b-256 614e7dc981c8307966da0039a13fe5c2aae14afce7bb0e8bc84a9365268624fb

See more details on using hashes here.

File details

Details for the file cjwmodule-4.1.12-py3-none-any.whl.

File metadata

  • Download URL: cjwmodule-4.1.12-py3-none-any.whl
  • Upload date:
  • Size: 52.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.3 Linux/5.4.0-1042-gcp

File hashes

Hashes for cjwmodule-4.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 b282a64595809f98c92d383ede664903093fdf9b12748d63199546f6466f2b55
MD5 997237a5ec92f0b2de12e3bc6fe730a1
BLAKE2b-256 f96d57764ddf94d665b556c8c299bf1d28c933d3371f01a27f96712798daf81e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page