mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-04-29 23:24:55 +02:00
scripts/*.py: update coding style (#10761)
* convert to f string * use a next function instead of a for-loop * remove uneeded else statement * use in operator instead of multi comparison * conver to f string * adds extra line between function defs * revert/change to PR comment around looping * remove uneeded loops * revert to keep old style choice
This commit is contained in:
parent
71ee97c1f9
commit
e747bd8132
4 changed files with 11 additions and 13 deletions
|
@ -26,7 +26,7 @@ def main(loc, colorscheme):
|
||||||
# Set up css style sheets
|
# Set up css style sheets
|
||||||
csslist = ["basic.css"]
|
csslist = ["basic.css"]
|
||||||
if colorscheme != "basic":
|
if colorscheme != "basic":
|
||||||
csslist.append(colorscheme + ".css")
|
csslist.append(f"{colorscheme}.css")
|
||||||
|
|
||||||
# A string that stores all pages in HTML format
|
# A string that stores all pages in HTML format
|
||||||
html = (
|
html = (
|
||||||
|
|
|
@ -29,7 +29,7 @@ Is this intended? If so, just ignore this comment. Otherwise, please double-chec
|
||||||
|
|
||||||
|
|
||||||
def post_comment(pr_id, body, once):
|
def post_comment(pr_id, body, once):
|
||||||
endpoint = BOT_URL + "/comment"
|
endpoint = f"{BOT_URL}/comment"
|
||||||
|
|
||||||
if once:
|
if once:
|
||||||
endpoint += "/once"
|
endpoint += "/once"
|
||||||
|
|
|
@ -99,10 +99,9 @@ def get_alias_page(file):
|
||||||
if not os.path.isfile(file):
|
if not os.path.isfile(file):
|
||||||
return ""
|
return ""
|
||||||
with open(file) as f:
|
with open(file) as f:
|
||||||
lines = f.readlines()
|
for line in f:
|
||||||
for line in lines:
|
if match := re.search(r"^`tldr (.+)`", line):
|
||||||
if re.search(r"^`tldr ", line):
|
return match[1]
|
||||||
return re.search("`tldr (.+)`", line).group(1)
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -56,11 +56,10 @@ def get_tldr_root():
|
||||||
|
|
||||||
if "TLDR_ROOT" in os.environ:
|
if "TLDR_ROOT" in os.environ:
|
||||||
return os.environ["TLDR_ROOT"]
|
return os.environ["TLDR_ROOT"]
|
||||||
else:
|
print(
|
||||||
print(
|
"\x1b[31mPlease set TLDR_ROOT to the location of a clone of https://github.com/tldr-pages/tldr."
|
||||||
"\x1b[31mPlease set TLDR_ROOT to the location of a clone of https://github.com/tldr-pages/tldr."
|
)
|
||||||
)
|
sys.exit(1)
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
|
|
||||||
def set_link(file, link):
|
def set_link(file, link):
|
||||||
|
@ -88,9 +87,9 @@ def set_link(file, link):
|
||||||
# build new line
|
# build new line
|
||||||
if locale == "hi":
|
if locale == "hi":
|
||||||
new_line = f"> {labels[locale]} <{link}>।\n"
|
new_line = f"> {labels[locale]} <{link}>।\n"
|
||||||
elif locale == "ja" or locale == "th":
|
elif locale in ["ja", "th"]:
|
||||||
new_line = f"> {labels[locale]} <{link}>\n"
|
new_line = f"> {labels[locale]} <{link}>\n"
|
||||||
elif locale == "zh" or locale == "zh_TW":
|
elif locale in ["zh", "zh_TW"]:
|
||||||
new_line = f"> {labels[locale]}<{link}>.\n"
|
new_line = f"> {labels[locale]}<{link}>.\n"
|
||||||
else:
|
else:
|
||||||
new_line = f"> {labels[locale]} <{link}>.\n"
|
new_line = f"> {labels[locale]} <{link}>.\n"
|
||||||
|
|
Loading…
Add table
Reference in a new issue