More ruff fixes in files: stop ignoring C408, UP007, PLR5501, B006

This commit is contained in:
boxydog 2024-05-30 13:21:12 -05:00
commit 7577dd7603
16 changed files with 72 additions and 82 deletions

View file

@ -103,11 +103,10 @@ def ask(question, answer=str, default=None, length=None):
break
else:
print("You must enter something")
elif length and len(r) != length:
print(f"Entry must be {length} characters long")
else:
if length and len(r) != length:
print(f"Entry must be {length} characters long")
else:
break
break
return r
@ -169,7 +168,7 @@ def ask_timezone(question, default, tzurl):
r = tz_dict[r]
break
else:
print("Please enter a valid time zone:\n" f" (check [{tzurl}])")
print(f"Please enter a valid time zone:\n (check [{tzurl}])")
return r
@ -253,7 +252,7 @@ needed by Pelican.
default=True,
):
CONF["siteurl"] = ask(
"What is your URL prefix? (see " "above example; no trailing slash)",
"What is your URL prefix? (see above example; no trailing slash)",
str,
CONF["siteurl"],
)
@ -266,7 +265,7 @@ needed by Pelican.
if CONF["with_pagination"]:
CONF["default_pagination"] = ask(
"How many articles per page " "do you want?",
"How many articles per page do you want?",
int,
CONF["default_pagination"],
)
@ -296,7 +295,7 @@ needed by Pelican.
"What is your username on that server?", str, CONF["ftp_user"]
)
CONF["ftp_target_dir"] = ask(
"Where do you want to put your " "web site on that server?",
"Where do you want to put your web site on that server?",
str,
CONF["ftp_target_dir"],
)
@ -314,7 +313,7 @@ needed by Pelican.
"What is your username on that server?", str, CONF["ssh_user"]
)
CONF["ssh_target_dir"] = ask(
"Where do you want to put your " "web site on that server?",
"Where do you want to put your web site on that server?",
str,
CONF["ssh_target_dir"],
)
@ -338,23 +337,23 @@ needed by Pelican.
)
if ask(
"Do you want to upload your website using " "Rackspace Cloud Files?",
"Do you want to upload your website using Rackspace Cloud Files?",
answer=bool,
default=False,
):
CONF["cloudfiles"] = (True,)
CONF["cloudfiles_username"] = ask(
"What is your Rackspace " "Cloud username?",
"What is your Rackspace Cloud username?",
str,
CONF["cloudfiles_username"],
)
CONF["cloudfiles_api_key"] = ask(
"What is your Rackspace " "Cloud API key?",
"What is your Rackspace Cloud API key?",
str,
CONF["cloudfiles_api_key"],
)
CONF["cloudfiles_container"] = ask(
"What is the name of your " "Cloud Files container?",
"What is the name of your Cloud Files container?",
str,
CONF["cloudfiles_container"],
)
@ -384,7 +383,7 @@ needed by Pelican.
except OSError as e:
print(f"Error: {e}")
conf_python = dict()
conf_python = {}
for key, value in CONF.items():
conf_python[key] = repr(value)
render_jinja_template("pelicanconf.py.jinja2", conf_python, "pelicanconf.py")