objdictgen 3.4__tar.gz → 3.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {objdictgen-3.4/src/objdictgen.egg-info → objdictgen-3.5}/PKG-INFO +5 -4
- {objdictgen-3.4 → objdictgen-3.5}/README.md +2 -2
- {objdictgen-3.4 → objdictgen-3.5}/setup.cfg +2 -1
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/__init__.py +1 -1
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/__main__.py +2 -2
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/jsonod.py +42 -35
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/nodemanager.py +7 -3
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/ui/objdictedit.py +5 -3
- {objdictgen-3.4 → objdictgen-3.5/src/objdictgen.egg-info}/PKG-INFO +5 -4
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen.egg-info/requires.txt +2 -1
- {objdictgen-3.4 → objdictgen-3.5}/tests/test_jsonod.py +28 -1
- {objdictgen-3.4 → objdictgen-3.5}/tests/test_main.py +3 -3
- {objdictgen-3.4 → objdictgen-3.5}/tests/test_nodemanager.py +1 -1
- {objdictgen-3.4 → objdictgen-3.5}/LICENSE +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/pyproject.toml +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/config/DS-302.prf +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/config/DS-401.prf +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/config/DS-402.prf +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/config/DS-404.prf +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/config/DS-406.prf +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/config/DS-408.prf +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/config/DS-410.prf +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/config/DS-418.prf +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/config/DS-419.prf +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/eds_utils.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/gen_cfile.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/img/networkedit.ico +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/img/networkedit.png +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/maps.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/node.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/nodelist.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/nosis.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/py.typed +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/schema/od.schema.json +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/typing.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/ui/__init__.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/ui/commondialogs.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/ui/exception.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/ui/networkedit.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/ui/networkeditortemplate.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/ui/nodeeditortemplate.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen/ui/subindextable.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen.egg-info/SOURCES.txt +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen.egg-info/dependency_links.txt +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen.egg-info/entry_points.txt +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/src/objdictgen.egg-info/top_level.txt +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/tests/test_imports.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/tests/test_knownfailures.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/tests/test_maps.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/tests/test_node.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/tests/test_nodelist.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/tests/test_nosis.py +0 -0
- {objdictgen-3.4 → objdictgen-3.5}/tests/test_odcompare.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: objdictgen
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.5
|
|
4
4
|
Summary: CanFestival Object Dictionary tool
|
|
5
5
|
Home-page: https://github.com/Laerdal/python-objdictgen
|
|
6
6
|
Author: Svein Seldal
|
|
@@ -23,7 +23,7 @@ Description-Content-Type: text/markdown
|
|
|
23
23
|
License-File: LICENSE
|
|
24
24
|
Requires-Dist: jsonschema
|
|
25
25
|
Requires-Dist: colorama
|
|
26
|
-
Requires-Dist: deepdiff
|
|
26
|
+
Requires-Dist: deepdiff<8.0.0
|
|
27
27
|
Provides-Extra: ui
|
|
28
28
|
Requires-Dist: wxPython; extra == "ui"
|
|
29
29
|
Provides-Extra: dist
|
|
@@ -39,6 +39,7 @@ Requires-Dist: pytest; extra == "dev"
|
|
|
39
39
|
Requires-Dist: coverage; extra == "dev"
|
|
40
40
|
Requires-Dist: pytest-cov; extra == "dev"
|
|
41
41
|
Requires-Dist: pytest-mock; extra == "dev"
|
|
42
|
+
Requires-Dist: freezegun; extra == "dev"
|
|
42
43
|
|
|
43
44
|
# Objdictgen (`odg`)
|
|
44
45
|
|
|
@@ -70,8 +71,8 @@ To install into a virtual environment `venv`. Check out this repo and go to
|
|
|
70
71
|
the top in a command-prompt (here assuming Windows and git bash):
|
|
71
72
|
|
|
72
73
|
$ py -3 -mvenv venv
|
|
73
|
-
$ venv/Scripts/python -mpip install --upgrade pip
|
|
74
|
-
$ venv/Scripts/pip install
|
|
74
|
+
$ venv/Scripts/python -mpip install --upgrade pip setuptools # Optional
|
|
75
|
+
$ venv/Scripts/pip install objdictgen[ui] # [ui] will install GUI tools
|
|
75
76
|
|
|
76
77
|
After this `venv/Scripts/odg.exe` (on Windows) will exist and can be called
|
|
77
78
|
from anywhere to run it.
|
|
@@ -28,8 +28,8 @@ To install into a virtual environment `venv`. Check out this repo and go to
|
|
|
28
28
|
the top in a command-prompt (here assuming Windows and git bash):
|
|
29
29
|
|
|
30
30
|
$ py -3 -mvenv venv
|
|
31
|
-
$ venv/Scripts/python -mpip install --upgrade pip
|
|
32
|
-
$ venv/Scripts/pip install
|
|
31
|
+
$ venv/Scripts/python -mpip install --upgrade pip setuptools # Optional
|
|
32
|
+
$ venv/Scripts/pip install objdictgen[ui] # [ui] will install GUI tools
|
|
33
33
|
|
|
34
34
|
After this `venv/Scripts/odg.exe` (on Windows) will exist and can be called
|
|
35
35
|
from anywhere to run it.
|
|
@@ -31,7 +31,7 @@ python_requires = >=3.10, <4
|
|
|
31
31
|
install_requires =
|
|
32
32
|
jsonschema
|
|
33
33
|
colorama
|
|
34
|
-
deepdiff
|
|
34
|
+
deepdiff<8.0.0
|
|
35
35
|
|
|
36
36
|
[options.packages.find]
|
|
37
37
|
where = src
|
|
@@ -58,6 +58,7 @@ dev =
|
|
|
58
58
|
coverage
|
|
59
59
|
pytest-cov
|
|
60
60
|
pytest-mock
|
|
61
|
+
freezegun
|
|
61
62
|
|
|
62
63
|
[options.entry_points]
|
|
63
64
|
console_scripts =
|
|
@@ -128,7 +128,7 @@ def list_od(
|
|
|
128
128
|
"""Generator for producing the output for odg list"""
|
|
129
129
|
|
|
130
130
|
# Get the indexes to print and determine the order
|
|
131
|
-
keys = od.GetAllIndices(sort=
|
|
131
|
+
keys = od.GetAllIndices(sort=opts.sort)
|
|
132
132
|
if opts.index:
|
|
133
133
|
indexp = [jsonod.str_to_int(i) for i in opts.index]
|
|
134
134
|
keys = [k for k in keys if k in indexp]
|
|
@@ -259,7 +259,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None):
|
|
|
259
259
|
subp.add_argument('-i', '--index', action="append", help="Specify parameter index to show")
|
|
260
260
|
subp.add_argument('--all', action="store_true",
|
|
261
261
|
help="Show all subindexes, including subindex 0")
|
|
262
|
-
subp.add_argument('--
|
|
262
|
+
subp.add_argument('--sort', action="store_true", help="Sort output")
|
|
263
263
|
subp.add_argument('--compact', action="store_true", help="Compact listing")
|
|
264
264
|
subp.add_argument('--raw', action="store_true", help="Show raw parameter values")
|
|
265
265
|
subp.add_argument('--short', action="store_true", help="Do not list sub-index")
|
|
@@ -240,6 +240,14 @@ def remove_underscore(d: T) -> T:
|
|
|
240
240
|
remove_underscore(v)
|
|
241
241
|
for v in d
|
|
242
242
|
]
|
|
243
|
+
if isinstance(d, str):
|
|
244
|
+
# Remove comments from any @@ fields
|
|
245
|
+
return re.sub( # type: ignore[return-value]
|
|
246
|
+
r'@@"?(.*?)"?(\s*//.*?)?@@',
|
|
247
|
+
lambda m: m[1].replace('\\"', '"'),
|
|
248
|
+
d,
|
|
249
|
+
flags=re.MULTILINE,
|
|
250
|
+
)
|
|
243
251
|
return d
|
|
244
252
|
|
|
245
253
|
|
|
@@ -353,7 +361,7 @@ def generate_jsonc(node: "Node", compact=False, sort=False, internal=False, vali
|
|
|
353
361
|
""" Export a JSONC string representation of the node """
|
|
354
362
|
|
|
355
363
|
# Get the dict representation
|
|
356
|
-
jd
|
|
364
|
+
jd = node_todict(
|
|
357
365
|
node, sort=sort, internal=internal, validate=validate,
|
|
358
366
|
rich=not compact,
|
|
359
367
|
)
|
|
@@ -365,39 +373,22 @@ def generate_jsonc(node: "Node", compact=False, sort=False, internal=False, vali
|
|
|
365
373
|
# Generate the json string
|
|
366
374
|
text = json.dumps(jd, separators=(',', ': '), indent=2)
|
|
367
375
|
|
|
368
|
-
# Convert the special __ fields to
|
|
369
|
-
|
|
376
|
+
# Convert the special __ fields to jsonc comments
|
|
377
|
+
text = re.sub(
|
|
370
378
|
r'^(\s*)"__(\w+)": "(.*)",?$',
|
|
371
379
|
r'\1// "\2": "\3"',
|
|
372
380
|
text,
|
|
373
381
|
flags=re.MULTILINE,
|
|
374
382
|
)
|
|
375
383
|
|
|
376
|
-
#
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
n = str_to_int(v)
|
|
382
|
-
if p == 'type':
|
|
383
|
-
n = objtypes_s2i.get(v, v)
|
|
384
|
-
if n != v:
|
|
385
|
-
return m.group(0) + f' // {n}'
|
|
386
|
-
return m.group(0)
|
|
387
|
-
out = re.sub( # As object entries
|
|
388
|
-
r'"(index|type)": "([a-zA-Z0-9_]+)",?$',
|
|
389
|
-
_index_repl,
|
|
390
|
-
out,
|
|
391
|
-
flags=re.MULTILINE,
|
|
392
|
-
)
|
|
393
|
-
out = re.sub( # As comments
|
|
394
|
-
r'// (index|type): "([a-zA-Z0-9_]+)"',
|
|
395
|
-
_index_repl,
|
|
396
|
-
out,
|
|
384
|
+
# Convert the special @@ fields to jsonc comments
|
|
385
|
+
text = re.sub(
|
|
386
|
+
r'"@@(.*?)(\s*//.*?)?@@"(.*)$',
|
|
387
|
+
lambda m: m[1].replace('\\"', '"') + m[3] + m[2],
|
|
388
|
+
text,
|
|
397
389
|
flags=re.MULTILINE,
|
|
398
390
|
)
|
|
399
|
-
|
|
400
|
-
return out
|
|
391
|
+
return text
|
|
401
392
|
|
|
402
393
|
|
|
403
394
|
def generate_node(contents: str|TODJson) -> "Node":
|
|
@@ -440,7 +431,7 @@ def generate_node(contents: str|TODJson) -> "Node":
|
|
|
440
431
|
return node_fromdict(jd, objtypes_s2i)
|
|
441
432
|
|
|
442
433
|
|
|
443
|
-
def node_todict(node: "Node", sort=False, rich=True, internal=False, validate=True) ->
|
|
434
|
+
def node_todict(node: "Node", sort=False, rich=True, internal=False, validate=True) -> TODJson:
|
|
444
435
|
"""
|
|
445
436
|
Convert a node to dict representation for serialization.
|
|
446
437
|
|
|
@@ -500,7 +491,8 @@ def node_todict(node: "Node", sort=False, rich=True, internal=False, validate=Tr
|
|
|
500
491
|
finally:
|
|
501
492
|
# Add in a fancyer index (do it here after index is finished being used)
|
|
502
493
|
if rich:
|
|
503
|
-
|
|
494
|
+
index = obj["index"]
|
|
495
|
+
obj["index"] = f'@@"0x{index:04X}" // {index}@@'
|
|
504
496
|
|
|
505
497
|
dictionary.append(obj)
|
|
506
498
|
|
|
@@ -510,7 +502,7 @@ def node_todict(node: "Node", sort=False, rich=True, internal=False, validate=Tr
|
|
|
510
502
|
'$version': JSON_INTERNAL_VERSION if internal else JSON_VERSION,
|
|
511
503
|
'$description': JSON_DESCRIPTION,
|
|
512
504
|
'$tool': str(objdictgen.ODG_PROGRAM) + ' ' + str(objdictgen.__version__),
|
|
513
|
-
'$date': datetime.
|
|
505
|
+
'$date': datetime.now().astimezone().isoformat(),
|
|
514
506
|
'name': node.Name,
|
|
515
507
|
'description': node.Description,
|
|
516
508
|
'type': node.Type,
|
|
@@ -532,9 +524,9 @@ def node_todict(node: "Node", sort=False, rich=True, internal=False, validate=Tr
|
|
|
532
524
|
|
|
533
525
|
# Cross check verification to see if we later can import the generated dict
|
|
534
526
|
if validate and not internal:
|
|
535
|
-
|
|
527
|
+
validate_fromdict(remove_underscore(jd), objtypes_i2s, objtypes_s2i)
|
|
536
528
|
|
|
537
|
-
return jd
|
|
529
|
+
return jd
|
|
538
530
|
|
|
539
531
|
|
|
540
532
|
def indexentry_to_jsondict(ientry: TIndexEntry) -> TODObjJson:
|
|
@@ -725,12 +717,27 @@ def rearrage_for_json(obj: TODObjJson, node: "Node", objtypes_i2s: dict[int, str
|
|
|
725
717
|
# Replace numeric type with string value
|
|
726
718
|
if rich and "type" in sub:
|
|
727
719
|
# FIXME: The cast is to ensure mypy is able keep track
|
|
728
|
-
|
|
720
|
+
n = objtypes_i2s.get(cast(int, sub["type"]), sub["type"])
|
|
721
|
+
sub["type"] = f'@@"{n}" // {sub["type"]}@@'
|
|
729
722
|
|
|
730
|
-
#
|
|
723
|
+
# Add __type when rich format
|
|
731
724
|
if info and "type" not in sub:
|
|
732
725
|
sub["__type"] = objtypes_i2s.get(info["type"], info["type"])
|
|
733
726
|
|
|
727
|
+
# Replace value
|
|
728
|
+
if rich and "value" in sub:
|
|
729
|
+
ir = maps.INDEX_RANGES.get_index_range(index)
|
|
730
|
+
if i > 0 and ir and ir.name in ('rpdom', 'tpdom'):
|
|
731
|
+
value = sub["value"]
|
|
732
|
+
value_h = f"{value:08X}"
|
|
733
|
+
try:
|
|
734
|
+
idx, subidx, _ = node.GetMapIndex(value)
|
|
735
|
+
pdo = node.GetSubentryInfos(idx, subidx)
|
|
736
|
+
name = pdo["name"]
|
|
737
|
+
except ValueError:
|
|
738
|
+
name = '???'
|
|
739
|
+
sub["value"] = f'@@{value} // 0x{value_h[0:4]}_{value_h[4:6]}_{value_h[6:]} {name}@@'
|
|
740
|
+
|
|
734
741
|
if 'each' in obj:
|
|
735
742
|
each = obj["each"]
|
|
736
743
|
|
|
@@ -1414,8 +1421,8 @@ def diff_nodes(node1: "Node", node2: "Node", asdict=True, validate=True) -> TDif
|
|
|
1414
1421
|
diffs: dict[int|str, list] = {}
|
|
1415
1422
|
|
|
1416
1423
|
if asdict:
|
|
1417
|
-
jd1
|
|
1418
|
-
jd2
|
|
1424
|
+
jd1 = node_todict(node1, sort=True, validate=validate)
|
|
1425
|
+
jd2 = node_todict(node2, sort=True, validate=validate)
|
|
1419
1426
|
|
|
1420
1427
|
dt = datetime.isoformat(datetime.now())
|
|
1421
1428
|
jd1['$date'] = jd2['$date'] = dt
|
|
@@ -482,9 +482,13 @@ class NodeManager:
|
|
|
482
482
|
node.AddEntry(index, 1, default)
|
|
483
483
|
# Second case entry is a record
|
|
484
484
|
else:
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
485
|
+
i = 0
|
|
486
|
+
while True:
|
|
487
|
+
try:
|
|
488
|
+
i += 1
|
|
489
|
+
subentry_infos = node.GetSubentryInfos(index, i)
|
|
490
|
+
except ValueError:
|
|
491
|
+
break
|
|
488
492
|
if "default" in subentry_infos:
|
|
489
493
|
default = subentry_infos["default"]
|
|
490
494
|
else:
|
|
@@ -457,7 +457,8 @@ class ObjdictEdit(NodeEditorTemplate):
|
|
|
457
457
|
|
|
458
458
|
def Save(self):
|
|
459
459
|
try:
|
|
460
|
-
|
|
460
|
+
# Sort only applies if saving JSON file
|
|
461
|
+
result = self.Manager.SaveCurrentInFile(sort=True)
|
|
461
462
|
if not result:
|
|
462
463
|
self.SaveAs()
|
|
463
464
|
else:
|
|
@@ -487,8 +488,9 @@ class ObjdictEdit(NodeEditorTemplate):
|
|
|
487
488
|
display_error_dialog(self, f"'{os.path.dirname(filepath)}' is not a valid folder!")
|
|
488
489
|
else:
|
|
489
490
|
try:
|
|
490
|
-
# Try and save the file and then update the filepath if
|
|
491
|
-
if
|
|
491
|
+
# Try and save the file and then update the filepath if successful
|
|
492
|
+
# Sort only applies if saving JSON file
|
|
493
|
+
if self.Manager.SaveCurrentInFile(filepath, sort=True):
|
|
492
494
|
self.Manager.SetCurrentFilePath(filepath)
|
|
493
495
|
self.RefreshBufferState()
|
|
494
496
|
except Exception: # pylint: disable=broad-except
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: objdictgen
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.5
|
|
4
4
|
Summary: CanFestival Object Dictionary tool
|
|
5
5
|
Home-page: https://github.com/Laerdal/python-objdictgen
|
|
6
6
|
Author: Svein Seldal
|
|
@@ -23,7 +23,7 @@ Description-Content-Type: text/markdown
|
|
|
23
23
|
License-File: LICENSE
|
|
24
24
|
Requires-Dist: jsonschema
|
|
25
25
|
Requires-Dist: colorama
|
|
26
|
-
Requires-Dist: deepdiff
|
|
26
|
+
Requires-Dist: deepdiff<8.0.0
|
|
27
27
|
Provides-Extra: ui
|
|
28
28
|
Requires-Dist: wxPython; extra == "ui"
|
|
29
29
|
Provides-Extra: dist
|
|
@@ -39,6 +39,7 @@ Requires-Dist: pytest; extra == "dev"
|
|
|
39
39
|
Requires-Dist: coverage; extra == "dev"
|
|
40
40
|
Requires-Dist: pytest-cov; extra == "dev"
|
|
41
41
|
Requires-Dist: pytest-mock; extra == "dev"
|
|
42
|
+
Requires-Dist: freezegun; extra == "dev"
|
|
42
43
|
|
|
43
44
|
# Objdictgen (`odg`)
|
|
44
45
|
|
|
@@ -70,8 +71,8 @@ To install into a virtual environment `venv`. Check out this repo and go to
|
|
|
70
71
|
the top in a command-prompt (here assuming Windows and git bash):
|
|
71
72
|
|
|
72
73
|
$ py -3 -mvenv venv
|
|
73
|
-
$ venv/Scripts/python -mpip install --upgrade pip
|
|
74
|
-
$ venv/Scripts/pip install
|
|
74
|
+
$ venv/Scripts/python -mpip install --upgrade pip setuptools # Optional
|
|
75
|
+
$ venv/Scripts/pip install objdictgen[ui] # [ui] will install GUI tools
|
|
75
76
|
|
|
76
77
|
After this `venv/Scripts/odg.exe` (on Windows) will exist and can be called
|
|
77
78
|
from anywhere to run it.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import re
|
|
2
2
|
from pprint import pprint
|
|
3
|
+
import datetime
|
|
4
|
+
from freezegun import freeze_time
|
|
3
5
|
from objdictgen import Node
|
|
4
6
|
from objdictgen.jsonod import generate_jsonc, generate_node, remove_jsonc
|
|
5
7
|
from .test_odcompare import shave_equal
|
|
@@ -103,3 +105,28 @@ def test_jsonod_roundtrip_internal(odjsoneds):
|
|
|
103
105
|
|
|
104
106
|
a, b = shave_equal(m1, m2, ignore=["IndexOrder", "DefaultStringSize"])
|
|
105
107
|
assert a == b
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def test_jsonod_timezone():
|
|
111
|
+
""" Test timezone handling in the jsonod module. """
|
|
112
|
+
|
|
113
|
+
for now, offset, cmp in [
|
|
114
|
+
("2020-01-01 12:00:00", None, "2020-01-01T12:00:00"),
|
|
115
|
+
("2020-01-01 12:00:00", 5, "2020-01-01T17:00:00"),
|
|
116
|
+
("2020-01-01 12:00:00", -5, "2020-01-01T07:00:00"),
|
|
117
|
+
]:
|
|
118
|
+
kw = {}
|
|
119
|
+
if offset is not None:
|
|
120
|
+
kw["tz_offset"] = offset
|
|
121
|
+
with freeze_time(now, **kw):
|
|
122
|
+
# The tzoffset is dependent on the current time, so we need to calculate it
|
|
123
|
+
tzoffset = datetime.datetime.now().astimezone().utcoffset()
|
|
124
|
+
tz = f"{tzoffset.seconds//3600:02}:{tzoffset.seconds%60:02}"
|
|
125
|
+
print(f"tzoffset: {tzoffset}, {type(tzoffset)} {tz}")
|
|
126
|
+
|
|
127
|
+
od = Node()
|
|
128
|
+
out = generate_jsonc(od, compact=False, sort=False, internal=False, validate=True)
|
|
129
|
+
m = re.search(r'^\s+"\$date": "(.*?)",$', out, re.M)
|
|
130
|
+
if m:
|
|
131
|
+
print(m[1])
|
|
132
|
+
assert m[1] == cmp + "+" + tz
|
|
@@ -28,21 +28,21 @@ def test_main_list_od(odpath, file):
|
|
|
28
28
|
|
|
29
29
|
import argparse
|
|
30
30
|
ns = argparse.Namespace(
|
|
31
|
-
|
|
31
|
+
sort=True, index=[], compact=False, short=False, unused=True,
|
|
32
32
|
all=True, raw=False
|
|
33
33
|
)
|
|
34
34
|
|
|
35
35
|
lines = list(__main__.list_od(od, file, ns))
|
|
36
36
|
|
|
37
37
|
ns = argparse.Namespace(
|
|
38
|
-
|
|
38
|
+
sort=True, index=[0x1000], compact=False, short=False, unused=True,
|
|
39
39
|
all=True, raw=False
|
|
40
40
|
)
|
|
41
41
|
|
|
42
42
|
lines = list(__main__.list_od(od, file, ns))
|
|
43
43
|
|
|
44
44
|
ns = argparse.Namespace(
|
|
45
|
-
|
|
45
|
+
sort=True, index=[0x5000], compact=False, short=False, unused=True,
|
|
46
46
|
all=True, raw=False
|
|
47
47
|
)
|
|
48
48
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|