Skip to content

Commit

Permalink
Fix some more typos.
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrix2000 authored and oroulet committed Jan 1, 2023
1 parent 888462e commit d5bacbc
Show file tree
Hide file tree
Showing 32 changed files with 105 additions and 106 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async with Client(url='opc.tcp://localhost:4840/freeopcua/server/') as client:
value = await node.read_value()
```

Of course you can also call the `connect`, `disconnect` methods yourself if you do not want to use the context manager.
Of course, you can also call the `connect`, `disconnect` methods yourself if you do not want to use the context manager.

See the example folder and the code for more information on the client API.

Expand Down
10 changes: 5 additions & 5 deletions asyncua/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ def set_password(self, pwd: str):

def set_locale(self, locale: List[str]) -> None:
"""
Sets the prefred locales of the client, the server chooses which locale he can provide.
Normaly the first matching locale in the list will be chossen, by the server.
Sets the preferred locales of the client, the server chooses which locale he can provide.
Normally the first matching locale in the list will be chosen, by the server.
Call this before connect()
"""
self._locale = locale
Expand Down Expand Up @@ -390,7 +390,7 @@ async def find_servers_on_network(self):
async def create_session(self):
"""
send a CreateSessionRequest to server with reasonable parameters.
If you want o modify settings look at code of this methods
If you want to modify settings look at code of these methods
and make your own
"""
self._closing = False
Expand Down Expand Up @@ -467,8 +467,8 @@ async def _monitor_server_loop(self):
async def _renew_channel_loop(self):
"""
Renew the SecureChannel before the SecureChannelTimeout will happen.
In theory we could do that only if no session activity
but it does not cost much..
In theory, we could do that only if no session activity,
but it does not cost much.
"""
try:
# Part4 5.5.2.1:
Expand Down
18 changes: 9 additions & 9 deletions asyncua/client/ua_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, timeout: float = 1, security_policy: ua.SecurityPolicy = ua.S
# needed to pass params from asynchronous request to synchronous data receive callback, as well as
# passing back the processed response to the request so that it can return it.
self._open_secure_channel_exchange: Union[ua.OpenSecureChannelResponse, ua.OpenSecureChannelParameters, None] = None
# Hook for upperlayer tasks before a request is send (optional)
# Hook for upper layer tasks before a request is sent (optional)
self.pre_request_hook: Optional[Callable[[], Awaitable[None]]] = None

def connection_made(self, transport: asyncio.Transport): # type: ignore
Expand Down Expand Up @@ -153,8 +153,8 @@ async def send_request(self, request, timeout: Optional[float] = None, message_t
"""
timeout = self.timeout if timeout is None else timeout
if self.pre_request_hook:
# This will propagade exceptions from background tasks to the libary user before calling a request which will
# timeout then.
# This will propagate exceptions from background tasks to the library user before calling a request which will
# time out then.
await self.pre_request_hook()
try:
data = await asyncio.wait_for(self._send_request(request, timeout, message_type), timeout if timeout else None)
Expand Down Expand Up @@ -230,7 +230,7 @@ async def open_secure_channel(self, params):
async def close_secure_channel(self):
"""
Close secure channel.
It seems to trigger a shutdown of socket in most servers, so be prepare to reconnect.
It seems to trigger a shutdown of socket in most servers, so be prepared to reconnect.
OPC UA specs Part 6, 7.1.4 say that Server does not send a CloseSecureChannel response
and should just close socket.
"""
Expand Down Expand Up @@ -310,7 +310,7 @@ async def open_secure_channel(self, params):
async def close_secure_channel(self):
"""
close secure channel. It seems to trigger a shutdown of socket
in most servers, so be prepare to reconnect
in most servers, so be prepared to reconnect
"""
if not self.protocol or self.protocol.state == UASocketProtocol.CLOSED:
self.logger.warning("close_secure_channel was called but connection is closed")
Expand Down Expand Up @@ -485,7 +485,7 @@ async def create_subscription(
response.Parameters.SubscriptionId
)
if not self._publish_task or self._publish_task.done():
# Start the publish loop if it is not yet running
# Start the publishing loop if it is not yet running
# The current strategy is to have only one open publish request per UaClient. This might not be enough
# in high latency networks or in case many subscriptions are created. A Set of Tasks of `_publish_loop`
# could be used if necessary.
Expand All @@ -494,7 +494,7 @@ async def create_subscription(

async def inform_subscriptions(self, status: ua.StatusCode):
"""
Inform all current subscriptions with a status code. This calls the handlers status_change_notification
Inform all current subscriptions with a status code. This calls the handler's status_change_notification
"""
status_message = ua.StatusChangeNotification(Status=status)
notification_message = ua.NotificationMessage(NotificationData=[status_message])
Expand Down Expand Up @@ -570,7 +570,7 @@ async def _publish_loop(self):
continue
except BadNoSubscription: # See Spec. Part 5, 13.8.1
# BadNoSubscription is expected to be received after deleting the last subscription.
# We use this as a signal to exit this task and stop sending PublishRequests. This is easier then
# We use this as a signal to exit this task and stop sending PublishRequests. This is easier than
# checking if there are no more subscriptions registered in this client (). A Publish response
# could still arrive before the DeleteSubscription response.
#
Expand Down Expand Up @@ -780,6 +780,6 @@ async def set_publishing_mode(self, params) -> ua.uatypes.StatusCode:
return response.Parameters.Results

async def transfer_subscriptions(self, params: ua.TransferSubscriptionsParameters) -> List[ua.TransferResult]:
# Subscriptions aren't bound to a Session and can be transfered!
# Subscriptions aren't bound to a Session and can be transferred!
# https://reference.opcfoundation.org/Core/Part4/v104/5.13.7/
raise NotImplementedError
2 changes: 1 addition & 1 deletion asyncua/client/ua_file_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async def write(self, data: bytes) -> None:
It is server-dependent whether the written data are persistently
stored if the session is ended without calling the Close Method with the fileHandle.
Writing an empty or null ByteString returns a Good result code without any
affect on the file.
effect on the file.
"""
_logger.debug("Request to write to file %s", self._file_node)
if self._write_node is None:
Expand Down
8 changes: 4 additions & 4 deletions asyncua/common/statemachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, id, name: str=None, number: int=None, node: Optional[Node]=No

class Transition:
'''
Helperclass for Transitions (TransitionVariableType)
Helper class for Transitions (TransitionVariableType)
https://reference.opcfoundation.org/v104/Core/docs/Part5/B.4.4/
name: type string will be converted automatically to qualifiedname
-> Name is a QualifiedName which uniquely identifies a transition within the StateMachineType.
Expand All @@ -57,7 +57,7 @@ class Transition:
transitiontime: TransitionTime specifies when the transition occurred.
effectivetransitiontime: EffectiveTransitionTime specifies the time when the current state or one of its substates was entered.
If, for example, a StateA is active and – while active – switches several times between its substates SubA and SubB,
then the TransitionTime stays at the point in time where StateA became active whereas the EffectiveTransitionTime changes
then the TransitionTime stays at the point in time when StateA became active whereas the EffectiveTransitionTime changes
with each change of a substate.
'''
def __init__(self, id, name: str=None, number: int=None, node: Node=None):
Expand Down Expand Up @@ -153,7 +153,7 @@ async def init(self, statemachine: Node):
elif dn.Text == "EffectiveDisplayName":
self._current_state_effective_display_name_node = await self._current_state_node.get_child(["EffectiveDisplayName"])
else:
_logger.warning(f"{await statemachine.read_browse_name()} CurrentState Unknown propertie: {dn.Text}")
_logger.warning(f"{await statemachine.read_browse_name()} CurrentState Unknown property: {dn.Text}")
if self._optionals:
self._last_transition_node = await statemachine.get_child(["LastTransition"])
last_transition_props = await self._last_transition_node.get_properties()
Expand All @@ -168,7 +168,7 @@ async def init(self, statemachine: Node):
elif dn.Text == "TransitionTime":
self._last_transition_transitiontime_node = await self._last_transition_node.get_child(["TransitionTime"])
else:
_logger.warning(f"{await statemachine.read_browse_name()} LastTransition Unknown propertie: {dn.Text}")
_logger.warning(f"{await statemachine.read_browse_name()} LastTransition Unknown property: {dn.Text}")
self._evgen = await self._server.get_event_generator(self.evtype, self._state_machine_node)

async def change_state(self, state: State, transition: Transition=None, event_msg:Union[str, ua.LocalizedText]=None, severity: int=500):
Expand Down
8 changes: 4 additions & 4 deletions asyncua/common/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ def set_typeid(self, name, typeid):
async def load_type_definitions(server, nodes=None):
"""
Download xml from given variable node defining custom structures.
If no node is given, attemps to import variables from all nodes under
If no node is given, attempts to import variables from all nodes under
"0:OPC Binary"
the code is generated and imported on the fly. If you know the structures
are not going to be modified it might be interresting to copy the generated files
are not going to be modified it might be interesting to copy the generated files
and include them in you code
"""
if nodes is None:
Expand All @@ -251,7 +251,7 @@ async def load_type_definitions(server, nodes=None):
generator.get_python_classes(structs_dict)
# same but using a file that is imported. This can be useful for debugging library
# name = node.read_browse_name().Name
# Make sure structure names do not contain charaters that cannot be used in Python class file names
# Make sure structure names do not contain characters that cannot be used in Python class file names
# name = clean_name(name)
# name = "structures_" + node.read_browse_name().Name
# generator.save_and_import(name + ".py", append_to=structs_dict)
Expand All @@ -268,7 +268,7 @@ async def load_type_definitions(server, nodes=None):
continue
nodeid = ref_desc_list[0].NodeId
ua.register_extension_object(name, nodeid, structs_dict[name])
# save the typeid if user want to create static file for type definitnion
# save the typeid if user want to create static file for type definition
generator.set_typeid(name, nodeid.to_string())

for key, val in structs_dict.items():
Expand Down
8 changes: 4 additions & 4 deletions asyncua/common/structures104.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async def new_enum(
def clean_name(name):
"""
Remove characters that might be present in OPC UA structures
but cannot be part of of Python class names
but cannot be part of Python class names
"""
if keyword.iskeyword(name):
return name + "_"
Expand Down Expand Up @@ -383,7 +383,7 @@ async def _recursive_parse_basedatatypes(server, base_node, parent_datatype, new
for desc in await base_node.get_children_descriptions(refs=ua.ObjectIds.HasSubtype):
name = clean_name(desc.BrowseName.Name)
if parent_datatype not in 'Number':
# Don't insert Number alias, they should be allready insert because they have to be basetypes allready
# Don't insert Number alias, they should be already insert because they have to be basetypes already
if not hasattr(ua, name):
env = make_basetype_code(name, parent_datatype)
ua.register_basetype(name, desc.NodeId, env[name])
Expand Down Expand Up @@ -421,7 +421,7 @@ async def _load_base_datatypes(server: Union["Server", "Client"]) -> Any:

async def load_data_type_definitions(server: Union["Server", "Client"], base_node: Node = None, overwrite_existing=False) -> Dict:
"""
Read DataTypeDefition attribute on all Structure and Enumeration defined
Read DataTypeDefinition attribute on all Structure and Enumeration defined
on server and generate Python objects in ua namespace to be used to talk with server
"""
new_objects = await _load_base_datatypes(server) # we need to load all basedatatypes alias first
Expand Down Expand Up @@ -510,7 +510,7 @@ async def load_enums(server: Union["Server", "Client"], base_node: Node = None,
name = clean_name(desc.BrowseName.Name)
if hasattr(ua, name):
continue
logger.info("Registring Enum %s %s OptionSet=%s", desc.NodeId, name, option_set)
logger.info("Registering Enum %s %s OptionSet=%s", desc.NodeId, name, option_set)
edef = await _read_data_type_definition(server, desc)
if not edef:
continue
Expand Down
18 changes: 9 additions & 9 deletions asyncua/common/ua_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Usefull method and classes not belonging anywhere and depending on asyncua library
Useful methods and classes not belonging anywhere and depending on asyncua library
"""

import uuid
Expand All @@ -16,7 +16,7 @@

def value_to_datavalue(val, varianttype=None):
"""
convert anyting to a DataValue using varianttype
convert anything to a DataValue using varianttype
"""
if isinstance(val, ua.DataValue):
return val
Expand All @@ -31,7 +31,7 @@ def val_to_string(val, truncate=False):
which should be easy to understand for human
easy to modify, and not too hard to parse back ....not easy
meant for UI or command lines
if truncate is true then huge strings or bytes are tuncated
if truncate is true then huge strings or bytes are truncated
"""
if isinstance(val, (list, tuple)):
Expand Down Expand Up @@ -172,7 +172,7 @@ async def get_node_subtypes(node, nodes=None):
async def get_node_supertypes(node, includeitself=False, skipbase=True):
"""
return get all subtype parents of node recursive
:param node: can be a ua.Node or ua.NodeId
:param node: can be an ua.Node or ua.NodeId
:param includeitself: include also node to the list
:param skipbase don't include the toplevel one
:returns list of ua.Node, top parent first
Expand Down Expand Up @@ -216,7 +216,7 @@ async def is_child_present(node, browsename):
return if a browsename is present a child from the provide node
:param node: node wherein to find the browsename
:param browsename: browsename to search
:returns returne True if the browsename is present else False
:returns returns True if the browsename is present else False
"""
child_descs = await node.get_children_descriptions()
for child_desc in child_descs:
Expand All @@ -232,7 +232,7 @@ async def data_type_to_variant_type(dtype_node):
"""
base = await get_base_data_type(dtype_node)
if base.nodeid.Identifier == 29:
# we have an enumeration, value is a Int32
# we have an enumeration, value is an Int32
return ua.VariantType.Int32
elif base.nodeid.Identifier in [24, 26, 27, 28]:
# BaseDataType, Number, Integer, UInteger -> Variant
Expand Down Expand Up @@ -277,10 +277,10 @@ async def get_nodes_of_namespace(server, namespaces=None):
elif isinstance(namespaces, (str, int)):
namespaces = [namespaces]

# make sure all namespace are indexes (if needed convert strings to indexes)
# make sure all namespace are indexes (if needed, convert strings to indexes)
namespace_indexes = [n if isinstance(n, int) else ns_available.index(n) for n in namespaces]

# filter nodeis based on the provide namespaces and convert the nodeid to a node
# filter node is based on the provided namespaces and convert the nodeid to a node
nodes = [
server.get_node(nodeid) for nodeid in server.iserver.aspace.keys()
if nodeid.NamespaceIndex != 0 and nodeid.NamespaceIndex in namespace_indexes
Expand All @@ -297,7 +297,7 @@ def get_default_value(uatype):


def data_type_to_string(dtype):
# we could just display browse name of node but it requires a query
# we could just display browse name of node, but it requires a query
if dtype.NamespaceIndex == 0 and dtype.Identifier in ua.ObjectIdNames:
string = ua.ObjectIdNames[dtype.Identifier]
else:
Expand Down
8 changes: 4 additions & 4 deletions asyncua/common/xmlexporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ async def add_etree_datatype(self, obj):
elif isinstance(sdef, ua.EnumDefinition):
self._enum_fields_to_etree(sdef_el, sdef)
else:
self.logger.warning("Unknown DataTypeSpecification elemnt: %s", sdef)
self.logger.warning("Unknown DataTypeSpecification element: %s", sdef)

def _structure_fields_to_etree(self, sdef_el, sdef):
for field in sdef.Fields:
Expand Down Expand Up @@ -447,7 +447,7 @@ async def _value_to_etree(self, el, type_name, dtype, val):
if isinstance(val, (list, tuple)):
if dtype.NamespaceIndex == 0 and dtype.Identifier <= 21:
elname = "uax:ListOf" + type_name
else: # this is an extentionObject:
else: # this is an extensionObject:
elname = "uax:ListOfExtensionObject"

list_el = Et.SubElement(el, elname)
Expand Down Expand Up @@ -489,9 +489,9 @@ async def _extobj_to_etree(self, val_el, name, dtype, val):

async def _all_fields_to_etree(self, struct_el, val):
# TODO: adding the 'ua' module to the globals to resolve the type hints might not be enough.
# its possible that the type annotations also refere to classes defined in other modules.
# it is possible that the type annotations also refere to classes defined in other modules.
for field in fields_with_resolved_types(val, globalns={"ua": ua}):
# FIXME; what happend if we have a custom type which is not part of ObjectIds???
# FIXME; what happened if we have a custom type which is not part of ObjectIds???
if field.name == "Encoding":
continue
type_name = type_string_from_type(field.type)
Expand Down
4 changes: 2 additions & 2 deletions asyncua/common/xmlimporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class XmlImporter:

def __init__(self, server, strict_mode=True):
'''
strict_mode: stop on a error, if False only a error message is logged,
strict_mode: stop on an error, if False only an error message is logged,
but the import continues
'''
self.parser = None
Expand Down Expand Up @@ -279,7 +279,7 @@ def make_objects(self, node_data):
def _migrate_ns(self, obj: Union[ua.NodeId, ua.QualifiedName]) -> Union[ua.NodeId, ua.QualifiedName]:
"""
Check if the index of nodeid or browsename given in the xml model file
must be converted to a already existing namespace id based on the files
must be converted to an already existing namespace id based on the files
namespace uri
:returns: NodeId (str)
Expand Down
4 changes: 2 additions & 2 deletions asyncua/common/xmlparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ def _parse_list_of_localized_text(self, el):

def _parse_list_of_extension_object(self, el):
"""
Parse a uax:ListOfExtensionObject Value
Return an list of ExtObj
Parse an uax:ListOfExtensionObject Value
Return a list of ExtObj
"""
value = []
for extension_object in el:
Expand Down
1 change: 0 additions & 1 deletion asyncua/crypto/permission_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,3 @@ def check_validity(self, user, action_type_id, body):
return True
else:
return False

Loading

0 comments on commit d5bacbc

Please sign in to comment.