Main Page
Namespaces
Classes
Files
File List
python-opcua
schemas
generate_uaerrors.py
Go to the documentation of this file.
1
from
textwrap
import
dedent
2
from
generate_statuscode
import
status_codes
3
from
string
import
Template
4
5
if
__name__ ==
"__main__"
:
6
codes =
status_codes
()
7
8
with open(
"../opcua/ua/errors/_auto.py"
,
"w"
)
as
f:
9
preamble =
"""\
10
#AUTOGENERATED!!!
11
12
from opcua.ua.uaerrors import UaStatusCodeError
13
14
15
"""
16
17
f.write(dedent(preamble))
18
19
for
name, code, _
in
codes:
20
# skip non-bad because they should not be thrown as exceptions
21
if
not
name.startswith(
"Bad"
):
22
continue
23
24
template = Template(dedent(
"""\
25
class $name(UaStatusCodeError):
26
code = $code
27
"""
))
28
print(template.safe_substitute(name=name, code=code), file=f)
generate_statuscode.status_codes
def status_codes()
Definition:
generate_statuscode.py:4
ros_opcua_impl_python_opcua
Author(s): Denis Štogl
, Daniel Draper
autogenerated on Tue Jan 19 2021 03:12:44