You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+42-11Lines changed: 42 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,17 @@
4
4
5
5
6
6
It's as second Parser that done by me, first is a https://github.com/xnuinside/simple-ddl-parser for SQL DDL with different dialects.
7
-
Py-Models-Parser supports now ORM Sqlalchemy, Gino, Tortoise; Pydantic, Python Enum models, Dataclasses & in nearest feature I plan to add pure pyton classes. And next will be added other ORMs models.
7
+
8
+
Py-Models-Parser can parse & extract information from models:
9
+
10
+
- Sqlalchemy ORM,
11
+
- Gino ORM,
12
+
- Tortoise ORM,
13
+
- Pydantic,
14
+
- Python Enum,
15
+
- Python Dataclasses
16
+
17
+
Number of supported models will be increased, check 'TODO' section.
8
18
9
19
Py-Models-Parser written with PEG parser and it's python implementation - parsimonious. It's pretty new and I did not cover all possible test cases, so if you will have an issue - please just open an issue in this case with example, I will fix it as soon as possible.
10
20
@@ -51,7 +61,7 @@ NOTE: it's is a text parser, so it don't import or load your code, parser work w
51
61
52
62
Library detect automaticaly that type of models you tries to parse. You can check a lot of examples in test/ folder on the GitHub
53
63
54
-
You can parse models from python string:
64
+
1.You can parse models from python string:
55
65
56
66
```python
57
67
@@ -75,7 +85,7 @@ result = parse(models_str)
75
85
76
86
```
77
87
78
-
or just provide the path to file:
88
+
2. Parse models from file:
79
89
80
90
```python
81
91
@@ -87,7 +97,31 @@ or just provide the path to file:
87
97
result = parse_from_file(file_path)
88
98
```
89
99
90
-
It will produce the result:
100
+
3. Parse models from file with command line
101
+
102
+
```bash
103
+
104
+
pmp path_to_models.py
105
+
106
+
# for example: pmp tests/data/dataclass_defaults.py
107
+
108
+
```
109
+
110
+
Output from cli can be dumped in 'output_models.json' file - use flag '-d' '--dump' if you want to change target file name, provide it after argument like '-d target_file.json'
111
+
112
+
```bash
113
+
114
+
# example how to dump output from cli
115
+
116
+
pmp path_to_models.py -d target_file.json
117
+
118
+
```
119
+
120
+
### Output example
121
+
122
+
You can find a lot of output examples in tests - https://github.com/xnuinside/py-models-parser/tree/main/tests
123
+
124
+
For model from point 1 (above) library will produce the result:
91
125
92
126
```python
93
127
@@ -132,20 +166,17 @@ It will produce the result:
132
166
]
133
167
```
134
168
135
-
136
169
## TODO: in next Release
137
170
138
-
1. Parse from file method
139
-
2. Add cli
140
-
3. Add more tests for supported models (and fix existed not covered cases): Pydantic, Enums, Dataclasses, SQLAlchemy Models, GinoORM models, TortoiseORM models
141
-
4. Add support for pure Python classes
142
-
5. Add support for pure SQLAlchemy Core Tables
171
+
1. Add more tests for supported models (and fix existed not covered cases): Pydantic, Enums, Dataclasses, SQLAlchemy Models, GinoORM models, TortoiseORM models
172
+
2. Add support for pure SQLAlchemy Core Tables
173
+
3. Add support for Pony ORM models
143
174
144
175
## Changelog
145
176
**v0.2.0**
146
177
1. Added support for Dataclasses
147
178
2. Added parse_from_file method
148
-
3. Added correct work with types with comma inside, like: Union[dict, list] or Union[dict, list, tuple, anything]
179
+
3. Added correct work with types with comma inside, like: Union[dict, list] or Union[dict, list, tuple, anything]
149
180
150
181
**v0.1.1**
151
182
1. Added base parser logic & tests for Pydantic, Enums, SQLAlchemy Models, GinoORM models, TortoiseORM models
Copy file name to clipboardExpand all lines: pyproject.toml
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
[tool.poetry]
2
2
name = "py-models-parser"
3
-
version = "0.2.0"
3
+
version = "0.3.0"
4
4
description = "Parser for Different Python Models (Pydantic, Enums, ORMs: Tortoise, SqlAlchemy, GinoORM) to extract information about columns(attrs), model, table args,etc in one format."
0 commit comments