Skip to content

Commit

Permalink
USJ Generation (#208)
Browse files Browse the repository at this point in the history
* Refactor the code, moving USX and USJ generations to sub modules

* A simple JSON schema definition for USJ

* Implement AST to USJ conversion, usfm_parser.to_usj(), and replace it with older to_dict()

* Test and fix, USJ schema and conversion

* Implement to_list() using new USJ, test and fix

* Keep usfm_bytes as object property instead of passing it in every method

* Update README code examples and CLI to use to_usj() instead of to_dict()

* Fix linter issues

* Rename python-usfm-parser to py-usfm-parser

* Make changes in code and docs where old folder name was used

* Update local node version, and bump tree-sitter-cli npm package to latest version

* Use newer node versiion on git actions too

* Upgrade the python tree-sitter library version to latest
  • Loading branch information
kavitharaju authored Jul 13, 2023
1 parent 1c52124 commit 60c94b9
Show file tree
Hide file tree
Showing 36 changed files with 1,172 additions and 1,234 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/check-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup node and npm
uses: actions/setup-node@v2
with:
node-version: 14
node-version: 20.4
- name: Run tests
run: |
cd tree-sitter-usfm3
Expand All @@ -45,7 +45,7 @@ jobs:
- name: Setup node and npm
uses: actions/setup-node@v2
with:
node-version: 14
node-version: 20.4

- name: Create Virtual Environment
run: python -m venv ENV-dev
Expand All @@ -54,23 +54,23 @@ jobs:
run: source ENV-dev/bin/activate

- name: Install dependencies
run: pip install -r ./python-usfm-parser/dev-requirements.txt
run: pip install -r ./py-usfm-parser/dev-requirements.txt

- name: Build grammar binary
run: |
cd tree-sitter-usfm3
npm install .
./node_modules/.bin/tree-sitter generate
cd ..
python python-usfm-parser/src/grammar_rebuild.py ./tree-sitter-usfm3/ python-usfm-parser/src/usfm_grammar/my-languages.so
python py-usfm-parser/src/grammar_rebuild.py ./tree-sitter-usfm3/ py-usfm-parser/src/usfm_grammar/my-languages.so
- name: Install python module
run: |
cd python-usfm-parser
cd py-usfm-parser
pip install .
- name: Run tests for parsing errors
working-directory: ./python-usfm-parser
working-directory: ./py-usfm-parser
run:
# pytest -k "not compare_usx_with_testsuite_samples and not testsuite_usx_with_rnc_grammar and not samples-from-wild and not 57-TIT.partial" -n auto
pytest -k "not compare_usx_with_testsuite_samples and not testsuite_usx_with_rnc_grammar and not samples-from-wild and not 57-TIT.partial" -n auto tests/test_parsing.py
pytest -k "not compare_usx_with_testsuite_samples and not testsuite_usx_with_rnc_grammar and not generated_usx_with_rnc_grammar and not samples-from-wild and not 57-TIT.partial" -n auto
4 changes: 2 additions & 2 deletions .github/workflows/lint-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
run: source ENV-dev/bin/activate

- name: install packages
working-directory: ./python-usfm-parser
working-directory: ./py-usfm-parser
run: pip install -r dev-requirements.txt

- name: Run linter
working-directory: ./python-usfm-parser
working-directory: ./py-usfm-parser
run: pylint --extension-pkg-allow-list=lxml src/usfm_grammar/*.py
4 changes: 2 additions & 2 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup node and npm
uses: actions/setup-node@v2
with:
node-version: 14
node-version: 20.4
- name: Run tests
run: |
cd tree-sitter-usfm3
Expand All @@ -36,7 +36,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
node-version: 20.4
registry-url: https://registry.npmjs.org/
- run: |
cd tree-sitter-usfm3
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/pypi_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Setup node and npm
uses: actions/setup-node@v2
with:
node-version: 14
node-version: 20.4
- name: Build the tree-sitter parser
run: |
cd tree-sitter-usfm3
Expand All @@ -32,15 +32,15 @@ jobs:
env:
CIBW_BEFORE_BUILD: >
python -m pip install tree-sitter==0.20.0 &&
python python-usfm-parser/src/grammar_rebuild.py tree-sitter-usfm3 python-usfm-parser/src/usfm_grammar/my-languages.so
python py-usfm-parser/src/grammar_rebuild.py tree-sitter-usfm3 py-usfm-parser/src/usfm_grammar/my-languages.so
with:
package-dir: python-usfm-parser
output-dir: python-usfm-parser/dist
config-file: "python-usfm-parser/pyproject.toml"
package-dir: py-usfm-parser
output-dir: py-usfm-parser/dist
config-file: "py-usfm-parser/pyproject.toml"

- uses: actions/upload-artifact@v3
with:
path: python-usfm-parser/dist/*.whl
path: py-usfm-parser/dist/*.whl

publish_to_pypi:
needs: [build_wheels]
Expand All @@ -55,12 +55,12 @@ jobs:
- uses: actions/download-artifact@v3
with:
name: artifact
path: python-usfm-parser/dist/
path: py-usfm-parser/dist/

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_token }}
# repository_url: https://test.pypi.org/legacy/
packages_dir: python-usfm-parser/dist/
packages_dir: py-usfm-parser/dist/
16 changes: 8 additions & 8 deletions .github/workflows/testpypi_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup node and npm
uses: actions/setup-node@v2
with:
node-version: 14
node-version: 20.4
- name: Build the tree-sitter parser
run: |
cd tree-sitter-usfm3
Expand All @@ -30,15 +30,15 @@ jobs:
env:
CIBW_BEFORE_BUILD: >
python -m pip install tree-sitter==0.20.0 &&
python python-usfm-parser/src/grammar_rebuild.py tree-sitter-usfm3 python-usfm-parser/src/usfm_grammar/my-languages.so
python py-usfm-parser/src/grammar_rebuild.py tree-sitter-usfm3 py-usfm-parser/src/usfm_grammar/my-languages.so
with:
package-dir: python-usfm-parser
output-dir: python-usfm-parser/dist
config-file: "python-usfm-parser/pyproject.toml"
package-dir: py-usfm-parser
output-dir: py-usfm-parser/dist
config-file: "py-usfm-parser/pyproject.toml"

- uses: actions/upload-artifact@v3
with:
path: python-usfm-parser/dist/*.whl
path: py-usfm-parser/dist/*.whl

publish_to_pypi:
needs: [build_wheels]
Expand All @@ -53,12 +53,12 @@ jobs:
- uses: actions/download-artifact@v3
with:
name: artifact
path: python-usfm-parser/dist/
path: py-usfm-parser/dist/

- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PUBLISH_ON_TEST_PYPI }}
repository_url: https://test.pypi.org/legacy/
packages_dir: python-usfm-parser/dist/
packages_dir: py-usfm-parser/dist/
Loading

0 comments on commit 60c94b9

Please sign in to comment.