Skip to content

Commit 48c0606

Browse files
committed
Initial commit
0 parents  commit 48c0606

27 files changed

+1701
-0
lines changed

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = tab
6+
indent_size = 4
7+
insert_final_newline = true
8+
end_of_line = lf
9+
10+
[*.{yml,yaml}]
11+
indent_style = space
12+
indent_size = 2

.github/.templateMarker

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
KOLANICH/python_project_boilerplate.py

.github/dependabot.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
allow:
8+
- dependency-type: "all"

.github/workflows/CI.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [ "master" ]
5+
pull_request:
6+
branches: [ "master" ]
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- name: typical python workflow
13+
uses: KOLANICH-GHActions/typical-python-workflow@master
14+
with:
15+
github_token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
__pycache__
2+
*.pyc
3+
*.pyo
4+
/*.egg-info
5+
/build
6+
/dist
7+
/.eggs
8+
/monkeytype.sqlite3
9+
/*.srctrldb
10+
/*.srctrlbm
11+
/*.srctrlprj

Code_Of_Conduct.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
No codes of conduct!

MANIFEST.in

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
include UNLICENSE
2+
include *.md
3+
exclude tests
4+
include .editorconfig
5+
global-include *.json
6+
global-include *.pglr
7+
global-include *.pgt
8+
global-include *.parsimonious
9+
global-include *.ebnf

ReadMe.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
pyMetakitDefinitionString [![Unlicensed work](https://raw.githubusercontent.com/unlicense/unlicense.org/master/static/favicon.png)](https://unlicense.org/)
2+
=========================
3+
~~[wheel (GHA via `nightly.link`)](https://nightly.link/prebuilder/pyMetakitDefinitionString/workflows/CI/master/pyMetakitDefinitionString-0.CI-py3-none-any.whl)~~
4+
~~[![GitHub Actions](https://github.com/prebuilder/pyMetakitDefinitionString/workflows/CI/badge.svg)](https://github.com/prebuilder/pyMetakitDefinitionString/actions/)~~
5+
[![Libraries.io Status](https://img.shields.io/librariesio/github/prebuilder/pyMetakitDefinitionString.svg)](https://libraries.io/github/prebuilder/pyMetakitDefinitionString)
6+
[![Code style: antiflash](https://img.shields.io/badge/code%20style-antiflash-FFF.svg)](https://codeberg.org/KOLANICH-tools/antiflash.py)
7+
8+
Parses metakit definition string.
9+
10+
Usage
11+
-----
12+
13+
```python
14+
import pyMetakitDefinitionString
15+
16+
d = pyMetakitDefinitionString.parse("people[first:S,last:S,shoesize:I],text[line:S]")
17+
print(d)
18+
```
19+
20+
```
21+
[
22+
view<name='people', bodyF=[scalar<name='first', typeF='S'>, scalar<name='last', typeF='S'>, scalar<name='shoesize', typeF='I'>]>,
23+
view<name='text', bodyF=[scalar<name='line', typeF='S'>]>
24+
]
25+
```
26+
27+
Interpretation of `typeF` is up to you since adding a enum will not spare you from having a look-up table. [See the docs.](https://codeberg.org/prebuilder/metakit/blob/master/doc/format.html#L155-L161)
28+
29+
30+
Requirements
31+
------------
32+
* [UniGrammarRuntime](https://codeberg.org/UniGrammar/UniGrammarRuntime.py)
33+
* Any of the backends for which parsers have been generated. [`parsimonious`](https://github.com/erikrose/parsimonious) is recommended, as it was benchmarked as the fastest one.

UNLICENSE

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <https://unlicense.org/>

parserBundle

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./pyMetakitDefinitionString/parserBundle/

pyMetakitDefinitionString/__init__.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
__all__ = ("parse",)
2+
3+
from pathlib import Path
4+
5+
from UniGrammarRuntime.ParserBundle import ParserBundle
6+
7+
thisFile = Path(__file__).absolute()
8+
thisDir = thisFile.parent
9+
bundleDir = thisDir / "parserBundle"
10+
11+
bundle = ParserBundle(bundleDir)
12+
13+
grammar = bundle.grammars["metakit4_definition_string"]
14+
wrapper = grammar.getWrapper() # put backend name, by default it selects the fastest one
15+
16+
17+
parse = wrapper

pyMetakitDefinitionString/__main__.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import sys
2+
3+
if __name__ == "__main__":
4+
from pprint import pprint
5+
6+
from . import parse
7+
8+
for el in sys.argv[1:]:
9+
pprint(parse(el))

0 commit comments

Comments
 (0)