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

@ -28,7 +28,7 @@ RE_URL = re.compile(
# 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 @@ def getURLParams(url):
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 @@ def addURLToText(string, new_target=True):
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 @@ def addURLToImage(string):
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