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:
Goffi 2023-04-08 13:54:42 +02:00
commit 6a6f15707a

View file

@ -84,31 +84,31 @@ class AppManager:
self._started = {}
# instance id to app data map
self._instances = {}
host.bridge.addMethod(
"applicationsList",
host.bridge.add_method(
"applications_list",
".plugin",
in_sign="as",
out_sign="as",
method=self.list_applications,
)
host.bridge.addMethod(
"applicationStart",
host.bridge.add_method(
"application_start",
".plugin",
in_sign="ss",
out_sign="s",
method=self._start,
async_=True,
)
host.bridge.addMethod(
"applicationStop",
host.bridge.add_method(
"application_stop",
".plugin",
in_sign="sss",
out_sign="",
method=self._stop,
async_=True,
)
host.bridge.addMethod(
"applicationExposedGet",
host.bridge.add_method(
"application_exposed_get",
".plugin",
in_sign="sss",
out_sign="s",
@ -117,12 +117,12 @@ class AppManager:
)
# application has been started succeesfully,
# args: name, instance_id, extra
host.bridge.addSignal(
host.bridge.add_signal(
"application_started", ".plugin", signature="sss"
)
# application went wrong with the application
# args: name, instance_id, extra
host.bridge.addSignal(
host.bridge.add_signal(
"application_error", ".plugin", signature="sss"
)
yaml.add_constructor(
@ -169,7 +169,7 @@ class AppManager:
"expected"
)
value = self.host.memory.getConfig(section, name, default)
value = self.host.memory.config_get(section, name, default)
# FIXME: "public_url" is used only here and doesn't take multi-sites into account
if name == "public_url" and (not value or value.startswith('http')):
if not value:
@ -408,7 +408,7 @@ class AppManager:
log.info(f"{app_name!r} is already started or being started")
return ret_data
else:
cache_path = self.host.memory.getCachePath(
cache_path = self.host.memory.get_cache_path(
PLUGIN_INFO[C.PI_IMPORT_NAME], app_name
)
cache_path.mkdir(0o700, parents=True, exist_ok=True)