Package: cjwparse
Parsers forCJWorkbenchmodules.Workbench modules mayoptionallydepend on the latest version of this Python
package for itscjwparse.api.parse_file()function.InstallationThis is meant to be used within a Docker container. It depends on executables/usr/bin/(csv|json|xls|xlsx)-to-arrow.Your Dockerfile might look something like this:FROM arrow-tools:v0.0.11 AS arrow-tools
FROM python:3.8.1-buster AS main

COPY --from=arrow-tools /usr/bin/csv-to-arrow /usr/bin/csv-to-arrow
COPY --from=arrow-tools /usr/bin/json-to-arrow /usr/bin/json-to-arrow
COPY --from=arrow-tools /usr/bin/xls-to-arrow /usr/bin/xls-to-arrow
COPY --from=arrow-tools /usr/bin/xlsx-to-arrow /usr/bin/xlsx-to-arrow

# And now that these binaries are accessible, you can install cjwparse...Usageimportpyarrowfromcjwparse.apiimportparse_file# Convert a CSV file 'input.csv' to Arrow file 'output.arrow'input_path=Path("input.csv")input_path.write_bytes(b"A,B\n1,2")output_path=Path("output.arrow")parse_file(input_path,output_path=output_path,has_headers=False)# Read the outputwithpyarrow.ipc.open_file(output_path)asreader:table=reader.read_all()DevelopingRun tests:docker build .Write a failing unit test intests/Make it pass by editing code incjwparse/black cjwparse maintenance tests && isort cjwparse maintenance tests && python3 ./setup.py extract_messagesSubmit a pull requestBe very, very, very careful to preserve a consistent API. Workbench will
upgrade this dependency without module authors' explicit consent. Add new
features; fix bugs. Never change functionality.I18nMarking strings for translationStrings incjwparsecan be marked for translation usingcjwparse.i18n._trans_cjwparse. Each translation message must have a
(unique) ID. ICU is supported for the content. For example:from.i18nimport_trans_cjwparseerr="Error 404"with_arguments=_trans_cjwparse("greatapi.exception.message","Something is wrong:{error}",{"error":err})without_arguments=_trans_cjwparse("greatapi.exception.general","Something is wrong",)Workbench is wired to accept the return value of_trans_cjwparsewherever an error/warning or quick fix is expected.CreatingpocatalogsCalls to_trans_cjwparsecan (and must) be parsed to createcjwparse's.pofiles.
Update the.pofiles with:./setup.py extract_messagesThe first time you run this, you'll need to install dependencies:pip3 install .[maintenance]Unit testingIn case a_trans_cjwparseinvocation needs to be unit tested, you can usecjwparse.testing.i18n.cjwparse_i18n_messagein a manner similar to the following:fromcjwparse.testing.i18nimportcjwparse_i18n_messageimportwith_arguments,without_argumentsassertwith_arguments==cjwparse_i18n_message("greatapi.exception.message",{"error":"Error 404"})assertwithout_arguments==cjwparse_i18n_message("greatapi.exception.general")Message deprecationNever delete atrans()call: each message ID, once assigned, must be preserved
forever.When there is no more code path to atrans()call, move it tocjwparse/i18n/_deprecated_i18n_messages.py. The file is only read by
extraction code. It is never executed.PublishingWrite a new__version__tocjwparse/__init__.py. Adhere tosemver. (As changes must be backwards-compatible,
the version will always start with1and look like1.x.y.)Prepend notes toCHANGELOG.mdabout the new versiongit commitgit tag v1.x.ygit push --tags && git pushWait for Travis to push our changes to PyPI