mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-14 22:45:47 +00:00
style: fix some typos and warnings
This commit is contained in:
@ -21,7 +21,7 @@ import argparse
|
||||
|
||||
from pathlib import Path
|
||||
from pwd import getpwuid
|
||||
from urllib.parse import quote_plus as urlencode
|
||||
from urllib.parse import quote_plus as url_encode
|
||||
|
||||
from ahriman.application.application import Application
|
||||
from ahriman.application.handlers.handler import Handler, SubParserAction
|
||||
@ -174,7 +174,7 @@ class Setup(Handler):
|
||||
if args.web_unix_socket is not None:
|
||||
unix_socket = str(args.web_unix_socket)
|
||||
configuration.set_option("web", "unix_socket", unix_socket)
|
||||
configuration.set_option("status", "address", f"http+unix://{urlencode(unix_socket)}")
|
||||
configuration.set_option("status", "address", f"http+unix://{url_encode(unix_socket)}")
|
||||
|
||||
if args.generate_salt:
|
||||
configuration.set_option("auth", "salt", User.generate_password(20))
|
||||
|
@ -146,7 +146,7 @@ class PkgbuildParser(shlex.shlex):
|
||||
# reset state
|
||||
buffer, prefix = [], None
|
||||
|
||||
# we have already prefix string, so we are in progress of expansion
|
||||
# we have already got prefix string, so we are in progress of expansion
|
||||
# we always operate the last element, so this matches ",", "next"
|
||||
case (PkgbuildToken.Comma, _) if prefix is not None:
|
||||
buffer.append(f"{prefix}{second}")
|
||||
@ -168,7 +168,7 @@ class PkgbuildParser(shlex.shlex):
|
||||
def _is_escaped(self) -> bool:
|
||||
"""
|
||||
check if the last element was quoted. ``shlex.shlex`` parser doesn't provide information about was the token
|
||||
quoted or not, thus there is no difference between "'#'" (diez in quotes) and "#" (diez without quotes). This
|
||||
quoted or not, thus there is no difference between "'#'" (sharp in quotes) and "#" (sharp without quotes). This
|
||||
method simply rolls back to the last non-space character and check if it is a quotation mark
|
||||
|
||||
Returns:
|
||||
|
@ -58,8 +58,8 @@ class EventStatsPrinter(StringPrinter):
|
||||
mean = statistics.mean(self.events)
|
||||
|
||||
if len(self.events) > 1:
|
||||
stdev = statistics.stdev(self.events)
|
||||
average = f"{mean:.3f} ± {stdev:.3f}"
|
||||
st_dev = statistics.stdev(self.events)
|
||||
average = f"{mean:.3f} ± {st_dev:.3f}"
|
||||
else:
|
||||
average = f"{mean:.3f}"
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#
|
||||
import contextlib
|
||||
|
||||
from urllib.parse import quote_plus as urlencode
|
||||
from urllib.parse import quote_plus as url_encode
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.http import SyncAhrimanClient
|
||||
@ -75,7 +75,7 @@ class WebClient(Client, SyncAhrimanClient):
|
||||
# legacy-style section
|
||||
if (unix_socket := configuration.get("web", "unix_socket", fallback=None)) is not None:
|
||||
# special pseudo-protocol which is used for unix sockets
|
||||
return "web", f"http+unix://{urlencode(unix_socket)}"
|
||||
return "web", f"http+unix://{url_encode(unix_socket)}"
|
||||
address = configuration.get("web", "address", fallback=None)
|
||||
if not address:
|
||||
# build address from host and port directly
|
||||
@ -94,7 +94,7 @@ class WebClient(Client, SyncAhrimanClient):
|
||||
Returns:
|
||||
str: full url for web service for changes
|
||||
"""
|
||||
return f"{self.address}/api/v1/packages/{urlencode(package_base)}/changes"
|
||||
return f"{self.address}/api/v1/packages/{url_encode(package_base)}/changes"
|
||||
|
||||
def _dependencies_url(self, package_base: str) -> str:
|
||||
"""
|
||||
@ -106,7 +106,7 @@ class WebClient(Client, SyncAhrimanClient):
|
||||
Returns:
|
||||
str: full url for web service for dependencies
|
||||
"""
|
||||
return f"{self.address}/api/v1/packages/{urlencode(package_base)}/dependencies"
|
||||
return f"{self.address}/api/v1/packages/{url_encode(package_base)}/dependencies"
|
||||
|
||||
def _events_url(self) -> str:
|
||||
"""
|
||||
@ -127,7 +127,7 @@ class WebClient(Client, SyncAhrimanClient):
|
||||
Returns:
|
||||
str: full url for web service for logs
|
||||
"""
|
||||
return f"{self.address}/api/v1/packages/{urlencode(package_base)}/logs"
|
||||
return f"{self.address}/api/v1/packages/{url_encode(package_base)}/logs"
|
||||
|
||||
def _package_url(self, package_base: str = "") -> str:
|
||||
"""
|
||||
@ -139,7 +139,7 @@ class WebClient(Client, SyncAhrimanClient):
|
||||
Returns:
|
||||
str: full url of web service for specific package base
|
||||
"""
|
||||
suffix = f"/{urlencode(package_base)}" if package_base else ""
|
||||
suffix = f"/{url_encode(package_base)}" if package_base else ""
|
||||
return f"{self.address}/api/v1/packages{suffix}"
|
||||
|
||||
def _patches_url(self, package_base: str, variable: str = "") -> str:
|
||||
@ -153,8 +153,8 @@ class WebClient(Client, SyncAhrimanClient):
|
||||
Returns:
|
||||
str: full url of web service for the package patch
|
||||
"""
|
||||
suffix = f"/{urlencode(variable)}" if variable else ""
|
||||
return f"{self.address}/api/v1/packages/{urlencode(package_base)}/patches{suffix}"
|
||||
suffix = f"/{url_encode(variable)}" if variable else ""
|
||||
return f"{self.address}/api/v1/packages/{url_encode(package_base)}/patches{suffix}"
|
||||
|
||||
def _status_url(self) -> str:
|
||||
"""
|
||||
|
@ -107,8 +107,8 @@ class Pkgbuild(Mapping[str, Any]):
|
||||
|
||||
def __getitem__(self, item: str) -> Any:
|
||||
"""
|
||||
get the field of the PKGBUILD. This method tries to get exact key value if possible; if none found, it tries to
|
||||
fetch function with the same name
|
||||
get the field of the PKGBUILD. This method tries to get exact key value if possible; if none was found,
|
||||
it tries to fetch function with the same name
|
||||
|
||||
Args:
|
||||
item(str): key name
|
||||
|
Reference in New Issue
Block a user