mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-03-24 02:13:38 +00:00
docs: update docstrings
This commit is contained in:
@@ -104,7 +104,7 @@ class PkgbuildParser(shlex.shlex):
|
|||||||
|
|
||||||
# ignore substitution and extend bash symbols
|
# ignore substitution and extend bash symbols
|
||||||
self.wordchars += "${}#:+-@!"
|
self.wordchars += "${}#:+-@!"
|
||||||
# in case of default behaviour, it will ignore, for example, segment part of url outside of quotes
|
# in case of default behavior, it will ignore, for example, segment part of url outside of quotes
|
||||||
self.commenters = ""
|
self.commenters = ""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class AUR(Remote):
|
|||||||
parse RPC response to package list
|
parse RPC response to package list
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
response(dict[str, Any]): RPC response json
|
response(dict[str, Any]): RPC response JSON
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list[AURPackage]: list of parsed packages
|
list[AURPackage]: list of parsed packages
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class Official(Remote):
|
|||||||
parse RPC response to package list
|
parse RPC response to package list
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
response(dict[str, Any]): RPC response json
|
response(dict[str, Any]): RPC response JSON
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list[AURPackage]: list of parsed packages
|
list[AURPackage]: list of parsed packages
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class OfficialSyncdb(Official):
|
|||||||
updates.
|
updates.
|
||||||
|
|
||||||
This approach also has limitations, because we don't require superuser rights (neither going to download database
|
This approach also has limitations, because we don't require superuser rights (neither going to download database
|
||||||
separately), the database file might be outdated and must be handled manually (or kind of). This behaviour might be
|
separately), the database file might be outdated and must be handled manually (or kind of). This behavior might be
|
||||||
changed in the future.
|
changed in the future.
|
||||||
|
|
||||||
Still we leave search function based on the official repositories RPC.
|
Still we leave search function based on the official repositories RPC.
|
||||||
|
|||||||
@@ -50,13 +50,13 @@ class Auth(LazyLogging):
|
|||||||
@property
|
@property
|
||||||
def auth_control(self) -> str:
|
def auth_control(self) -> str:
|
||||||
"""
|
"""
|
||||||
This workaround is required to make different behaviour for login interface.
|
This workaround is required to make different behavior for login interface.
|
||||||
In case of internal authentication it must provide an interface (modal form) to log in with button sends POST
|
In case of internal authentication it must provide an interface (modal form) to log in with button sends POST
|
||||||
request. But for an external providers behaviour can be different: e.g. OAuth provider requires sending GET
|
request. But for an external providers behavior can be different: e.g. OAuth provider requires sending GET
|
||||||
request to external resource
|
request to external resource
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str: login control as html code to insert
|
str: login control as HTML code to insert
|
||||||
"""
|
"""
|
||||||
return "<button type=\"button\" class=\"btn btn-link\" data-bs-toggle=\"modal\" data-bs-target=\"#login-modal\" style=\"text-decoration: none\"><i class=\"bi bi-box-arrow-in-right\"></i> login</button>"
|
return "<button type=\"button\" class=\"btn btn-link\" data-bs-toggle=\"modal\" data-bs-target=\"#login-modal\" style=\"text-decoration: none\"><i class=\"bi bi-box-arrow-in-right\"></i> login</button>"
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,13 @@ except ImportError:
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["authorized_userid", "check_authorized", "forget", "remember"]
|
__all__ = [
|
||||||
|
"authorized_userid",
|
||||||
|
"check_authorized",
|
||||||
|
"forget",
|
||||||
|
"get_session",
|
||||||
|
"remember",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
async def authorized_userid(*args: Any, **kwargs: Any) -> Any:
|
async def authorized_userid(*args: Any, **kwargs: Any) -> Any:
|
||||||
|
|||||||
@@ -62,10 +62,10 @@ class OAuth(Mapping):
|
|||||||
@property
|
@property
|
||||||
def auth_control(self) -> str:
|
def auth_control(self) -> str:
|
||||||
"""
|
"""
|
||||||
get authorization html control
|
get authorization HTML control
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str: login control as html code to insert
|
str: login control as HTML code to insert
|
||||||
"""
|
"""
|
||||||
return "<a class=\"nav-link\" href=\"/api/v1/login\" title=\"login via OAuth2\"><i class=\"bi bi-box-arrow-in-right\"></i> login</a>"
|
return "<a class=\"nav-link\" href=\"/api/v1/login\" title=\"login via OAuth2\"><i class=\"bi bi-box-arrow-in-right\"></i> login</a>"
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class Configuration(configparser.RawConfigParser):
|
|||||||
def __init__(self, allow_no_value: bool = False, allow_multi_key: bool = True) -> None:
|
def __init__(self, allow_no_value: bool = False, allow_multi_key: bool = True) -> None:
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
allow_no_value(bool, optional): copies :class:`configparser.RawConfigParser` behaviour. In case if it is set
|
allow_no_value(bool, optional): copies :class:`configparser.RawConfigParser` behavior. In case if it is set
|
||||||
to ``True``, the keys without values will be allowed (Default value = False)
|
to ``True``, the keys without values will be allowed (Default value = False)
|
||||||
allow_multi_key(bool, optional): if set to ``False``, then the default dictionary class will be used to
|
allow_multi_key(bool, optional): if set to ``False``, then the default dictionary class will be used to
|
||||||
store keys internally. Otherwise, the special implementation will be used, which supports arrays
|
store keys internally. Otherwise, the special implementation will be used, which supports arrays
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ class SyncHttpClient(LazyLogging):
|
|||||||
headers(dict[str, str] | None, optional): request headers (Default value = None)
|
headers(dict[str, str] | None, optional): request headers (Default value = None)
|
||||||
params(list[tuple[str, str]] | None, optional): request query parameters (Default value = None)
|
params(list[tuple[str, str]] | None, optional): request query parameters (Default value = None)
|
||||||
data(Any | None, optional): request raw data parameters (Default value = None)
|
data(Any | None, optional): request raw data parameters (Default value = None)
|
||||||
json(dict[str, Any] | None, optional): request json parameters (Default value = None)
|
json(dict[str, Any] | None, optional): request JSON parameters (Default value = None)
|
||||||
files(dict[str, MultipartType] | None, optional): multipart upload (Default value = None)
|
files(dict[str, MultipartType] | None, optional): multipart upload (Default value = None)
|
||||||
stream(bool | None, optional): handle response as stream (Default value = None)
|
stream(bool | None, optional): handle response as stream (Default value = None)
|
||||||
session(requests.Session | None, optional): session object if any (Default value = None)
|
session(requests.Session | None, optional): session object if any (Default value = None)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ from ahriman.models.result import Result
|
|||||||
|
|
||||||
class Console(Report):
|
class Console(Report):
|
||||||
"""
|
"""
|
||||||
html report generator
|
HTML report generator
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
use_utf(bool): print utf8 symbols instead of ASCII
|
use_utf(bool): print utf8 symbols instead of ASCII
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ from ahriman.models.result import Result
|
|||||||
|
|
||||||
class HTML(Report, JinjaTemplate):
|
class HTML(Report, JinjaTemplate):
|
||||||
"""
|
"""
|
||||||
html report generator
|
HTML report generator
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
report_path(Path): output path to html report
|
report_path(Path): output path to HTML report
|
||||||
template(Path | str): name or path to template for full package list
|
template(Path | str): name or path to template for full package list
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class Report(LazyLogging):
|
|||||||
Args:
|
Args:
|
||||||
repository_id(RepositoryId): repository unique identifier
|
repository_id(RepositoryId): repository unique identifier
|
||||||
configuration(Configuration): configuration instance
|
configuration(Configuration): configuration instance
|
||||||
target(str): target to generate report aka section name (e.g. html)
|
target(str): target to generate report aka section name (e.g. HTML)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Report: client according to current settings
|
Report: client according to current settings
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class Trigger(LazyLogging):
|
|||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
CONFIGURATION_SCHEMA(ConfigurationSchema): (class attribute) configuration schema template
|
CONFIGURATION_SCHEMA(ConfigurationSchema): (class attribute) configuration schema template
|
||||||
REQUIRES_REPOSITORY(bool): (class attribute) either trigger requires loaded repository or not
|
REQUIRES_REPOSITORY(bool): (class attribute) either trigger requires a repository to be loaded or not
|
||||||
configuration(Configuration): configuration instance
|
configuration(Configuration): configuration instance
|
||||||
repository_id(RepositoryId): repository unique identifier
|
repository_id(RepositoryId): repository unique identifier
|
||||||
|
|
||||||
|
|||||||
@@ -231,13 +231,13 @@ def check_user(root: Path, *, unsafe: bool) -> None:
|
|||||||
|
|
||||||
def dataclass_view(instance: Any) -> dict[str, Any]:
|
def dataclass_view(instance: Any) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
convert dataclass instance to json object
|
convert dataclass instance to JSON object
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
instance(Any): dataclass instance
|
instance(Any): dataclass instance
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict[str, Any]: json representation of the dataclass with empty field removed
|
dict[str, Any]: JSON representation of the dataclass with empty field removed
|
||||||
"""
|
"""
|
||||||
return asdict(instance, dict_factory=lambda fields: {key: value for key, value in fields if value is not None})
|
return asdict(instance, dict_factory=lambda fields: {key: value for key, value in fields if value is not None})
|
||||||
|
|
||||||
@@ -287,15 +287,15 @@ def filelock(path: Path) -> Iterator[FileLock]:
|
|||||||
|
|
||||||
def filter_json(source: T, known_fields: Iterable[str] | None = None) -> T:
|
def filter_json(source: T, known_fields: Iterable[str] | None = None) -> T:
|
||||||
"""
|
"""
|
||||||
recursively filter json object removing ``None`` values and optionally filtering by known fields
|
recursively filter JSON object removing ``None`` values and optionally filtering by known fields
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
source(T): raw json object (dict, list, or scalar)
|
source(T): raw JSON object (dict, list, or scalar)
|
||||||
known_fields(Iterable[str] | None, optional): list of fields which have to be known for the target object
|
known_fields(Iterable[str] | None, optional): list of fields which have to be known for the target object
|
||||||
(Default value = None)
|
(Default value = None)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
T: json without ``None`` values
|
T: JSON without ``None`` values
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
This wrapper is mainly used for the dataclasses, thus the flow must be something like this::
|
This wrapper is mainly used for the dataclasses, thus the flow must be something like this::
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class AURPackage:
|
|||||||
Examples:
|
Examples:
|
||||||
Mainly this class must be used from class methods instead of default :func:`__init__()`::
|
Mainly this class must be used from class methods instead of default :func:`__init__()`::
|
||||||
|
|
||||||
>>> package = AURPackage.from_json(metadata) # load package from json dump
|
>>> package = AURPackage.from_json(metadata) # load package from JSON dump
|
||||||
>>> # ...or alternatively...
|
>>> # ...or alternatively...
|
||||||
>>> package = AURPackage.from_repo(metadata) # load package from official repository RPC
|
>>> package = AURPackage.from_repo(metadata) # load package from official repository RPC
|
||||||
>>> # properties of the class are built based on ones from AUR RPC, thus additional method is required
|
>>> # properties of the class are built based on ones from AUR RPC, thus additional method is required
|
||||||
@@ -175,7 +175,7 @@ class AURPackage:
|
|||||||
construct package descriptor from official repository RPC properties
|
construct package descriptor from official repository RPC properties
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
dump(dict[str, Any]): json dump body
|
dump(dict[str, Any]): JSON dump body
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Self: AUR package descriptor
|
Self: AUR package descriptor
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class BuildStatus:
|
|||||||
|
|
||||||
def view(self) -> dict[str, Any]:
|
def view(self) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
generate json status view
|
generate JSON status view
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict[str, Any]: json-friendly dictionary
|
dict[str, Any]: json-friendly dictionary
|
||||||
|
|||||||
@@ -41,10 +41,10 @@ class Changes:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, dump: dict[str, Any]) -> Self:
|
def from_json(cls, dump: dict[str, Any]) -> Self:
|
||||||
"""
|
"""
|
||||||
construct changes from the json dump
|
construct changes from the JSON dump
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
dump(dict[str, Any]): json dump body
|
dump(dict[str, Any]): JSON dump body
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Self: changes object
|
Self: changes object
|
||||||
@@ -55,7 +55,7 @@ class Changes:
|
|||||||
|
|
||||||
def view(self) -> dict[str, Any]:
|
def view(self) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
generate json change view
|
generate JSON change view
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict[str, Any]: json-friendly dictionary
|
dict[str, Any]: json-friendly dictionary
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ class Counters:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, dump: dict[str, Any]) -> Self:
|
def from_json(cls, dump: dict[str, Any]) -> Self:
|
||||||
"""
|
"""
|
||||||
construct counters from json dump
|
construct counters from JSON dump
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
dump(dict[str, Any]): json dump body
|
dump(dict[str, Any]): JSON dump body
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Self: status counters
|
Self: status counters
|
||||||
|
|||||||
@@ -72,10 +72,10 @@ class Event:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, dump: dict[str, Any]) -> Self:
|
def from_json(cls, dump: dict[str, Any]) -> Self:
|
||||||
"""
|
"""
|
||||||
construct event from the json dump
|
construct event from the JSON dump
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
dump(dict[str, Any]): json dump body
|
dump(dict[str, Any]): JSON dump body
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Self: event object
|
Self: event object
|
||||||
@@ -102,7 +102,7 @@ class Event:
|
|||||||
|
|
||||||
def view(self) -> dict[str, Any]:
|
def view(self) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
generate json event view
|
generate JSON event view
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict[str, Any]: json-friendly dictionary
|
dict[str, Any]: json-friendly dictionary
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ class InternalStatus:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, dump: dict[str, Any]) -> Self:
|
def from_json(cls, dump: dict[str, Any]) -> Self:
|
||||||
"""
|
"""
|
||||||
construct internal status from json dump
|
construct internal status from JSON dump
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
dump(dict[str, Any]): json dump body
|
dump(dict[str, Any]): JSON dump body
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Self: internal status
|
Self: internal status
|
||||||
@@ -70,7 +70,7 @@ class InternalStatus:
|
|||||||
|
|
||||||
def view(self) -> dict[str, Any]:
|
def view(self) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
generate json status view
|
generate JSON status view
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict[str, Any]: json-friendly dictionary
|
dict[str, Any]: json-friendly dictionary
|
||||||
|
|||||||
@@ -41,11 +41,11 @@ class LogRecord:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, package_base: str, dump: dict[str, Any]) -> Self:
|
def from_json(cls, package_base: str, dump: dict[str, Any]) -> Self:
|
||||||
"""
|
"""
|
||||||
construct log record from the json dump
|
construct log record from the JSON dump
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
package_base(str): package base for which log record belongs
|
package_base(str): package base for which log record belongs
|
||||||
dump(dict[str, Any]): json dump body
|
dump(dict[str, Any]): JSON dump body
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Self: log record object
|
Self: log record object
|
||||||
@@ -63,7 +63,7 @@ class LogRecord:
|
|||||||
|
|
||||||
def view(self) -> dict[str, Any]:
|
def view(self) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
generate json log record view
|
generate JSON log record view
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict[str, Any]: json-friendly dictionary
|
dict[str, Any]: json-friendly dictionary
|
||||||
|
|||||||
@@ -50,11 +50,11 @@ class Package(LazyLogging):
|
|||||||
version(str): package full version
|
version(str): package full version
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
Different usages of this class may generate different (incomplete) data, e.g. if instantiating class from json::
|
Different usages of this class may generate different (incomplete) data, e.g. if instantiating class from JSON::
|
||||||
|
|
||||||
>>> package = Package.from_json(dump)
|
>>> package = Package.from_json(dump)
|
||||||
|
|
||||||
it will contain every data available in the json body. Otherwise, if generate package from local archive::
|
it will contain every data available in the JSON body. Otherwise, if generate package from local archive::
|
||||||
|
|
||||||
>>> package = Package.from_archive(local_path, pacman)
|
>>> package = Package.from_archive(local_path, pacman)
|
||||||
|
|
||||||
@@ -273,10 +273,10 @@ class Package(LazyLogging):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, dump: dict[str, Any]) -> Self:
|
def from_json(cls, dump: dict[str, Any]) -> Self:
|
||||||
"""
|
"""
|
||||||
construct package properties from json dump
|
construct package properties from JSON dump
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
dump(dict[str, Any]): json dump body
|
dump(dict[str, Any]): JSON dump body
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Self: package properties
|
Self: package properties
|
||||||
@@ -396,7 +396,7 @@ class Package(LazyLogging):
|
|||||||
|
|
||||||
def view(self) -> dict[str, Any]:
|
def view(self) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
generate json package view
|
generate JSON package view
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict[str, Any]: json-friendly dictionary
|
dict[str, Any]: json-friendly dictionary
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class PackageDescription:
|
|||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
Unlike the :class:`ahriman.models.package.Package` class, this implementation only holds properties.
|
Unlike the :class:`ahriman.models.package.Package` class, this implementation only holds properties.
|
||||||
The recommended way to deal with it is to read data based on the source type - either json or
|
The recommended way to deal with it is to read data based on the source type - either JSON or
|
||||||
:class:`pyalpm.Package` instance::
|
:class:`pyalpm.Package` instance::
|
||||||
|
|
||||||
>>> description = PackageDescription.from_json(dump)
|
>>> description = PackageDescription.from_json(dump)
|
||||||
@@ -126,10 +126,10 @@ class PackageDescription:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, dump: dict[str, Any]) -> Self:
|
def from_json(cls, dump: dict[str, Any]) -> Self:
|
||||||
"""
|
"""
|
||||||
construct package properties from json dump
|
construct package properties from JSON dump
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
dump(dict[str, Any]): json dump body
|
dump(dict[str, Any]): JSON dump body
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Self: package properties
|
Self: package properties
|
||||||
@@ -169,7 +169,7 @@ class PackageDescription:
|
|||||||
|
|
||||||
def view(self) -> dict[str, Any]:
|
def view(self) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
generate json package view
|
generate JSON package view
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict[str, Any]: json-friendly dictionary
|
dict[str, Any]: json-friendly dictionary
|
||||||
|
|||||||
@@ -87,10 +87,10 @@ class PkgbuildPatch:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, dump: dict[str, Any]) -> Self:
|
def from_json(cls, dump: dict[str, Any]) -> Self:
|
||||||
"""
|
"""
|
||||||
construct patch descriptor from the json dump
|
construct patch descriptor from the JSON dump
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
dump(dict[str, Any]): json dump body
|
dump(dict[str, Any]): JSON dump body
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Self: patch object
|
Self: patch object
|
||||||
@@ -125,7 +125,7 @@ class PkgbuildPatch:
|
|||||||
# the source value looks like shell array, remove brackets and parse with shlex
|
# the source value looks like shell array, remove brackets and parse with shlex
|
||||||
return shlex.split(shell_array[1:-1])
|
return shlex.split(shell_array[1:-1])
|
||||||
case json_array if json_array.startswith("[") and json_array.endswith("]"):
|
case json_array if json_array.startswith("[") and json_array.endswith("]"):
|
||||||
# json (aka python) array, parse with json parser instead
|
# JSON (aka python) array, parse with JSON parser instead
|
||||||
parsed: list[str] = json.loads(json_array)
|
parsed: list[str] = json.loads(json_array)
|
||||||
return parsed
|
return parsed
|
||||||
case variable:
|
case variable:
|
||||||
@@ -220,7 +220,7 @@ class PkgbuildPatch:
|
|||||||
|
|
||||||
def view(self) -> dict[str, Any]:
|
def view(self) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
generate json patch view
|
generate JSON patch view
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict[str, Any]: json-friendly dictionary
|
dict[str, Any]: json-friendly dictionary
|
||||||
|
|||||||
@@ -74,10 +74,10 @@ class RemoteSource:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, dump: dict[str, Any]) -> Self:
|
def from_json(cls, dump: dict[str, Any]) -> Self:
|
||||||
"""
|
"""
|
||||||
construct remote source from the json dump (or database row)
|
construct remote source from the JSON dump (or database row)
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
dump(dict[str, Any]): json dump body
|
dump(dict[str, Any]): JSON dump body
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Self: remote source
|
Self: remote source
|
||||||
@@ -102,7 +102,7 @@ class RemoteSource:
|
|||||||
|
|
||||||
def view(self) -> dict[str, Any]:
|
def view(self) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
generate json package remote view
|
generate JSON package remote view
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict[str, Any]: json-friendly dictionary
|
dict[str, Any]: json-friendly dictionary
|
||||||
|
|||||||
@@ -28,10 +28,10 @@ class ReportSettings(StrEnum):
|
|||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
Disabled(ReportSettings): option which generates no report for testing purpose
|
Disabled(ReportSettings): option which generates no report for testing purpose
|
||||||
HTML(ReportSettings): html report generation
|
HTML(ReportSettings): HTML report generation
|
||||||
Email(ReportSettings): email report generation
|
Email(ReportSettings): email report generation
|
||||||
Console(ReportSettings): print result to console
|
Console(ReportSettings): print result to console
|
||||||
Telegram(ReportSettings): markdown report to telegram channel
|
Telegram(ReportSettings): Markdown report to telegram channel
|
||||||
RSS(ReportSettings): RSS report generation
|
RSS(ReportSettings): RSS report generation
|
||||||
RemoteCall(ReportSettings): remote ahriman server call
|
RemoteCall(ReportSettings): remote ahriman server call
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class RepositoryId:
|
|||||||
|
|
||||||
def view(self) -> dict[str, Any]:
|
def view(self) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
generate json package view
|
generate JSON package view
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict[str, Any]: json-friendly dictionary
|
dict[str, Any]: json-friendly dictionary
|
||||||
|
|||||||
@@ -38,10 +38,10 @@ class RepositoryStats:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, dump: dict[str, Any]) -> Self:
|
def from_json(cls, dump: dict[str, Any]) -> Self:
|
||||||
"""
|
"""
|
||||||
construct counters from json dump
|
construct counters from JSON dump
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
dump(dict[str, Any]): json dump body
|
dump(dict[str, Any]): JSON dump body
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Self: status counters
|
Self: status counters
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class Worker:
|
|||||||
|
|
||||||
def view(self) -> dict[str, Any]:
|
def view(self) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
generate json patch view
|
generate JSON worker view
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict[str, Any]: json-friendly dictionary
|
dict[str, Any]: json-friendly dictionary
|
||||||
|
|||||||
@@ -42,13 +42,13 @@ __all__ = ["exception_handler"]
|
|||||||
|
|
||||||
def _is_templated_unauthorized(request: Request) -> bool:
|
def _is_templated_unauthorized(request: Request) -> bool:
|
||||||
"""
|
"""
|
||||||
check if the request is eligible for rendering html template
|
check if the request is eligible for rendering HTML template
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
request(Request): source request to check
|
request(Request): source request to check
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool: ``True`` in case if response should be rendered as html and ``False`` otherwise
|
bool: ``True`` in case if response should be rendered as HTML and ``False`` otherwise
|
||||||
"""
|
"""
|
||||||
return request.path in ("/api/v1/login", "/api/v1/logout") \
|
return request.path in ("/api/v1/login", "/api/v1/logout") \
|
||||||
and "application/json" not in request.headers.getall("accept", [])
|
and "application/json" not in request.headers.getall("accept", [])
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ async def server_info(view: BaseView) -> dict[str, Any]:
|
|||||||
view(BaseView): view of the request
|
view(BaseView): view of the request
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict[str, Any]: server info as a json response
|
dict[str, Any]: server info as a JSON response
|
||||||
"""
|
"""
|
||||||
autorefresh_intervals = [
|
autorefresh_intervals = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class DocsView(BaseView):
|
|||||||
@aiohttp_jinja2.template("api.jinja2")
|
@aiohttp_jinja2.template("api.jinja2")
|
||||||
async def get(self) -> dict[str, Any]:
|
async def get(self) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
return static docs html
|
return static docs HTML
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict[str, Any]: parameters for jinja template
|
dict[str, Any]: parameters for jinja template
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class SwaggerView(BaseView):
|
|||||||
get api specification
|
get api specification
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Response: 200 with json api specification
|
Response: 200 with JSON api specification
|
||||||
"""
|
"""
|
||||||
spec = self.request.app["swagger_dict"]
|
spec = self.request.app["swagger_dict"]
|
||||||
is_body_parameter: Callable[[dict[str, str]], bool] = lambda p: p["in"] == "body" or p["in"] == "formData"
|
is_body_parameter: Callable[[dict[str, str]], bool] = lambda p: p["in"] == "body" or p["in"] == "formData"
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ class BaseView(View, CorsViewMixin):
|
|||||||
filter and convert data and return :class:`aiohttp.web.Response` object
|
filter and convert data and return :class:`aiohttp.web.Response` object
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
data(dict[str, Any] | list[Any]): response in json format
|
data(dict[str, Any] | list[Any]): response in JSON format
|
||||||
**kwargs(Any): keyword arguments for :func:`aiohttp.web.json_response` function
|
**kwargs(Any): keyword arguments for :func:`aiohttp.web.json_response` function
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|||||||
Reference in New Issue
Block a user