massive refactoring to switch from camelCase to snake_case:
historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a pre-PEP8 code, to use the same coding style as in Twisted. However, snake_case is more readable and it's better to follow PEP8 best practices, so it has been decided to move on full snake_case. Because Libervia has a huge codebase, this ended with a ugly mix of camelCase and snake_case. To fix that, this patch does a big refactoring by renaming every function and method (including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case. This is a massive change, and may result in some bugs.
This commit is contained in:
parent
d50412c7f7
commit
6a6f15707a
1 changed files with 9945 additions and 9945 deletions
|
|
@ -75,7 +75,7 @@ class NatPort(object):
|
|||
def unload(self):
|
||||
if self._to_unmap:
|
||||
log.info("Cleaning mapped ports")
|
||||
return threads.deferToThread(self._unmapPortsBlocking)
|
||||
return threads.deferToThread(self._unmap_ports_blocking)
|
||||
|
||||
def _init_failed(self, failure_):
|
||||
e = failure_.trap(exceptions.NotFound, exceptions.FeatureNotFound)
|
||||
|
|
@ -98,23 +98,23 @@ class NatPort(object):
|
|||
except Exception:
|
||||
raise failure.Failure(exceptions.FeatureNotFound())
|
||||
|
||||
def getIP(self, local=False):
|
||||
def get_ip(self, local=False):
|
||||
"""Return IP address found with UPnP-IGD
|
||||
|
||||
@param local(bool): True to get external IP address, False to get local network one
|
||||
@return (None, str): found IP address, or None of something got wrong
|
||||
"""
|
||||
|
||||
def getIP(__):
|
||||
def get_ip(__):
|
||||
if self._upnp is None:
|
||||
return None
|
||||
# lanaddr can be the empty string if not found,
|
||||
# we need to return None in this case
|
||||
return (self._upnp.lanaddr or None) if local else self._external_ip
|
||||
|
||||
return self._initialised.addCallback(getIP)
|
||||
return self._initialised.addCallback(get_ip)
|
||||
|
||||
def _unmapPortsBlocking(self):
|
||||
def _unmap_ports_blocking(self):
|
||||
"""Unmap ports mapped in this session"""
|
||||
self._mutex.acquire()
|
||||
try:
|
||||
|
|
@ -137,7 +137,7 @@ class NatPort(object):
|
|||
finally:
|
||||
self._mutex.release()
|
||||
|
||||
def _mapPortBlocking(self, int_port, ext_port, protocol, desc):
|
||||
def _map_port_blocking(self, int_port, ext_port, protocol, desc):
|
||||
"""Internal blocking method to map port
|
||||
|
||||
@param int_port(int): internal port to use
|
||||
|
|
@ -186,7 +186,7 @@ class NatPort(object):
|
|||
|
||||
return ext_port
|
||||
|
||||
def mapPort(self, int_port, ext_port=None, protocol="TCP", desc=DEFAULT_DESC):
|
||||
def map_port(self, int_port, ext_port=None, protocol="TCP", desc=DEFAULT_DESC):
|
||||
"""Add a port mapping
|
||||
|
||||
@param int_port(int): internal port to use
|
||||
|
|
@ -199,7 +199,7 @@ class NatPort(object):
|
|||
if self._upnp is None:
|
||||
return defer.succeed(None)
|
||||
|
||||
def mappingCb(ext_port):
|
||||
def mapping_cb(ext_port):
|
||||
log.info(
|
||||
"{protocol} mapping from {int_port} to {ext_port} successful".format(
|
||||
protocol=protocol, int_port=int_port, ext_port=ext_port
|
||||
|
|
@ -207,16 +207,16 @@ class NatPort(object):
|
|||
)
|
||||
return ext_port
|
||||
|
||||
def mappingEb(failure_):
|
||||
def mapping_eb(failure_):
|
||||
failure_.trap(MappingError)
|
||||
log.warning("Can't map internal {int_port}".format(int_port=int_port))
|
||||
|
||||
def mappingUnknownEb(failure_):
|
||||
def mapping_unknown_eb(failure_):
|
||||
log.error(_("error while trying to map ports: {msg}").format(msg=failure_))
|
||||
|
||||
d = threads.deferToThread(
|
||||
self._mapPortBlocking, int_port, ext_port, protocol, desc
|
||||
self._map_port_blocking, int_port, ext_port, protocol, desc
|
||||
)
|
||||
d.addCallbacks(mappingCb, mappingEb)
|
||||
d.addErrback(mappingUnknownEb)
|
||||
d.addCallbacks(mapping_cb, mapping_eb)
|
||||
d.addErrback(mapping_unknown_eb)
|
||||
return d
|
||||
|
|
|
|||
Loading…
Reference in a new issue