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
42889db6
Commit
42889db6
authored
Jul 28, 2023
by
Yuta Okamoto
Committed by
oroulet
Jul 31, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add default_idx parameter to QualifiedName
parent
31e3e78f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
asyncua/ua/uatypes.py
asyncua/ua/uatypes.py
+2
-2
tests/test_unit.py
tests/test_unit.py
+11
-0
No files found.
asyncua/ua/uatypes.py
View file @
42889db6
...
...
@@ -683,7 +683,7 @@ class QualifiedName:
return
f"
{
self
.
NamespaceIndex
}
:
{
self
.
Name
}
"
@
staticmethod
def
from_string
(
string
):
def
from_string
(
string
,
default_idx
=
0
):
if
":"
in
string
:
try
:
idx
,
name
=
string
.
split
(
":"
,
1
)
...
...
@@ -691,7 +691,7 @@ class QualifiedName:
except
(
TypeError
,
ValueError
)
as
ex
:
raise
UaStringParsingError
(
f"Error parsing string
{
string
}
"
,
ex
)
from
ex
else
:
idx
=
0
idx
=
default_idx
name
=
string
return
QualifiedName
(
Name
=
name
,
NamespaceIndex
=
idx
)
...
...
tests/test_unit.py
View file @
42889db6
...
...
@@ -456,6 +456,17 @@ def test_nodeid_string():
# nid1 = ua.StringNodeId(1, 2)
def
test_qualifiedname_string
():
qname1
=
ua
.
QualifiedName
.
from_string
(
"Name"
)
assert
(
0
,
"Name"
)
==
(
qname1
.
NamespaceIndex
,
qname1
.
Name
)
qname2
=
ua
.
QualifiedName
.
from_string
(
"1:Name"
)
assert
(
1
,
"Name"
)
==
(
qname2
.
NamespaceIndex
,
qname2
.
Name
)
qname3
=
ua
.
QualifiedName
.
from_string
(
"Name"
,
default_idx
=
2
)
assert
(
2
,
"Name"
)
==
(
qname3
.
NamespaceIndex
,
qname3
.
Name
)
qname4
=
ua
.
QualifiedName
.
from_string
(
"3:Name"
,
default_idx
=
2
)
assert
(
3
,
"Name"
)
==
(
qname4
.
NamespaceIndex
,
qname4
.
Name
)
def
test_bad_string
():
with
pytest
.
raises
(
ua
.
UaStringParsingError
):
ua
.
NodeId
.
from_string
(
"ns=r;s=yu"
)
...
...
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