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

@ -29,7 +29,7 @@ from twisted.internet import defer
from twisted.python.failure import Failure
from twisted.words.xish import domish
from twisted.words.protocols.jabber import jid
from sat.tools.xml_tools import paramsXML2XMLUI, getText
from sat.tools.xml_tools import params_xml_2_xmlui, get_text
from sat.tools.common import data_format
from xml.sax.saxutils import quoteattr
@ -38,7 +38,7 @@ from xml.sax.saxutils import quoteattr
# this need an overall simplification to make maintenance easier
def createJidElts(jids):
def create_jid_elts(jids):
"""Generator which return <jid/> elements from jids
@param jids(iterable[id.jID]): jids to use
@ -101,18 +101,18 @@ class Params(object):
def load_default_params(self):
self.dom = minidom.parseString(Params.default_xml.encode("utf-8"))
def _mergeParams(self, source_node, dest_node):
def _merge_params(self, source_node, dest_node):
"""Look for every node in source_node and recursively copy them to dest if they don't exists"""
def getNodesMap(children):
def get_nodes_map(children):
ret = {}
for child in children:
if child.nodeType == child.ELEMENT_NODE:
ret[(child.tagName, child.getAttribute("name"))] = child
return ret
source_map = getNodesMap(source_node.childNodes)
dest_map = getNodesMap(dest_node.childNodes)
source_map = get_nodes_map(source_node.childNodes)
dest_map = get_nodes_map(dest_node.childNodes)
source_set = set(source_map.keys())
dest_set = set(dest_map.keys())
to_add = source_set.difference(dest_set)
@ -122,22 +122,22 @@ class Params(object):
to_recurse = source_set - to_add
for node_key in to_recurse:
self._mergeParams(source_map[node_key], dest_map[node_key])
self._merge_params(source_map[node_key], dest_map[node_key])
def load_xml(self, xml_file):
"""Load parameters template from xml file"""
self.dom = minidom.parse(xml_file)
default_dom = minidom.parseString(Params.default_xml.encode("utf-8"))
self._mergeParams(default_dom.documentElement, self.dom.documentElement)
self._merge_params(default_dom.documentElement, self.dom.documentElement)
def loadGenParams(self):
def load_gen_params(self):
"""Load general parameters data from storage
@return: deferred triggered once params are loaded
"""
return self.storage.loadGenParams(self.params_gen)
return self.storage.load_gen_params(self.params_gen)
def loadIndParams(self, profile, cache=None):
def load_ind_params(self, profile, cache=None):
"""Load individual parameters
set self.params cache or a temporary cache
@ -147,11 +147,11 @@ class Params(object):
"""
if cache is None:
self.params[profile] = {}
return self.storage.loadIndParams(
return self.storage.load_ind_params(
self.params[profile] if cache is None else cache, profile
)
def purgeProfile(self, profile):
def purge_profile(self, profile):
"""Remove cache data of a profile
@param profile: %(doc_profile)s
@ -176,7 +176,7 @@ class Params(object):
self.params = {}
self.params_gen = {}
def createProfile(self, profile, component):
def create_profile(self, profile, component):
"""Create a new profile
@param profile(unicode): name of the profile
@ -184,14 +184,14 @@ class Params(object):
@param callback: called when the profile actually exists in database and memory
@return: a Deferred instance
"""
if self.storage.hasProfile(profile):
if self.storage.has_profile(profile):
log.info(_("The profile name already exists"))
return defer.fail(exceptions.ConflictError())
if not self.host.trigger.point("ProfileCreation", profile):
return defer.fail(exceptions.CancelError())
return self.storage.createProfile(profile, component or None)
return self.storage.create_profile(profile, component or None)
def asyncDeleteProfile(self, profile, force=False):
def profile_delete_async(self, profile, force=False):
"""Delete an existing profile
@param profile: name of the profile
@ -199,18 +199,18 @@ class Params(object):
To be used for direct calls only (not through the bridge).
@return: a Deferred instance
"""
if not self.storage.hasProfile(profile):
if not self.storage.has_profile(profile):
log.info(_("Trying to delete an unknown profile"))
return defer.fail(Failure(exceptions.ProfileUnknownError(profile)))
if self.host.isConnected(profile):
if self.host.is_connected(profile):
if force:
self.host.disconnect(profile)
else:
log.info(_("Trying to delete a connected profile"))
return defer.fail(Failure(exceptions.ProfileConnected))
return self.storage.deleteProfile(profile)
return self.storage.delete_profile(profile)
def getProfileName(self, profile_key, return_profile_keys=False):
def get_profile_name(self, profile_key, return_profile_keys=False):
"""return profile according to profile_key
@param profile_key: profile name or key which can be
@ -229,7 +229,7 @@ class Params(object):
try:
default = self.host.memory.memory_data[
"Profile_default"
] = self.storage.getProfilesList()[0]
] = self.storage.get_profiles_list()[0]
except IndexError:
log.info(_("No profile exist yet"))
raise exceptions.ProfileUnknownError(profile_key)
@ -240,7 +240,7 @@ class Params(object):
raise exceptions.ProfileNotSetError
elif return_profile_keys and profile_key in [C.PROF_KEY_ALL]:
return profile_key # this value must be managed by the caller
if not self.storage.hasProfile(profile_key):
if not self.storage.has_profile(profile_key):
log.error(_("Trying to access an unknown profile (%s)") % profile_key)
raise exceptions.ProfileUnknownError(profile_key)
return profile_key
@ -260,7 +260,7 @@ class Params(object):
# the node is new
return None
def updateParams(self, xml, security_limit=C.NO_SECURITY_LIMIT, app=""):
def update_params(self, xml, security_limit=C.NO_SECURITY_LIMIT, app=""):
"""import xml in parameters, update if the param already exists
If security_limit is specified and greater than -1, the parameters
@ -287,7 +287,7 @@ class Params(object):
0
) # count the params to be removed from current category
for node in cat_node.childNodes:
if node.nodeName != "param" or not self.checkSecurityLimit(
if node.nodeName != "param" or not self.check_security_limit(
node, security_limit
):
to_remove.append(node)
@ -324,7 +324,7 @@ class Params(object):
pre_process_app_node(src_parent, security_limit, app)
import_node(self.dom.documentElement, src_parent)
def paramsRegisterApp(self, xml, security_limit, app):
def params_register_app(self, xml, security_limit, app):
"""Register frontend's specific parameters
If security_limit is specified and greater than -1, the parameters
@ -351,12 +351,12 @@ class Params(object):
)
return
self.frontends_cache.append(app)
self.updateParams(xml, security_limit, app)
self.update_params(xml, security_limit, app)
log.debug("Frontends parameters registered for %(app)s" % {"app": app})
def __default_ok(self, value, name, category):
# FIXME: will not work with individual parameters
self.setParam(name, value, category)
self.param_set(name, value, category)
def __default_ko(self, failure, name, category):
log.error(
@ -364,7 +364,7 @@ class Params(object):
% {"category": category, "name": name, "reason": str(failure.value)}
)
def setDefault(self, name, category, callback, errback=None):
def set_default(self, name, category, callback, errback=None):
"""Set default value of parameter
'default_cb' attibute of parameter must be set to 'yes'
@ -376,10 +376,10 @@ class Params(object):
# TODO: send signal param update if value changed
# TODO: manage individual paramaters
log.debug(
"setDefault called for %(category)s/%(name)s"
"set_default called for %(category)s/%(name)s"
% {"category": category, "name": name}
)
node = self._getParamNode(name, category, "@ALL@")
node = self._get_param_node(name, category, "@ALL@")
if not node:
log.error(
_(
@ -390,15 +390,15 @@ class Params(object):
return
if node[1].getAttribute("default_cb") == "yes":
# del node[1].attributes['default_cb'] # default_cb is not used anymore as a flag to know if we have to set the default value,
# and we can still use it later e.g. to call a generic setDefault method
value = self._getParam(category, name, C.GENERAL)
# and we can still use it later e.g. to call a generic set_default method
value = self._get_param(category, name, C.GENERAL)
if value is None: # no value set by the user: we have the default value
log.debug("Default value to set, using callback")
d = defer.maybeDeferred(callback)
d.addCallback(self.__default_ok, name, category)
d.addErrback(errback or self.__default_ko, name, category)
def _getAttr_internal(self, node, attr, value):
def _get_attr_internal(self, node, attr, value):
"""Get attribute value.
/!\ This method would return encrypted password values.
@ -464,7 +464,7 @@ class Params(object):
"\t"
) # FIXME: it's not good to use tabs as separator !
else: # no user defined value, take default value from the XML
jids = [getText(jid_) for jid_ in node.getElementsByTagName("jid")]
jids = [get_text(jid_) for jid_ in node.getElementsByTagName("jid")]
to_delete = []
for idx, value in enumerate(jids):
try:
@ -480,7 +480,7 @@ class Params(object):
return value_to_use
return node.getAttribute(attr)
def _getAttr(self, node, attr, value):
def _get_attr(self, node, attr, value):
"""Get attribute value (synchronous).
/!\ This method can not be used to retrieve password values.
@ -491,11 +491,11 @@ class Params(object):
"""
if attr == "value" and node.getAttribute("type") == "password":
raise exceptions.InternalError(
"To retrieve password values, use _asyncGetAttr instead of _getAttr"
"To retrieve password values, use _async_get_attr instead of _get_attr"
)
return self._getAttr_internal(node, attr, value)
return self._get_attr_internal(node, attr, value)
def _asyncGetAttr(self, node, attr, value, profile=None):
def _async_get_attr(self, node, attr, value, profile=None):
"""Get attribute value.
Profile passwords are returned hashed (if not empty),
@ -506,7 +506,7 @@ class Params(object):
@param profile: %(doc_profile)s
@return (unicode, bool, int, list): Deferred value to retrieve
"""
value = self._getAttr_internal(node, attr, value)
value = self._get_attr_internal(node, attr, value)
if attr != "value" or node.getAttribute("type") != "password":
return defer.succeed(value)
param_cat = node.parentNode.getAttribute("name")
@ -519,7 +519,7 @@ class Params(object):
raise exceptions.ProfileNotSetError(
"The profile is needed to decrypt a password"
)
password = self.host.memory.decryptValue(value, profile)
password = self.host.memory.decrypt_value(value, profile)
if password is None:
raise exceptions.InternalError("password should never be None")
@ -528,25 +528,25 @@ class Params(object):
def _type_to_str(self, result):
"""Convert result to string, according to its type """
if isinstance(result, bool):
return C.boolConst(result)
return C.bool_const(result)
elif isinstance(result, (list, set, tuple)):
return ', '.join(self._type_to_str(r) for r in result)
else:
return str(result)
def getStringParamA(self, name, category, attr="value", profile_key=C.PROF_KEY_NONE):
""" Same as getParamA but for bridge: convert non string value to string """
def get_string_param_a(self, name, category, attr="value", profile_key=C.PROF_KEY_NONE):
""" Same as param_get_a but for bridge: convert non string value to string """
return self._type_to_str(
self.getParamA(name, category, attr, profile_key=profile_key)
self.param_get_a(name, category, attr, profile_key=profile_key)
)
def getParamA(
def param_get_a(
self, name, category, attr="value", use_default=True, profile_key=C.PROF_KEY_NONE
):
"""Helper method to get a specific attribute.
/!\ This method would return encrypted password values,
to get the plain values you have to use asyncGetParamA.
to get the plain values you have to use param_get_a_async.
@param name: name of the parameter
@param category: category of the parameter
@param attr: name of the attribute (default: "value")
@ -557,7 +557,7 @@ class Params(object):
"""
# FIXME: looks really dirty and buggy, need to be reviewed/refactored
# FIXME: security_limit is not managed here !
node = self._getParamNode(name, category)
node = self._get_param_node(name, category)
if not node:
log.error(
_(
@ -569,18 +569,18 @@ class Params(object):
if attr == "value" and node[1].getAttribute("type") == "password":
raise exceptions.InternalError(
"To retrieve password values, use asyncGetParamA instead of getParamA"
"To retrieve password values, use param_get_a_async instead of param_get_a"
)
if node[0] == C.GENERAL:
value = self._getParam(category, name, C.GENERAL)
value = self._get_param(category, name, C.GENERAL)
if value is None and attr == "value" and not use_default:
return value
return self._getAttr(node[1], attr, value)
return self._get_attr(node[1], attr, value)
assert node[0] == C.INDIVIDUAL
profile = self.getProfileName(profile_key)
profile = self.get_profile_name(profile_key)
if not profile:
log.error(_("Requesting a param for an non-existant profile"))
raise exceptions.ProfileUnknownError(profile_key)
@ -590,19 +590,19 @@ class Params(object):
raise exceptions.ProfileNotConnected(profile)
if attr == "value":
value = self._getParam(category, name, profile=profile)
value = self._get_param(category, name, profile=profile)
if value is None and attr == "value" and not use_default:
return value
return self._getAttr(node[1], attr, value)
return self._get_attr(node[1], attr, value)
async def asyncGetStringParamA(
async def async_get_string_param_a(
self, name, category, attr="value", security_limit=C.NO_SECURITY_LIMIT,
profile=C.PROF_KEY_NONE):
value = await self.asyncGetParamA(
value = await self.param_get_a_async(
name, category, attr, security_limit, profile_key=profile)
return self._type_to_str(value)
def asyncGetParamA(
def param_get_a_async(
self,
name,
category,
@ -618,7 +618,7 @@ class Params(object):
@param profile: owner of the param (@ALL@ for everyone)
@return (defer.Deferred): parameter value, with corresponding type (bool, int, list, etc)
"""
node = self._getParamNode(name, category)
node = self._get_param_node(name, category)
if not node:
log.error(
_(
@ -628,7 +628,7 @@ class Params(object):
)
raise ValueError("Requested param doesn't exist")
if not self.checkSecurityLimit(node[1], security_limit):
if not self.check_security_limit(node[1], security_limit):
log.warning(
_(
"Trying to get parameter '%(param)s' in category '%(cat)s' without authorization!!!"
@ -638,12 +638,12 @@ class Params(object):
raise exceptions.PermissionError
if node[0] == C.GENERAL:
value = self._getParam(category, name, C.GENERAL)
return self._asyncGetAttr(node[1], attr, value)
value = self._get_param(category, name, C.GENERAL)
return self._async_get_attr(node[1], attr, value)
assert node[0] == C.INDIVIDUAL
profile = self.getProfileName(profile_key)
profile = self.get_profile_name(profile_key)
if not profile:
raise exceptions.InternalError(
_("Requesting a param for a non-existant profile")
@ -652,23 +652,23 @@ class Params(object):
if attr != "value":
return defer.succeed(node[1].getAttribute(attr))
try:
value = self._getParam(category, name, profile=profile)
return self._asyncGetAttr(node[1], attr, value, profile)
value = self._get_param(category, name, profile=profile)
return self._async_get_attr(node[1], attr, value, profile)
except exceptions.ProfileNotInCacheError:
# We have to ask data to the storage manager
d = self.storage.getIndParam(category, name, profile)
d = self.storage.get_ind_param(category, name, profile)
return d.addCallback(
lambda value: self._asyncGetAttr(node[1], attr, value, profile)
lambda value: self._async_get_attr(node[1], attr, value, profile)
)
def _getParamsValuesFromCategory(
def _get_params_values_from_category(
self, category, security_limit, app, extra_s, profile_key):
client = self.host.getClient(profile_key)
client = self.host.get_client(profile_key)
extra = data_format.deserialise(extra_s)
return defer.ensureDeferred(self.getParamsValuesFromCategory(
return defer.ensureDeferred(self.get_params_values_from_category(
client, category, security_limit, app, extra))
async def getParamsValuesFromCategory(
async def get_params_values_from_category(
self, client, category, security_limit, app='', extra=None):
"""Get all parameters "attribute" for a category
@ -676,14 +676,14 @@ class Params(object):
@param security_limit(int): NO_SECURITY_LIMIT (-1) to return all the params.
Otherwise sole the params which have a security level defined *and*
lower or equal to the specified value are returned.
@param app(str): see [getParams]
@param extra(dict): see [getParams]
@param app(str): see [get_params]
@param extra(dict): see [get_params]
@return (dict): key: param name, value: param value (converted to string if needed)
"""
# TODO: manage category of general type (without existant profile)
if extra is None:
extra = {}
prof_xml = await self._constructProfileXml(client, security_limit, app, extra)
prof_xml = await self._construct_profile_xml(client, security_limit, app, extra)
ret = {}
for category_node in prof_xml.getElementsByTagName("category"):
if category_node.getAttribute("name") == category:
@ -696,7 +696,7 @@ class Params(object):
)
)
continue
value = await self.asyncGetStringParamA(
value = await self.async_get_string_param_a(
name, category, security_limit=security_limit,
profile=client.profile)
@ -706,7 +706,7 @@ class Params(object):
prof_xml.unlink()
return ret
def _getParam(
def _get_param(
self, category, name, type_=C.INDIVIDUAL, cache=None, profile=C.PROF_KEY_NONE
):
"""Return the param, or None if it doesn't exist
@ -736,7 +736,7 @@ class Params(object):
return None
return cache[(category, name)]
async def _constructProfileXml(self, client, security_limit, app, extra):
async def _construct_profile_xml(self, client, security_limit, app, extra):
"""Construct xml for asked profile, filling values when needed
/!\ as noticed in doc, don't forget to unlink the minidom.Document
@ -749,18 +749,18 @@ class Params(object):
"""
profile = client.profile
def checkNode(node):
def check_node(node):
"""Check the node against security_limit, app and extra"""
return (self.checkSecurityLimit(node, security_limit)
and self.checkApp(node, app)
and self.checkExtra(node, extra))
return (self.check_security_limit(node, security_limit)
and self.check_app(node, app)
and self.check_extra(node, extra))
if profile in self.params:
profile_cache = self.params[profile]
else:
# profile is not in cache, we load values in a short time cache
profile_cache = {}
await self.loadIndParams(profile, profile_cache)
await self.load_ind_params(profile, profile_cache)
# init the result document
prof_xml = minidom.parseString("<params/>")
@ -782,7 +782,7 @@ class Params(object):
for node in dest_cat.childNodes:
if node.nodeName != "param":
continue
if not checkNode(node):
if not check_node(node):
to_remove.append(node)
continue
dest_params[node.getAttribute("name")] = node
@ -799,14 +799,14 @@ class Params(object):
# we have to merge new params (we are parsing individual parameters, we have to add them
# to the previously parsed general ones)
name = param_node.getAttribute("name")
if not checkNode(param_node):
if not check_node(param_node):
continue
if name not in dest_params:
# this is reached when a previous category exists
dest_params[name] = param_node.cloneNode(True)
dest_cat.appendChild(dest_params[name])
profile_value = self._getParam(
profile_value = self._get_param(
category,
name,
type_node.nodeName,
@ -867,12 +867,12 @@ class Params(object):
return prof_xml
def _getParamsUI(self, security_limit, app, extra_s, profile_key):
client = self.host.getClient(profile_key)
def _get_params_ui(self, security_limit, app, extra_s, profile_key):
client = self.host.get_client(profile_key)
extra = data_format.deserialise(extra_s)
return defer.ensureDeferred(self.getParamsUI(client, security_limit, app, extra))
return defer.ensureDeferred(self.param_ui_get(client, security_limit, app, extra))
async def getParamsUI(self, client, security_limit, app, extra=None):
async def param_ui_get(self, client, security_limit, app, extra=None):
"""Get XMLUI to handle parameters
@param security_limit: NO_SECURITY_LIMIT (-1) to return all the params.
@ -883,10 +883,10 @@ class Params(object):
- ignore: list of (category/name) values to remove from parameters
@return(str): a SàT XMLUI for parameters
"""
param_xml = await self.getParams(client, security_limit, app, extra)
return paramsXML2XMLUI(param_xml)
param_xml = await self.get_params(client, security_limit, app, extra)
return params_xml_2_xmlui(param_xml)
async def getParams(self, client, security_limit, app, extra=None):
async def get_params(self, client, security_limit, app, extra=None):
"""Construct xml for asked profile, take params xml as skeleton
@param security_limit: NO_SECURITY_LIMIT (-1) to return all the params.
@ -900,12 +900,12 @@ class Params(object):
"""
if extra is None:
extra = {}
prof_xml = await self._constructProfileXml(client, security_limit, app, extra)
prof_xml = await self._construct_profile_xml(client, security_limit, app, extra)
return_xml = prof_xml.toxml()
prof_xml.unlink()
return "\n".join((line for line in return_xml.split("\n") if line))
def _getParamNode(self, name, category, type_="@ALL@"): # FIXME: is type_ useful ?
def _get_param_node(self, name, category, type_="@ALL@"): # FIXME: is type_ useful ?
"""Return a node from the param_xml
@param name: name of the node
@param category: category of the node
@ -931,7 +931,7 @@ class Params(object):
return (type_node.nodeName, param)
return None
def getParamsCategories(self):
def params_categories_get(self):
"""return the categories availables"""
categories = []
for cat in self.dom.getElementsByTagName("category"):
@ -940,7 +940,7 @@ class Params(object):
categories.append(cat.getAttribute("name"))
return categories
def setParam(self, name, value, category, security_limit=C.NO_SECURITY_LIMIT,
def param_set(self, name, value, category, security_limit=C.NO_SECURITY_LIMIT,
profile_key=C.PROF_KEY_NONE):
"""Set a parameter, return None if the parameter is not in param xml.
@ -955,14 +955,14 @@ class Params(object):
@param profile_key (str): %(doc_profile_key)s
@return: a deferred None value when everything is done
"""
# FIXME: setParam should accept the right type for value, not only str !
# FIXME: param_set should accept the right type for value, not only str !
if profile_key != C.PROF_KEY_NONE:
profile = self.getProfileName(profile_key)
profile = self.get_profile_name(profile_key)
if not profile:
log.error(_("Trying to set parameter for an unknown profile"))
raise exceptions.ProfileUnknownError(profile_key)
node = self._getParamNode(name, category, "@ALL@")
node = self._get_param_node(name, category, "@ALL@")
if not node:
log.error(
_("Requesting an unknown parameter (%(category)s/%(name)s)")
@ -970,7 +970,7 @@ class Params(object):
)
return defer.succeed(None)
if not self.checkSecurityLimit(node[1], security_limit):
if not self.check_security_limit(node[1], security_limit):
msg = _(
"{profile!r} is trying to set parameter {name!r} in category "
"{category!r} without authorization!!!").format(
@ -1018,12 +1018,12 @@ class Params(object):
if node[0] == C.GENERAL:
self.params_gen[(category, name)] = value
self.storage.setGenParam(category, name, value)
for profile in self.storage.getProfilesList():
if self.host.memory.isSessionStarted(profile):
self.host.bridge.paramUpdate(name, value, category, profile)
self.storage.set_gen_param(category, name, value)
for profile in self.storage.get_profiles_list():
if self.host.memory.is_session_started(profile):
self.host.bridge.param_update(name, value, category, profile)
self.host.trigger.point(
"paramUpdateTrigger", name, value, category, node[0], profile
"param_update_trigger", name, value, category, node[0], profile
)
return defer.succeed(None)
@ -1035,7 +1035,7 @@ class Params(object):
return defer.succeed(None)
elif type_ == "password":
try:
personal_key = self.host.memory.auth_sessions.profileGetUnique(profile)[
personal_key = self.host.memory.auth_sessions.profile_get_unique(profile)[
C.MEMORY_CRYPTO_KEY
]
except TypeError:
@ -1044,7 +1044,7 @@ class Params(object):
)
if (category, name) == C.PROFILE_PASS_PATH:
# using 'value' as the encryption key to encrypt another encryption key... could be confusing!
d = self.host.memory.encryptPersonalData(
d = self.host.memory.encrypt_personal_data(
data_key=C.MEMORY_CRYPTO_KEY,
data_value=personal_key,
crypto_key=value,
@ -1060,21 +1060,21 @@ class Params(object):
else:
d = defer.succeed(value)
def gotFinalValue(value):
if self.host.memory.isSessionStarted(profile):
def got_final_value(value):
if self.host.memory.is_session_started(profile):
self.params[profile][(category, name)] = value
self.host.bridge.paramUpdate(name, value, category, profile)
self.host.bridge.param_update(name, value, category, profile)
self.host.trigger.point(
"paramUpdateTrigger", name, value, category, node[0], profile
"param_update_trigger", name, value, category, node[0], profile
)
return self.storage.setIndParam(category, name, value, profile)
return self.storage.set_ind_param(category, name, value, profile)
else:
raise exceptions.ProfileNotConnected
d.addCallback(gotFinalValue)
d.addCallback(got_final_value)
return d
def _getNodesOfTypes(self, attr_type, node_type="@ALL@"):
def _get_nodes_of_types(self, attr_type, node_type="@ALL@"):
"""Return all the nodes matching the given types.
TODO: using during the dev but not anymore... remove if not needed
@ -1105,7 +1105,7 @@ class Params(object):
ret[(cat, param.getAttribute("name"))] = param
return ret
def checkSecurityLimit(self, node, security_limit):
def check_security_limit(self, node, security_limit):
"""Check the given node against the given security limit.
The value NO_SECURITY_LIMIT (-1) means that everything is allowed.
@return: True if this node can be accessed with the given security limit.
@ -1117,7 +1117,7 @@ class Params(object):
return True
return False
def checkApp(self, node, app):
def check_app(self, node, app):
"""Check the given node against the given app.
@param node: parameter node
@ -1128,7 +1128,7 @@ class Params(object):
return True
return node.getAttribute("app") == app
def checkExtra(self, node, extra):
def check_extra(self, node, extra):
"""Check the given node against the extra filters.
@param node: parameter node
@ -1147,7 +1147,7 @@ class Params(object):
return True
def makeOptions(options, selected=None):
def make_options(options, selected=None):
"""Create option XML form dictionary
@param options(dict): option's name => option's label map