Skip to content

Commit

Permalink
Fixed some field accesses & type hints according to Scott's changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tcalmant committed Jun 22, 2018
1 parent b0ee7a8 commit 03fb65f
Showing 1 changed file with 23 additions and 26 deletions.
49 changes: 23 additions & 26 deletions pelix/rsa/remoteserviceadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,6 @@ def update(self, props):
# type: (Dict[str, Any]) -> EndpointDescription
with self.__lock:
srprops = self.get_reference().get_properties().copy()

# FIXME: unknown field __orig_props
rsprops = self.__orig_props.copy()
updateprops = (
rsprops if props is None else props.update(rsprops).copy()
Expand Down Expand Up @@ -730,45 +728,45 @@ def __init__(self, endpoint=None, exception=None, errored=None):
)
self.__exception = exception
self.__errored = errored
self.__endpoint = None
self._endpoint = None
else:
self.__endpoint = endpoint
self._endpoint = endpoint
self.__exception = self.__errored = None

def get_export_container_id(self):
# type: () -> Optional[Tuple[str, str]]
with self.__lock:
return (
None
if self.__endpoint is None
else self.__endpoint.get_export_container_id()
if self._endpoint is None
else self._endpoint.get_export_container_id()
)

def get_remoteservice_id(self):
# type: () -> Optional[Tuple[str, str]]
with self.__lock:
return (
None
if self.__endpoint is None
else self.__endpoint.get_remoteservice_id()
if self._endpoint is None
else self._endpoint.get_remoteservice_id()
)

def get_reference(self):
# type: () -> Optional[ServiceReference]
with self.__lock:
return (
None
if self.__endpoint is None
else self.__endpoint.get_reference()
if self._endpoint is None
else self._endpoint.get_reference()
)

def get_description(self):
# type: () -> Optional[EndpointDescription]
with self.__lock:
return (
self.__errored
if self.__endpoint is None
else self.__endpoint.get_description()
if self._endpoint is None
else self._endpoint.get_description()
)

def get_exception(self):
Expand All @@ -781,18 +779,18 @@ def update(self, properties):
with self.__lock:
return (
None
if self.__endpoint is None
else self.__endpoint.update(properties)
if self._endpoint is None
else self._endpoint.update(properties)
)

def close(self, export_reg):
# type: (ExportRegistration) -> bool
with self.__lock:
if self.__endpoint is None:
if self._endpoint is None:
return False
else:
result = self.__endpoint.close(export_reg)
self.__endpoint = None
result = self._endpoint.close(export_reg)
self._endpoint = None
return bool(result)


Expand All @@ -806,8 +804,8 @@ class ExportRegistrationImpl(ExportRegistration):
"""
@classmethod
def fromreg(cls, export_reg):
# type: (ExportRegistration) -> ExportRegistration
return cls(export_reg.__rsa,export_reg.__export_ref.__endpoint)
# type: (ExportRegistrationImpl) -> ExportRegistrationImpl
return cls(export_reg.__rsa, export_reg.__exportref._endpoint)

@classmethod
def fromendpoint(cls, rsa, exporter, ed, svc_ref):
Expand All @@ -828,12 +826,12 @@ def __init__(self, rsa=None, endpoint=None, exception=None, errored=None):
)
self.__exportref = ExportReferenceImpl.fromexception(
exception, errored
)
) # type: ExportReferenceImpl
self.__rsa = None
else:
self.__rsa = endpoint._rsa()
endpoint._add_export_registration(self)
self.__exportref = ExportReferenceImpl.fromendpoint(endpoint)
self.__exportref = ExportReferenceImpl.fromendpoint(endpoint) # type: ExportReferenceImpl
self.__closed = False
self.__updateexception = None
self.__lock = threading.RLock()
Expand Down Expand Up @@ -873,13 +871,12 @@ def get_export_reference(self):
return None if self.__closed else self.__exportref

def _exportendpoint(self, svc_ref, cid):
# type: (ServiceReference, Tuple[str, str]) -> Optional
# FIXME: find result type
# type: (ServiceReference, Tuple[str, str]) -> Optional[_ExportEndpoint]
with self.__lock:
return (
None
if self.__closed
else self.__exportref.__endpoint
else self.__exportref._endpoint
if self.match_sr(svc_ref, cid)
else None
)
Expand Down Expand Up @@ -1027,7 +1024,7 @@ def get_import_container_id(self):
return None if self.__importer is None else self.__importer.get_id()

def get_export_container_id(self):
# FIXME: call to an unknown method
# type: () -> Tuple[str, str]
with self.__lock:
return self.__ed.get_container_id()

Expand All @@ -1042,7 +1039,7 @@ def update(self, ed):
return None

new_props = self.__importer._prepare_proxy_props(ed)
ed.update(new_props.get_properties())
ed.update(new_props)
self.__ed = ed
self.__svc_reg.set_properties(self.__ed.get_properties())

Expand Down

0 comments on commit 03fb65f

Please sign in to comment.