Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
opcua-asyncio
Commits
c30f32bc
Commit
c30f32bc
authored
Jan 11, 2021
by
oroulet
Committed by
oroulet
Jan 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pylint + remove print and some warnings
parent
f8945ce0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
13 deletions
+10
-13
asyncua/common/structures104.py
asyncua/common/structures104.py
+10
-13
No files found.
asyncua/common/structures104.py
View file @
c30f32bc
from
enum
import
Enum
from
enum
import
IntEnum
from
datetime
import
datetime
import
uuid
from
enum
import
IntEnum
import
logging
import
re
from
typing
import
Union
,
List
,
TYPE_CHECKING
,
Tuple
...
...
@@ -104,24 +104,23 @@ def get_default_value(uatype, enums=None):
enums = {}
if uatype == "String":
return "None"
el
if uatype == "Guid":
if uatype == "Guid":
return "uuid.uuid4()"
el
if uatype in ("ByteString", "CharArray", "Char"):
if uatype in ("ByteString", "CharArray", "Char"):
return b''
el
if uatype == "Boolean":
if uatype == "Boolean":
return "True"
el
if uatype == "DateTime":
if uatype == "DateTime":
return "datetime.utcnow()"
el
if uatype in ("Int16", "Int32", "Int64", "UInt16", "UInt32", "UInt64", "Double", "Float", "Byte", "SByte"):
if uatype in ("Int16", "Int32", "Int64", "UInt16", "UInt32", "UInt64", "Double", "Float", "Byte", "SByte"):
return 0
el
if uatype in enums:
if uatype in enums:
return f"ua.{uatype}({enums[uatype]})"
el
if hasattr(ua, uatype) and issubclass(getattr(ua, uatype), Enum):
if hasattr(ua, uatype) and issubclass(getattr(ua, uatype), Enum):
# We have an enum, try to initilize it correctly
val = list(getattr(ua, uatype).__members__)[0]
return f"ua.{uatype}.{val}"
else:
return f"ua.{uatype}()"
return f"ua.{uatype}()"
def make_structure_code(data_type, struct_name, sdef):
...
...
@@ -225,8 +224,6 @@ async def _generate_object(name, sdef, data_type=None, env=None, enum=False):
code = make_enum_code(name, sdef)
else:
code = make_structure_code(data_type, name, sdef)
print("SDEF", sdef)
print("CODE", code)
logger.debug("Executing code: %s", code)
exec(code, env)
return env
...
...
@@ -292,7 +289,7 @@ async def _read_data_type_definition(server, desc):
try:
sdef = await node.read_data_type_definition()
except ua.uaerrors.BadAttributeIdInvalid:
logger.
warnin
g("%s has no DataTypeDefinition atttribute", node)
logger.
debu
g("%s has no DataTypeDefinition atttribute", node)
return None
except Exception:
logger.exception("Error getting datatype for node %s", node)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment