Skip to main content

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

Metadata

Release files for cjwmodule 4.1.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cjwmodule 4.1.12
File Size Uploaded
cjwmodule-4.1.12.tar.gz 43.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cjwmodule 4.1.12
File Interpreter ABI Platform
cjwmodule-4.1.12-py3-none-any.whl Python 3 none any Details

Total release size: 96.1 kB

Release files / cjwmodule-4.1.12.tar.gz

Download URL cjwmodule-4.1.12.tar.gz
Size 43.8 kB
Tags Source
SHA-256 checksum
How to use checksums
38fa54384bf84f469d5e241ac958c7abb5fde360e7d4df0d8ca64312a7087f02
BLAKE2b-256 checksum
How to use checksums
614e7dc981c8307966da0039a13fe5c2aae14afce7bb0e8bc84a9365268624fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.8.3 Linux/5.4.0-1042-gcp

Release files / cjwmodule-4.1.12-py3-none-any.whl

Download URL cjwmodule-4.1.12-py3-none-any.whl
Size 52.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b282a64595809f98c92d383ede664903093fdf9b12748d63199546f6466f2b55
BLAKE2b-256 checksum
How to use checksums
f96d57764ddf94d665b556c8c299bf1d28c933d3371f01a27f96712798daf81e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.8.3 Linux/5.4.0-1042-gcp

Release history Release notifications | RSS feed

This release

4.1.12 This release

2 release files

4.1.9

2 release files

4.1.8

2 release files

4.1.7

2 release files

4.1.6

2 release files

4.1.5

2 release files

4.1.4

2 release files

4.1.3

2 release files

4.1.2

2 release files

4.1.1

2 release files

4.1.0

1 release file

4.0.2

1 release file

4.0.1

1 release file

4.0.0

1 release file

3.4.0

1 release file

3.3.1

1 release file

3.3.0

1 release file

3.2.0

1 release file

3.1.0

1 release file

3.0.0

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.5.7

1 release file

1.5.5

1 release file

1.5.4

1 release file

1.5.3

1 release file

1.5.2

1 release file

1.5.1

1 release file

1.5.0

1 release file

1.4.2

1 release file

1.4.1

1 release file

1.4.0

1 release file

1.3.1

1 release file

1.3.0

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.1.0

1 release file

1.0.0

1 release file

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page