Mercurial > libervia-backend
comparison sat_frontends/jp/xml_tools.py @ 4037:524856bd7b19
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.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 08 Apr 2023 13:54:42 +0200 |
parents | be6d91572633 |
children | 4b842c1fb686 |
comparison
equal
deleted
inserted
replaced
4036:c4464d7ae97b | 4037:524856bd7b19 |
---|---|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 from sat.core.i18n import _ | 20 from sat.core.i18n import _ |
21 from sat_frontends.jp.constants import Const as C | 21 from sat_frontends.jp.constants import Const as C |
22 | 22 |
23 def etreeParse(cmd, raw_xml, reraise=False): | 23 def etree_parse(cmd, raw_xml, reraise=False): |
24 """Import lxml and parse raw XML | 24 """import lxml and parse raw XML |
25 | 25 |
26 @param cmd(CommandBase): current command instance | 26 @param cmd(CommandBase): current command instance |
27 @param raw_xml(file, str): an XML bytestring, string or file-like object | 27 @param raw_xml(file, str): an XML bytestring, string or file-like object |
28 @param reraise(bool): if True, re raise exception on parse error instead of doing a | 28 @param reraise(bool): if True, re raise exception on parse error instead of doing a |
29 parser.error (which terminate the execution) | 29 parser.error (which terminate the execution) |
49 cmd.parser.error( | 49 cmd.parser.error( |
50 _("Can't parse the payload XML in input: {msg}").format(msg=e) | 50 _("Can't parse the payload XML in input: {msg}").format(msg=e) |
51 ) | 51 ) |
52 return element, etree | 52 return element, etree |
53 | 53 |
54 def getPayload(cmd, element): | 54 def get_payload(cmd, element): |
55 """Retrieve payload element and exit with and error if not found | 55 """Retrieve payload element and exit with and error if not found |
56 | 56 |
57 @param element(etree.Element): root element | 57 @param element(etree.Element): root element |
58 @return element(etree.Element): payload element | 58 @return element(etree.Element): payload element |
59 """ | 59 """ |