Mercurial > libervia-backend
diff sat/bridge/bridge_constructor/constructors/mediawiki/constructor.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 | 7550ae9cfbac |
children |
line wrap: on
line diff
--- a/sat/bridge/bridge_constructor/constructors/mediawiki/constructor.py Fri Apr 07 15:18:39 2023 +0200 +++ b/sat/bridge/bridge_constructor/constructors/mediawiki/constructor.py Sat Apr 08 13:54:42 2023 +0200 @@ -29,7 +29,7 @@ self.core_template = "mediawiki_template.tpl" self.core_dest = "mediawiki.wiki" - def _addTextDecorations(self, text): + def _add_text_decorations(self, text): """Add text decorations like coloration or shortcuts""" def anchor_link(match): @@ -42,43 +42,43 @@ return re.sub(r"\[(\w+)\]", anchor_link, text) - def _wikiParameter(self, name, sig_in): + def _wiki_parameter(self, name, sig_in): """Format parameters with the wiki syntax @param name: name of the function @param sig_in: signature in @return: string of the formated parameters""" - arg_doc = self.getArgumentsDoc(name) - arg_default = self.getDefault(name) - args_str = self.getArguments(sig_in) + arg_doc = self.get_arguments_doc(name) + arg_default = self.get_default(name) + args_str = self.get_arguments(sig_in) args = args_str.split(", ") if args_str else [] # ugly but it works :) wiki = [] for i in range(len(args)): if i in arg_doc: name, doc = arg_doc[i] doc = "\n:".join(doc.rstrip("\n").split("\n")) - wiki.append("; %s: %s" % (name, self._addTextDecorations(doc))) + wiki.append("; %s: %s" % (name, self._add_text_decorations(doc))) else: wiki.append("; arg_%d: " % i) if i in arg_default: wiki.append(":''DEFAULT: %s''" % arg_default[i]) return "\n".join(wiki) - def _wikiReturn(self, name): + def _wiki_return(self, name): """Format return doc with the wiki syntax @param name: name of the function """ - arg_doc = self.getArgumentsDoc(name) + arg_doc = self.get_arguments_doc(name) wiki = [] if "return" in arg_doc: wiki.append("\n|-\n! scope=row | return value\n|") wiki.append( "<br />\n".join( - self._addTextDecorations(arg_doc["return"]).rstrip("\n").split("\n") + self._add_text_decorations(arg_doc["return"]).rstrip("\n").split("\n") ) ) return "\n".join(wiki) - def generateCoreSide(self): + def generate_core_side(self): signals_part = [] methods_part = [] sections = self.bridge_template.sections() @@ -114,13 +114,13 @@ "sig_out": function["sig_out"] or "", "category": function["category"], "name": section, - "doc": self.getDoc(section) or "FIXME: No description available", + "doc": self.get_doc(section) or "FIXME: No description available", "async": async_msg if "async" in self.getFlags(section) else "", "deprecated": deprecated_msg if "deprecated" in self.getFlags(section) else "", - "parameters": self._wikiParameter(section, function["sig_in"]), - "return": self._wikiReturn(section) + "parameters": self._wiki_parameter(section, function["sig_in"]), + "return": self._wiki_return(section) if function["type"] == "method" else "", } @@ -148,7 +148,7 @@ # at this point, signals_part, and methods_part should be filled, # we just have to place them in the right part of the template core_bridge = [] - template_path = self.getTemplatePath(self.core_template) + template_path = self.get_template_path(self.core_template) try: with open(template_path) as core_template: for line in core_template: @@ -165,4 +165,4 @@ sys.exit(1) # now we write to final file - self.finalWrite(self.core_dest, core_bridge) + self.final_write(self.core_dest, core_bridge)