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
61129442
Commit
61129442
authored
Aug 04, 2023
by
Yuta Okamoto
Committed by
oroulet
Aug 09, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support the nested list result in sync functions
parent
2523d1e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
4 deletions
+19
-4
asyncua/sync.py
asyncua/sync.py
+5
-2
tests/test_sync.py
tests/test_sync.py
+14
-2
No files found.
asyncua/sync.py
View file @
61129442
...
@@ -77,8 +77,11 @@ def _to_async(args, kwargs):
...
@@ -77,8 +77,11 @@ def _to_async(args, kwargs):
def
_to_sync
(
tloop
,
result
):
def
_to_sync
(
tloop
,
result
):
if
isinstance
(
result
,
node
.
Node
):
if
isinstance
(
result
,
node
.
Node
):
return
SyncNode
(
tloop
,
result
)
return
SyncNode
(
tloop
,
result
)
if
isinstance
(
result
,
(
list
,
tuple
))
and
len
(
result
)
>
0
and
isinstance
(
result
[
0
],
node
.
Node
):
if
isinstance
(
result
,
(
list
,
tuple
))
and
len
(
result
)
>
0
:
return
[
SyncNode
(
tloop
,
i
)
for
i
in
result
]
if
isinstance
(
result
[
0
],
node
.
Node
):
return
[
SyncNode
(
tloop
,
i
)
for
i
in
result
]
elif
isinstance
(
result
[
0
],
(
list
,
tuple
)):
return
[
_to_sync
(
tloop
,
item
)
for
item
in
result
]
if
isinstance
(
result
,
server
.
event_generator
.
EventGenerator
):
if
isinstance
(
result
,
server
.
event_generator
.
EventGenerator
):
return
EventGenerator
(
tloop
,
result
)
return
EventGenerator
(
tloop
,
result
)
if
isinstance
(
result
,
subscription
.
Subscription
):
if
isinstance
(
result
,
subscription
.
Subscription
):
...
...
tests/test_sync.py
View file @
61129442
...
@@ -93,7 +93,7 @@ def test_sync_async_client_method(client, idx):
...
@@ -93,7 +93,7 @@ def test_sync_async_client_method(client, idx):
assert
results
[
0
].
Value
.
Value
==
6.7
assert
results
[
0
].
Value
.
Value
==
6.7
def
test_sync_client_get_node
(
client
):
def
test_sync_client_get_node
(
client
,
idx
):
node
=
client
.
get_node
(
85
)
node
=
client
.
get_node
(
85
)
assert
node
==
client
.
nodes
.
objects
assert
node
==
client
.
nodes
.
objects
nodes
=
node
.
get_children
()
nodes
=
node
.
get_children
()
...
@@ -101,8 +101,14 @@ def test_sync_client_get_node(client):
...
@@ -101,8 +101,14 @@ def test_sync_client_get_node(client):
assert
nodes
[
0
]
==
client
.
nodes
.
server
assert
nodes
[
0
]
==
client
.
nodes
.
server
assert
isinstance
(
nodes
[
0
],
SyncNode
)
assert
isinstance
(
nodes
[
0
],
SyncNode
)
results
=
node
.
get_children_by_path
([[
f"
{
idx
}
:MyObject"
,
f"
{
idx
}
:MyVariable"
]])
assert
len
(
results
)
==
1
vars
=
results
[
0
]
assert
len
(
vars
)
==
1
assert
vars
[
0
].
read_value
()
==
6.7
def
test_sync_server_get_node
(
server
):
def
test_sync_server_get_node
(
server
,
idx
):
node
=
server
.
get_node
(
85
)
node
=
server
.
get_node
(
85
)
assert
node
==
server
.
nodes
.
objects
assert
node
==
server
.
nodes
.
objects
nodes
=
node
.
get_children
()
nodes
=
node
.
get_children
()
...
@@ -110,6 +116,12 @@ def test_sync_server_get_node(server):
...
@@ -110,6 +116,12 @@ def test_sync_server_get_node(server):
assert
nodes
[
0
]
==
server
.
nodes
.
server
assert
nodes
[
0
]
==
server
.
nodes
.
server
assert
isinstance
(
nodes
[
0
],
SyncNode
)
assert
isinstance
(
nodes
[
0
],
SyncNode
)
results
=
node
.
get_children_by_path
([[
f"
{
idx
}
:MyObject"
,
f"
{
idx
}
:MyVariable"
]])
assert
len
(
results
)
==
1
vars
=
results
[
0
]
assert
len
(
vars
)
==
1
assert
vars
[
0
].
read_value
()
==
6.7
class
MySubHandler
:
class
MySubHandler
:
...
...
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