Generate style compliant code
This commit is contained in:
parent
4f658378eb
commit
b14085019c
@ -37,6 +37,7 @@ def main() -> None: # pragma: no cover
|
||||
if '/msg/' not in str(name):
|
||||
name = name.parent / 'msg' / name.name
|
||||
typs.update(get_types_from_msg(path.read_text(encoding='utf-8'), str(name)))
|
||||
typs = dict(sorted(typs.items()))
|
||||
register_types(typs)
|
||||
(selfdir / 'types.py').write_text(generate_python_code(typs))
|
||||
|
||||
|
||||
@ -76,6 +76,7 @@ def generate_python_code(typs: Typesdict) -> str:
|
||||
'',
|
||||
' from .base import Typesdict',
|
||||
'',
|
||||
'',
|
||||
]
|
||||
|
||||
for name, (consts, fields) in typs.items():
|
||||
@ -107,11 +108,21 @@ def generate_python_code(typs: Typesdict) -> str:
|
||||
for name, (consts, fields) in typs.items():
|
||||
pyname = name.replace('/', '__')
|
||||
lines += [
|
||||
f' \'{name}\': ([',
|
||||
*[f' ({fname!r}, {ftype!r}, {fvalue!r}),' for fname, ftype, fvalue in consts],
|
||||
' ], [',
|
||||
*[f' ({fname!r}, {get_ftype(ftype)!r}),' for fname, ftype in fields],
|
||||
' ]),',
|
||||
f' \'{name}\': (',
|
||||
*(
|
||||
[
|
||||
' [',
|
||||
*[
|
||||
f' ({fname!r}, {ftype!r}, {fvalue!r}),'
|
||||
for fname, ftype, fvalue in consts
|
||||
],
|
||||
' ],',
|
||||
] if consts else [' [],']
|
||||
),
|
||||
' [',
|
||||
*[f' ({fname!r}, {get_ftype(ftype)!r}),' for fname, ftype in fields],
|
||||
' ],',
|
||||
' ),',
|
||||
]
|
||||
lines += [
|
||||
'}',
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user