Mercurial > libervia-backend
diff sat_frontends/tools/strings.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 | 559a625a236b |
children |
line wrap: on
line diff
--- a/sat_frontends/tools/strings.py Fri Apr 07 15:18:39 2023 +0200 +++ b/sat_frontends/tools/strings.py Sat Apr 08 13:54:42 2023 +0200 @@ -28,7 +28,7 @@ # TODO: merge this class with an other module or at least rename it (strings is not a good name) -def getURLParams(url): +def get_url_params(url): """This comes from pyjamas.Location.makeUrlDict with a small change to also parse full URLs, and parameters with no value specified (in that case the default value "" is used). @@ -51,13 +51,13 @@ return dict_ -def addURLToText(string, new_target=True): +def add_url_to_text(string, new_target=True): """Check a text for what looks like an URL and make it clickable. @param string (unicode): text to process @param new_target (bool): if True, make the link open in a new window """ - # XXX: report any change to libervia.browser.strings.addURLToText + # XXX: report any change to libervia.browser.strings.add_url_to_text def repl(match): url = match.group(0) if not re.match(r"""[a-z]{3,}://|mailto:|xmpp:""", url): @@ -68,12 +68,12 @@ return RE_URL.sub(repl, string) -def addURLToImage(string): +def add_url_to_image(string): """Check a XHTML text for what looks like an imageURL and make it clickable. @param string (unicode): text to process """ - # XXX: report any change to libervia.browser.strings.addURLToImage + # XXX: report any change to libervia.browser.strings.add_url_to_image def repl(match): url = match.group(1) return '<a href="%s" target="_blank">%s</a>' % (url, match.group(0)) @@ -82,7 +82,7 @@ return re.sub(pattern, repl, string) -def fixXHTMLLinks(xhtml): +def fix_xhtml_links(xhtml): """Add http:// if the scheme is missing and force opening in a new window. @param string (unicode): XHTML Content