Skip to content

Commit d9cf57b

Browse files
committed
Extended regex handling
1 parent e17f455 commit d9cf57b

17 files changed

Lines changed: 399 additions & 136 deletions

documentation/2 usage/4 Building Schemas with the Simple Schema Generator.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ Create a Schema Generator
1616
In order to produce schemas you need to instantiate a schema generator first. This is done with the following Python code:
1717

1818
```python
19-
gen = jk_jsonschema.createSchemaGenerator()
19+
gen = jk_jsonschema.createObjectSchemaGenerator()
2020
```
2121

2222
Note: This function will provide an object for schema generation. As possibly maybe sometimes there might be different implementations in the future, all generation of objects is performed by this method. Please always use this factory method as it will be adapted to future implementations if necessary.
2323

24-
Defeine the Expectations
24+
Define the Expectations
2525
------------------------
2626

2727
After having generated a schema generator you can use it to define your schemas.
@@ -32,7 +32,7 @@ This default schema generator assumes you want to produce a schema matching an o
3232

3333
The object generator provides the following methods:
3434

35-
* `subCategory(name:str, bRequired:bool) -> ObjectGenerator`
35+
* `objectValue(name:str, bRequired:bool) -> ObjectGenerator`
3636
* Expect the current object matched later by the schema to have a key with name `name`.
3737
* Depending on `bRequired` this key later on is required or optional.
3838
* The value of this key should again be an **object**.
@@ -68,14 +68,14 @@ All methods return a new generator object.
6868
For convenience the object generator can be used in a `with` context. Example:
6969

7070
```python
71-
with gen.subCategory("abc") as c:
71+
with gen.objectValue("abc") as c:
7272
c.strValue("cde")
7373
```
7474

7575
The code above has the following meaning:
7676
* An object is expected. (Objects are always expected by default).
77-
* Then this object must have an `abc` key (=> `subCategory()`, no `bRequired=False` is specified).
78-
* For this key another object is expected (=> `subCategory()`).
77+
* Then this object must have an `abc` key (=> `objectValue()`, no `bRequired=False` is specified).
78+
* For this key another object is expected (=> `objectValue()`).
7979
* This value object at this key must itself have a key named `cde` (=> `strValue()`).
8080
* At this key a value of type *string* (=> `strValue()`) must be provided.
8181

@@ -232,7 +232,7 @@ The code above has the following meaning:
232232
### Complex Example
233233

234234
```python
235-
with gen.subCategory("abc") as c:
235+
with gen.objectValue("abc") as c:
236236
c.strValue("cde")
237237
```
238238

documentation/2 usage/5 Verifying JSON data with JSON Schemas.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jsonData = {
105105
"cde": 123
106106
}
107107

108-
gen = jk_jsonschema.createSchemaGenerator()
108+
gen = jk_jsonschema.createObjectSchemaGenerator()
109109
gen.strValue("abc")
110110
gen.intValue("cde")
111111
jsonSchemaData = gen.schema

packageinfo.json

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,53 @@
11
{
2-
"language": "python3",
3-
"name": "jk_json",
4-
"version": "0.2020.7.7",
2+
"documentation": [],
3+
"magic": {
4+
"magic": "packageinfo",
5+
"version": 2
6+
},
57
"meta": {
8+
"authors": [
9+
{
10+
"email": "pubsrc@binary-overflow.de",
11+
"name": "J\u00fcrgen Knauth"
12+
}
13+
],
614
"description": "This python module provides parser and validator for JSON files and data structures. The JSON parser is designed as a drop-in replacement for the built in python JSON parser as this parser here supports using comments in JSON files (which in some use cases is very a very handy feature).",
15+
"development_status": "stable",
716
"keywords": [
817
"json",
918
"parsing",
1019
"schema"
1120
],
12-
"license": "Apache 2.0",
13-
"development_status": "stable",
14-
"authors": [
15-
{
16-
"name": "Jürgen Knauth",
17-
"email": "pubsrc@binary-overflow.de"
18-
}
19-
],
20-
"wiki": {
21-
"page": "DevDocs:jk_json"
22-
}
21+
"language": "python3",
22+
"license": "Apache2",
23+
"name": "jk_json",
24+
"packageClass": "python-module",
25+
"version": "0.2020.11.2"
2326
},
2427
"repositories": [
2528
{
26-
"type": "github",
27-
"user": "jkpubsrc",
29+
"devon_publish": false,
2830
"project": "python-module-jk-json",
29-
"devon_publish": false
31+
"type": "github",
32+
"user": "jkpubsrc"
3033
},
3134
{
32-
"type": "pypy",
35+
"devon_publish": false,
3336
"project": "jk_json",
34-
"devon_publish": false
37+
"type": "pypi"
3538
}
3639
],
40+
"requirements": {
41+
"python_packages": [
42+
"chardet"
43+
],
44+
"python_packages_dev": [],
45+
"system_apt_packages": []
46+
},
3747
"source": {
38-
"packages": [
39-
"jk_json",
40-
"jk_json.tools",
41-
"jk_jsonschema"
48+
"extra_binary_files": [
49+
"bin/jsonPrettyPrint.py",
50+
"bin/jkjson.py"
4251
],
4352
"extra_data_files": [
4453
"data/*",
@@ -47,17 +56,10 @@
4756
"data/html_default/files/images/*",
4857
"data/html_default/templates/*"
4958
],
50-
"extra_binary_files": [
51-
"bin/jsonPrettyPrint.py",
52-
"bin/jkjson.py",
53-
]
54-
},
55-
"requirements": {
56-
"python_packages": [
57-
"chardet"
58-
],
59-
"python_packages_dev": [
59+
"packages": [
60+
"jk_json",
61+
"jk_json.tools",
62+
"jk_jsonschema"
6063
]
6164
}
62-
}
63-
65+
}

src/LICENSE.txt

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
 Apache License
1+
Apache License
22
Version 2.0, January 2004
33
http://www.apache.org/licenses/
44

@@ -174,28 +174,3 @@
174174
of your accepting any such warranty or additional liability.
175175

176176
END OF TERMS AND CONDITIONS
177-
178-
APPENDIX: How to apply the Apache License to your work.
179-
180-
To apply the Apache License to your work, attach the following
181-
boilerplate notice, with the fields enclosed by brackets "{}"
182-
replaced with your own identifying information. (Don't include
183-
the brackets!) The text should be enclosed in the appropriate
184-
comment syntax for the file format. We also recommend that a
185-
file or class name and description of purpose be included on the
186-
same "printed page" as the copyright notice for easier
187-
identification within third-party archives.
188-
189-
Copyright {yyyy} {name of copyright owner}
190-
191-
Licensed under the Apache License, Version 2.0 (the "License");
192-
you may not use this file except in compliance with the License.
193-
You may obtain a copy of the License at
194-
195-
http://www.apache.org/licenses/LICENSE-2.0
196-
197-
Unless required by applicable law or agreed to in writing, software
198-
distributed under the License is distributed on an "AS IS" BASIS,
199-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200-
See the License for the specific language governing permissions and
201-
limitations under the License.

src/MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ include data/html_default/*
66
include data/html_default/files/*
77
include data/html_default/files/images/*
88
include data/html_default/templates/*
9+

src/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
jk_json
1+
jk_json
22
=======
33

44
Introduction

src/jk_json/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
__version__ = "0.2020.7.7"
3+
__version__ = "0.2020.11.2"
44

55

66

@@ -198,4 +198,3 @@ def prettyPrint(jsonObj, linePrefix=None):
198198

199199
print(dumps(jsonObj, indent="\t", sort_keys=True, linePrefix=linePrefix, cls=ObjectEncoder))
200200
#
201-

src/jk_json/tools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212

1313

1414

15-
__version__ = "0.2020.7.7"
15+
__version__ = "0.2020.11.2"

src/jk_jsonschema/SchemaParser.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
31

42

53

0 commit comments

Comments
 (0)