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:
parent
d50412c7f7
commit
6a6f15707a
1 changed files with 9945 additions and 9945 deletions
|
|
@ -33,12 +33,12 @@ TEXT_MAX_LEN = 60
|
|||
TEXT_WORD_MIN_LENGHT = 0
|
||||
|
||||
|
||||
def reJoin(exps):
|
||||
def re_join(exps):
|
||||
"""Join (OR) various regexes"""
|
||||
return re.compile("|".join(exps))
|
||||
|
||||
|
||||
def reSubDict(pattern, repl_dict, string):
|
||||
def re_sub_dict(pattern, repl_dict, string):
|
||||
"""Replace key, value found in dict according to pattern
|
||||
|
||||
@param pattern(basestr): pattern using keys found in repl_dict
|
||||
|
|
@ -49,29 +49,29 @@ def reSubDict(pattern, repl_dict, string):
|
|||
return pattern.sub(lambda m: repl_dict[re.escape(m.group(0))], string)
|
||||
|
||||
|
||||
path_escape_re = reJoin(list(path_escape.keys()))
|
||||
path_escape_rev_re = reJoin(list(path_escape_rev.keys()))
|
||||
path_escape_re = re_join(list(path_escape.keys()))
|
||||
path_escape_rev_re = re_join(list(path_escape_rev.keys()))
|
||||
|
||||
|
||||
def pathEscape(string):
|
||||
def path_escape(string):
|
||||
"""Escape string so it can be use in a file path
|
||||
|
||||
@param string(basestr): string to escape
|
||||
@return (str, unicode): escaped string, usable in a file path
|
||||
"""
|
||||
return reSubDict(path_escape_re, path_escape, string)
|
||||
return re_sub_dict(path_escape_re, path_escape, string)
|
||||
|
||||
|
||||
def pathUnescape(string):
|
||||
def path_unescape(string):
|
||||
"""Unescape string from value found in file path
|
||||
|
||||
@param string(basestr): string found in file path
|
||||
@return (str, unicode): unescaped string
|
||||
"""
|
||||
return reSubDict(path_escape_rev_re, path_escape_rev, string)
|
||||
return re_sub_dict(path_escape_rev_re, path_escape_rev, string)
|
||||
|
||||
|
||||
def ansiRemove(string):
|
||||
def ansi_remove(string):
|
||||
"""Remove ANSI escape codes from string
|
||||
|
||||
@param string(basestr): string to filter
|
||||
|
|
@ -80,7 +80,7 @@ def ansiRemove(string):
|
|||
return RE_ANSI_REMOVE.sub("", string)
|
||||
|
||||
|
||||
def urlFriendlyText(text):
|
||||
def url_friendly_text(text):
|
||||
"""Convert text to url-friendly one"""
|
||||
# we change special chars to ascii one,
|
||||
# trick found at https://stackoverflow.com/a/3194567
|
||||
|
|
|
|||
Loading…
Reference in a new issue