Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2916210
messages.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
731 B
Referenced Files
None
Subscribers
None
messages.py
View Options
import
sys
try
:
import
tomllib
except
ModuleNotFoundError
:
try
:
import
tomli
as
tomllib
except
ModuleNotFoundError
as
exc
:
raise
ModuleNotFoundError
(
"No TOML parser available. Use Python 3.11+ or install 'tomli'."
)
from
exc
with
open
(
sys
.
argv
[
1
],
"rb"
)
as
f
:
messages
=
tomllib
.
load
(
f
)
print
(
"#ifndef MESSAGES_H"
)
print
(
"#define MESSAGES_H"
)
print
(
""
)
print
(
"typedef struct {"
)
for
name
in
messages
:
print
(
f
" const char *{name};"
)
print
(
"} ant_messages_t;"
)
print
(
""
)
print
(
"static const ant_messages_t msg = {"
)
for
name
,
value
in
messages
.
items
():
escaped
=
value
.
encode
(
"unicode_escape"
)
.
decode
()
.
replace
(
'"'
,
'
\\
"'
)
print
(
f
' .{name} = "{escaped}",'
)
print
(
"};"
)
print
(
""
)
print
(
"#endif"
)
File Metadata
Details
Attached
Mime Type
text/x-script.python
Expires
Thu, Mar 26, 4:44 PM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
511906
Default Alt Text
messages.py (731 B)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment