Compare commits

..

13 Commits

85 changed files with 183 additions and 218 deletions

View File

@ -84,8 +84,6 @@ Again, the most checks can be performed by `tox` command, though some additional
def __init__(self, *args: Any, **kwargs: Any) -> None:
"""
default constructor
Args:
*args(Any): positional arguments
**kwargs(Any): keyword arguments
@ -93,6 +91,8 @@ Again, the most checks can be performed by `tox` command, though some additional
self.instance_attribute = ""
```
Note missing comment for the `__init__` method, which is the special case.
* Type annotations are the must, even for local functions. For the function argument `self` (for instance methods) and `cls` (for class methods) should not be annotated.
* For collection types built-in classes must be used if possible (e.g. `dict` instead of `typing.Dict`, `tuple` instead of `typing.Tuple`). In case if built-in type is not available, but `collections.abc` provides interface, it must be used (e.g. `collections.abc.Awaitable` instead of `typing.Awaitable`, `collections.abc.Iterable` instead of `typing.Iterable`). For union classes, the bar operator (`|`) must be used (e.g. `float | int` instead of `typing.Union[float, int]`), which also includes `typing.Optional` (e.g. `str | None` instead of `Optional[str]`).
* `classmethod` should (almost) always return `Self`. In case of mypy warning (e.g. if there is a branch in which function doesn't return the instance of `cls`) consider using `staticmethod` instead.

View File

@ -40,8 +40,6 @@ class ApplicationProperties(LazyLogging):
def __init__(self, repository_id: RepositoryId, configuration: Configuration, *, report: bool,
refresh_pacman_database: PacmanSynchronization = PacmanSynchronization.Disabled) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -49,8 +49,6 @@ class UpdatesIterator(Iterator[list[str] | None]):
def __init__(self, application: Application, interval: int) -> None:
"""
default constructor
Args:
application(Application): application instance
interval(int): predefined interval for updates

View File

@ -37,8 +37,6 @@ class LocalUpdater(Updater):
def __init__(self, repository: Repository) -> None:
"""
default constructor
Args:
repository(Repository): repository instance
"""

View File

@ -43,8 +43,6 @@ class RemoteUpdater(Updater):
def __init__(self, workers: list[Worker], repository_id: RepositoryId, configuration: Configuration) -> None:
"""
default constructor
Args:
workers(list[Worker]): worker identifiers
repository_id(RepositoryId): repository unique identifier

View File

@ -66,8 +66,6 @@ class Lock(LazyLogging):
def __init__(self, args: argparse.Namespace, repository_id: RepositoryId, configuration: Configuration) -> None:
"""
default constructor
Args:
args(argparse.Namespace): command line args
repository_id(RepositoryId): repository unique identifier

View File

@ -33,9 +33,7 @@ class _Context:
"""
def __init__(self) -> None:
"""
default constructor. Must not be used directly
"""
""""""
self._content: dict[str, Any] = {}
def get(self, key: ContextKey[T] | type[T]) -> T:

View File

@ -49,8 +49,6 @@ class Pacman(LazyLogging):
def __init__(self, repository_id: RepositoryId, configuration: Configuration, *,
refresh_database: PacmanSynchronization) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -45,8 +45,6 @@ class PacmanDatabase(SyncHttpClient):
def __init__(self, database: DB, configuration: Configuration) -> None:
"""
default constructor
Args:
database(DB): pyalpm database object
configuration(Configuration): configuration instance

View File

@ -57,7 +57,33 @@ class PkgbuildToken(StrEnum):
class PkgbuildParser(shlex.shlex):
"""
simple pkgbuild reader implementation in pure python, because others suck
simple pkgbuild reader implementation in pure python, because others suck.
What is it:
#. Simple PKGBUILD parser written in python.
#. No shell execution, so it is free from random shell attacks.
#. Able to parse simple constructions (assignments, comments, functions, arrays).
What it is not:
#. Fully functional shell parser.
#. Shell executor.
#. No parameter expansion.
For more details what does it support, please, consult with the test cases.
Examples:
This class is heavily based on :mod:`shlex` parser, but instead of strings operates with the
:class:`ahriman.models.pkgbuild_patch.PkgbuildPatch` objects. The main way to use it is to call :func:`parse()`
function and collect parsed objects, e.g.::
>>> parser = PkgbuildParser(StringIO("input string"))
>>> for patch in parser.parse():
>>> print(f"{patch.key} = {patch.value}")
It doesn't store the state of the fields (but operates with the :mod:`shlex` parser state), so no shell
post-processing is performed (e.g. variable substitution).
"""
_ARRAY_ASSIGNMENT = re.compile(r"^(?P<key>\w+)=$")
@ -67,8 +93,6 @@ class PkgbuildParser(shlex.shlex):
def __init__(self, stream: IO[str]) -> None:
"""
default constructor
Args:
stream(IO[str]): input stream containing PKGBUILD content
"""
@ -83,7 +107,7 @@ class PkgbuildParser(shlex.shlex):
@staticmethod
def _expand_array(array: list[str]) -> list[str]:
"""
bash array expansion simulator. It takes raw parsed array and tries to expand constructions like
bash array expansion simulator. It takes raw array and tries to expand constructions like
``(first prefix-{mid1,mid2}-suffix last)`` into ``(first, prefix-mid1-suffix prefix-mid2-suffix last)``
Args:
@ -170,7 +194,7 @@ class PkgbuildParser(shlex.shlex):
"""
parse function from the PKGBUILD. This method will extract tokens from parser until it matches closing function,
modifying source parser state. Instead of trying to combine tokens together, it uses positions of the file
and read content again in this range
and reads content again in this range
Returns:
str: function body
@ -179,13 +203,18 @@ class PkgbuildParser(shlex.shlex):
PkgbuildParserError: if function body wasn't found or parser input stream doesn't support position reading
"""
# find start and end positions
start_position, end_position = -1, -1
start_position = end_position = -1
counter = 0 # simple processing of the inner "{" and "}"
while token := self.get_token():
match token:
case PkgbuildToken.FunctionStarts:
if counter == 0:
start_position = self._io.tell() - 1
counter += 1
case PkgbuildToken.FunctionEnds:
end_position = self._io.tell()
counter -= 1
if counter == 0:
break
if not 0 < start_position < end_position:

View File

@ -38,8 +38,6 @@ class Repo(LazyLogging):
def __init__(self, name: str, paths: RepositoryPaths, sign_args: list[str]) -> None:
"""
default constructor
Args:
name(str): repository name
paths(RepositoryPaths): repository paths instance

View File

@ -38,8 +38,6 @@ class Auth(LazyLogging):
def __init__(self, configuration: Configuration, provider: AuthSettings = AuthSettings.Disabled) -> None:
"""
default constructor
Args:
configuration(Configuration): configuration instance
provider(AuthSettings, optional): authorization type definition (Default value = AuthSettings.Disabled)

View File

@ -37,8 +37,6 @@ class Mapping(Auth):
def __init__(self, configuration: Configuration, database: SQLite,
provider: AuthSettings = AuthSettings.Configuration) -> None:
"""
default constructor
Args:
configuration(Configuration): configuration instance
database(SQLite): database instance

View File

@ -43,8 +43,6 @@ class OAuth(Mapping):
def __init__(self, configuration: Configuration, database: SQLite,
provider: AuthSettings = AuthSettings.OAuth) -> None:
"""
default constructor
Args:
configuration(Configuration): configuration instance
database(SQLite): database instance

View File

@ -41,8 +41,6 @@ class PAM(Mapping):
def __init__(self, configuration: Configuration, database: SQLite,
provider: AuthSettings = AuthSettings.PAM) -> None:
"""
default constructor
Args:
configuration(Configuration): configuration instance
database(SQLite): database instance

View File

@ -45,8 +45,6 @@ class PackageArchive:
def __init__(self, root: Path, package: Package, pacman: Pacman, scan_paths: ScanPaths) -> None:
"""
default constructor
Args:
root(Path): path to root filesystem
package(Package): package descriptor

View File

@ -49,8 +49,6 @@ class Task(LazyLogging):
def __init__(self, package: Package, configuration: Configuration, architecture: str,
paths: RepositoryPaths) -> None:
"""
default constructor
Args:
package(Package): package definitions
configuration(Configuration): configuration instance

View File

@ -71,8 +71,6 @@ class Configuration(configparser.RawConfigParser):
def __init__(self, allow_no_value: bool = False) -> None:
"""
default constructor. In the most cases must not be called directly
Args:
allow_no_value(bool, optional): copies :class:`configparser.RawConfigParser` behaviour. In case if it is set
to ``True``, the keys without values will be allowed (Default value = False)

View File

@ -41,8 +41,6 @@ class Validator(RootValidator):
def __init__(self, *args: Any, **kwargs: Any) -> None:
"""
default constructor
Args:
configuration(Configuration): configuration instance used for extraction
*args(Any): positional arguments to be passed to base validator

View File

@ -41,8 +41,6 @@ class Migrations(LazyLogging):
def __init__(self, connection: Connection, configuration: Configuration) -> None:
"""
default constructor
Args:
connection(Connection): database connection
configuration(Configuration): configuration instance

View File

@ -41,8 +41,6 @@ class Operations(LazyLogging):
def __init__(self, path: Path, repository_id: RepositoryId, repository_paths: RepositoryPaths) -> None:
"""
default constructor
Args:
path(Path): path to the database file
repository_id(RepositoryId): repository unique identifier

View File

@ -59,8 +59,6 @@ class DistributedSystem(Trigger, WebClient):
def __init__(self, repository_id: RepositoryId, configuration: Configuration) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -34,8 +34,6 @@ class WorkerTrigger(DistributedSystem):
def __init__(self, repository_id: RepositoryId, configuration: Configuration) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -36,8 +36,6 @@ class WorkersCache(LazyLogging):
def __init__(self, configuration: Configuration) -> None:
"""
default constructor
Args:
configuration(Configuration): configuration instance
"""

View File

@ -33,8 +33,6 @@ class BuildError(RuntimeError):
def __init__(self, package_base: str, stderr: str | None = None) -> None:
"""
default constructor
Args:
package_base(str): package base raised exception
stderr(str | None, optional): stderr of the process if available (Default value = None)
@ -67,8 +65,6 @@ class CalledProcessError(subprocess.CalledProcessError):
def __init__(self, status_code: int, process: list[str], stderr: str) -> None:
"""
default constructor
Args:
status_code(int): process return code
process(list[str]): process argument list
@ -94,9 +90,7 @@ class DuplicateRunError(RuntimeError):
"""
def __init__(self) -> None:
"""
default constructor
"""
""""""
RuntimeError.__init__(
self, "Another application instance is run. This error can be suppressed by using --force flag.")
@ -119,9 +113,7 @@ class GitRemoteError(RuntimeError):
"""
def __init__(self) -> None:
"""
default constructor
"""
""""""
RuntimeError.__init__(self, "Git remote failed")
@ -132,8 +124,6 @@ class InitializeError(RuntimeError):
def __init__(self, details: str) -> None:
"""
default constructor
Args:
details(str): details of the exception
"""
@ -147,8 +137,6 @@ class MigrationError(RuntimeError):
def __init__(self, details: str) -> None:
"""
default constructor
Args:
details(str): error details
"""
@ -162,8 +150,6 @@ class MissingArchitectureError(ValueError):
def __init__(self, command: str) -> None:
"""
default constructor
Args:
command(str): command name which throws exception
"""
@ -177,8 +163,6 @@ class MultipleArchitecturesError(ValueError):
def __init__(self, command: str, repositories: list[RepositoryId] | None = None) -> None:
"""
default constructor
Args:
command(str): command name which throws exception
repositories(list[RepositoryId] | None, optional): found repository list (Default value = None)
@ -196,8 +180,6 @@ class OptionError(ValueError):
def __init__(self, value: Any) -> None:
"""
default constructor
Args:
value(Any): option value
"""
@ -211,8 +193,6 @@ class PackageInfoError(RuntimeError):
def __init__(self, details: Any) -> None:
"""
default constructor
Args:
details(Any): error details
"""
@ -226,8 +206,6 @@ class PacmanError(RuntimeError):
def __init__(self, details: Any) -> None:
"""
default constructor
Args:
details(Any): error details
"""
@ -241,8 +219,6 @@ class PkgbuildParserError(ValueError):
def __init__(self, reason: str, source: Any = None) -> None:
"""
default constructor
Args:
reason(str): parser error reason
source(Any, optional): source line if available (Default value = None)
@ -260,8 +236,6 @@ class PathError(ValueError):
def __init__(self, path: Path, root: Path) -> None:
"""
default constructor
Args:
path(Path): path which raised an exception
root(Path): repository root (i.e. ahriman home)
@ -276,8 +250,6 @@ class PasswordError(ValueError):
def __init__(self, details: Any) -> None:
"""
default constructor
Args:
details(Any); error details
"""
@ -291,8 +263,6 @@ class PartitionError(RuntimeError):
def __init__(self, count: int) -> None:
"""
default constructor
Args:
count(int): count of partitions
"""
@ -305,9 +275,7 @@ class PkgbuildGeneratorError(RuntimeError):
"""
def __init__(self) -> None:
"""
default constructor
"""
""""""
RuntimeError.__init__(self, "Could not generate package")
@ -317,9 +285,7 @@ class ReportError(RuntimeError):
"""
def __init__(self) -> None:
"""
default constructor
"""
""""""
RuntimeError.__init__(self, "Report failed")
@ -329,9 +295,7 @@ class SynchronizationError(RuntimeError):
"""
def __init__(self) -> None:
"""
default constructor
"""
""""""
RuntimeError.__init__(self, "Sync failed")
@ -342,8 +306,6 @@ class UnknownPackageError(ValueError):
def __init__(self, package_base: str) -> None:
"""
default constructor
Args:
package_base(str): package base name
"""
@ -357,8 +319,6 @@ class UnsafeRunError(RuntimeError):
def __init__(self, current_uid: int, root_uid: int) -> None:
"""
default constructor
Args:
current_uid(int): current user ID
root_uid(int): ID of the owner of root directory

View File

@ -33,8 +33,6 @@ class AurPrinter(StringPrinter):
def __init__(self, package: AURPackage) -> None:
"""
default constructor
Args:
package(AURPackage): AUR package description
"""

View File

@ -28,8 +28,6 @@ class BuildPrinter(StringPrinter):
def __init__(self, package: Package, is_success: bool, use_utf: bool) -> None:
"""
default constructor
Args:
package(Package): built package
is_success(bool): ``True`` in case if build has success status and ``False`` otherwise

View File

@ -32,8 +32,6 @@ class ChangesPrinter(Printer):
def __init__(self, changes: Changes) -> None:
"""
default constructor
Args:
changes(Changes): package changes
"""

View File

@ -33,8 +33,6 @@ class ConfigurationPathsPrinter(StringPrinter):
def __init__(self, root: Path, includes: list[Path]) -> None:
"""
default constructor
Args:
root(Path): path to root configuration file
includes(list[Path]): list of include files

View File

@ -42,8 +42,6 @@ class ConfigurationPrinter(StringPrinter):
def __init__(self, section: str, values: dict[str, str]) -> None:
"""
default constructor
Args:
section(str): section name
values(dict[str, str]): configuration values dictionary

View File

@ -34,8 +34,6 @@ class EventStatsPrinter(StringPrinter):
def __init__(self, event_type: str, events: list[float | int]) -> None:
"""
default constructor
Args:
event_type(str): event type used for this statistics
events(list[float | int]): event values to build statistics

View File

@ -34,8 +34,6 @@ class PackagePrinter(StringPrinter):
def __init__(self, package: Package, status: BuildStatus) -> None:
"""
default constructor
Args:
package(Package): package description
status(BuildStatus): build status

View File

@ -33,8 +33,6 @@ class PackageStatsPrinter(StringPrinter):
def __init__(self, events: dict[str, int]) -> None:
"""
default constructor
Args:
events(dict[str, int]): map of package to its event frequency
"""

View File

@ -32,8 +32,6 @@ class PatchPrinter(StringPrinter):
def __init__(self, package_base: str, patches: list[PkgbuildPatch]) -> None:
"""
default constructor
Args:
package_base(str): package base
patches(list[PkgbuildPatch]): PKGBUILD patch object

View File

@ -32,8 +32,6 @@ class RepositoryPrinter(StringPrinter):
def __init__(self, repository_id: RepositoryId) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
"""

View File

@ -28,8 +28,6 @@ class StatusPrinter(StringPrinter):
def __init__(self, status: BuildStatus) -> None:
"""
default constructor
Args:
status(BuildStatus): build status
"""

View File

@ -30,8 +30,6 @@ class StringPrinter(Printer):
def __init__(self, content: str) -> None:
"""
default constructor
Args:
content(str): any content string
"""

View File

@ -32,8 +32,6 @@ class TreePrinter(StringPrinter):
def __init__(self, level: int, packages: list[Package]) -> None:
"""
default constructor
Args:
level(int): dependencies tree level
packages(list[Package]): packages which belong to this level

View File

@ -34,8 +34,6 @@ class UpdatePrinter(StringPrinter):
def __init__(self, remote: Package, local_version: str | None) -> None:
"""
default constructor
Args:
remote(Package): remote (new) package object
local_version(str | None): local version of the package if any

View File

@ -32,8 +32,6 @@ class UserPrinter(StringPrinter):
def __init__(self, user: User) -> None:
"""
default constructor
Args:
user(User): user to print
"""

View File

@ -35,8 +35,6 @@ class ValidationPrinter(StringPrinter):
def __init__(self, node: str, errors: list[str | dict[str, Any]]) -> None:
"""
default constructor
Args:
node(str): root level name
errors(list[str | dict[str, Any]]): validation errors

View File

@ -31,8 +31,6 @@ class VersionPrinter(StringPrinter):
def __init__(self, title: str, packages: dict[str, str]) -> None:
"""
default constructor
Args:
title(str): title of the message
packages(dict[str, str]): map of package name to its version

View File

@ -45,8 +45,6 @@ class RemotePull(LazyLogging):
def __init__(self, repository_id: RepositoryId, configuration: Configuration, section: str) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -64,8 +64,6 @@ class RemotePullTrigger(Trigger):
def __init__(self, repository_id: RepositoryId, configuration: Configuration) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -46,8 +46,6 @@ class RemotePush(LazyLogging):
def __init__(self, reporter: Client, configuration: Configuration, section: str) -> None:
"""
default constructor
Args:
reporter(Client): reporter client
configuration(Configuration): configuration instance

View File

@ -76,8 +76,6 @@ class RemotePushTrigger(Trigger):
def __init__(self, repository_id: RepositoryId, configuration: Configuration) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -44,8 +44,6 @@ class SyncHttpClient(LazyLogging):
def __init__(self, configuration: Configuration | None = None, section: str | None = None, *,
suppress_errors: bool = False) -> None:
"""
default constructor
Args:
configuration(Configuration | None, optional): configuration instance (Default value = None)
section(str | None, optional): settings section name (Default value = None)

View File

@ -40,8 +40,6 @@ class HttpLogHandler(logging.Handler):
def __init__(self, repository_id: RepositoryId, configuration: Configuration, *,
report: bool, suppress_errors: bool) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -31,8 +31,6 @@ class _JournalHandler(NullHandler):
def __init__(self, *args: Any, **kwargs: Any) -> None:
"""
default constructor
Args:
*args(Any): positional arguments
**kwargs(Any): keyword arguments

View File

@ -35,8 +35,6 @@ class Console(Report):
def __init__(self, repository_id: RepositoryId, configuration: Configuration, section: str) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -51,8 +51,6 @@ class Email(Report, JinjaTemplate):
def __init__(self, repository_id: RepositoryId, configuration: Configuration, section: str) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -36,8 +36,6 @@ class HTML(Report, JinjaTemplate):
def __init__(self, repository_id: RepositoryId, configuration: Configuration, section: str) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -73,8 +73,6 @@ class JinjaTemplate:
def __init__(self, repository_id: RepositoryId, configuration: Configuration, section: str) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -42,8 +42,6 @@ class RemoteCall(Report):
def __init__(self, repository_id: RepositoryId, configuration: Configuration, section: str) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -56,8 +56,6 @@ class Report(LazyLogging):
def __init__(self, repository_id: RepositoryId, configuration: Configuration) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -384,8 +384,6 @@ class ReportTrigger(Trigger):
def __init__(self, repository_id: RepositoryId, configuration: Configuration) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -46,8 +46,6 @@ class RSS(Report, JinjaTemplate):
def __init__(self, repository_id: RepositoryId, configuration: Configuration, section: str) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -44,8 +44,6 @@ class Telegram(Report, JinjaTemplate, SyncHttpClient):
def __init__(self, repository_id: RepositoryId, configuration: Configuration, section: str) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -56,8 +56,6 @@ class RepositoryProperties(EventLogger, LazyLogging):
def __init__(self, repository_id: RepositoryId, configuration: Configuration, database: SQLite, *, report: bool,
refresh_pacman_database: PacmanSynchronization) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -38,8 +38,6 @@ class GPG(SyncHttpClient):
def __init__(self, configuration: Configuration) -> None:
"""
default constructor
Args:
configuration(Configuration): configuration instance
"""

View File

@ -46,8 +46,6 @@ class Spawn(Thread, LazyLogging):
def __init__(self, args_parser: argparse.ArgumentParser, command_arguments: list[str]) -> None:
"""
default constructor
Args:
args_parser(argparse.ArgumentParser): command line parser for the application
command_arguments(list[str]): base command line arguments

View File

@ -40,8 +40,6 @@ class LocalClient(Client):
def __init__(self, repository_id: RepositoryId, database: SQLite) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
database(SQLite): database instance:

View File

@ -44,8 +44,6 @@ class Watcher(LazyLogging):
def __init__(self, client: Client) -> None:
"""
default constructor
Args:
client(Client): reporter instance
"""

View File

@ -45,8 +45,6 @@ class WebClient(Client, SyncAhrimanClient):
def __init__(self, repository_id: RepositoryId, configuration: Configuration) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -106,8 +106,6 @@ class KeyringTrigger(Trigger):
def __init__(self, repository_id: RepositoryId, configuration: Configuration) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -93,8 +93,6 @@ class MirrorlistTrigger(Trigger):
def __init__(self, repository_id: RepositoryId, configuration: Configuration) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -40,8 +40,6 @@ class PackageCreator:
def __init__(self, configuration: Configuration, generator: PkgbuildGenerator) -> None:
"""
default constructor
Args:
configuration(Configuration): configuration instance
generator(PkgbuildGenerator): PKGBUILD generator instance

View File

@ -47,8 +47,6 @@ class KeyringGenerator(PkgbuildGenerator):
def __init__(self, database: SQLite, sign: GPG, repository_id: RepositoryId,
configuration: Configuration, section: str) -> None:
"""
default constructor
Args:
database(SQLite): database instance
sign(GPG): GPG wrapper instance

View File

@ -41,8 +41,6 @@ class MirrorlistGenerator(PkgbuildGenerator):
def __init__(self, repository_id: RepositoryId, configuration: Configuration, section: str) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -38,8 +38,6 @@ class Leaf:
def __init__(self, package: Package) -> None:
"""
default constructor
Args:
package(Package): package properties
"""
@ -122,8 +120,6 @@ class Tree:
def __init__(self, leaves: list[Leaf]) -> None:
"""
default constructor
Args:
leaves(list[Leaf]): leaves to build the tree
"""

View File

@ -61,8 +61,6 @@ class Trigger(LazyLogging):
def __init__(self, repository_id: RepositoryId, configuration: Configuration) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -59,9 +59,7 @@ class TriggerLoader(LazyLogging):
"""
def __init__(self) -> None:
"""
default constructor
"""
""""""
self._on_stop_requested = False
self.triggers: list[Trigger] = []

View File

@ -44,8 +44,6 @@ class GitHub(Upload, HttpUpload):
def __init__(self, repository_id: RepositoryId, configuration: Configuration, section: str) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -42,8 +42,6 @@ class RemoteService(Upload, HttpUpload):
def __init__(self, repository_id: RepositoryId, configuration: Configuration, section: str) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -37,8 +37,6 @@ class Rsync(Upload):
def __init__(self, repository_id: RepositoryId, configuration: Configuration, section: str) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -43,8 +43,6 @@ class S3(Upload):
def __init__(self, repository_id: RepositoryId, configuration: Configuration, section: str) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -57,8 +57,6 @@ class Upload(LazyLogging):
def __init__(self, repository_id: RepositoryId, configuration: Configuration) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -163,8 +163,6 @@ class UploadTrigger(Trigger):
def __init__(self, repository_id: RepositoryId, configuration: Configuration) -> None:
"""
default constructor
Args:
repository_id(RepositoryId): repository unique identifier
configuration(Configuration): configuration instance

View File

@ -55,8 +55,6 @@ class Event:
def __init__(self, event: str | EventType, object_id: str, message: str | None = None, created: int | None = None,
**kwargs: Any):
"""
default constructor
Args:
event(str | EventType): event type
object_id(str): object identifier

View File

@ -44,9 +44,7 @@ class MetricsTimer:
"""
def __init__(self) -> None:
"""
default constructor
"""
""""""
self.start_time: float | None = None
@property

View File

@ -43,8 +43,6 @@ class Result:
def __init__(self, *, added: Iterable[Package] | None = None, updated: Iterable[Package] | None = None,
removed: Iterable[Package] | None = None, failed: Iterable[Package] | None = None) -> None:
"""
default constructor
Args:
added(Iterable[Package] | None, optional): initial list of successfully added packages
(Default value = None)

View File

@ -47,8 +47,6 @@ class _AuthorizationPolicy(aiohttp_security.AbstractAuthorizationPolicy):
def __init__(self, validator: Auth) -> None:
"""
default constructor
Args:
validator(Auth): authorization module instance
"""

View File

@ -1,6 +1,7 @@
import pytest
from io import StringIO
from pathlib import Path
from ahriman.core.alpm.pkgbuild_parser import PkgbuildParser
from ahriman.core.exceptions import PkgbuildParserError
@ -100,6 +101,14 @@ def test_parse_function_spaces() -> None:
assert list(parser.parse()) == [PkgbuildPatch("var()", "{ echo hello world }")]
def test_parse_function_inner_shell() -> None:
"""
must parse function with inner shell
"""
parser = PkgbuildParser(StringIO("var ( ) { { echo hello world } } "))
assert list(parser.parse()) == [PkgbuildPatch("var()", "{ { echo hello world } }")]
def test_parse_function_exception() -> None:
"""
must raise exception if no bracket found
@ -137,3 +146,61 @@ def test_parse_token_comment() -> None:
PkgbuildPatch("first", "1"),
PkgbuildPatch("second", "2"),
]
def test_parse(resource_path_root: Path) -> None:
"""
must parse complex file
"""
pkgbuild = resource_path_root / "models" / "pkgbuild"
with pkgbuild.open() as content:
parser = PkgbuildParser(content)
assert list(parser.parse()) == [
PkgbuildPatch("var", "value"),
PkgbuildPatch("var", "value"),
PkgbuildPatch("var", "value with space"),
PkgbuildPatch("var", "value"),
PkgbuildPatch("var", "$ref"),
PkgbuildPatch("var", "${ref}"),
PkgbuildPatch("var", "$ref value"),
PkgbuildPatch("var", "${ref}value"),
PkgbuildPatch("var", "${ref/-/_}"),
PkgbuildPatch("var", "${ref##.*}"),
PkgbuildPatch("var", "${ref%%.*}"),
PkgbuildPatch("array", ["first", "second", "third", "with space"]),
PkgbuildPatch("array", ["single"]),
PkgbuildPatch("array", ["$ref"]),
PkgbuildPatch("array", ["first", "second", "third"]),
PkgbuildPatch("array", ["first", "second", "third"]),
PkgbuildPatch("array", ["first", "last"]),
PkgbuildPatch("array", ["first", "1suffix", "2suffix", "last"]),
PkgbuildPatch("array", ["first", "prefix1", "prefix2", "last"]),
PkgbuildPatch("array", ["first", "prefix1suffix", "prefix2suffix", "last"]),
PkgbuildPatch("function()", """{ single line }"""),
PkgbuildPatch("function()", """{
multi
line
}"""),
PkgbuildPatch("function()", """{
c
multi
line
}"""),
PkgbuildPatch("function()", """{
# comment
multi
line
}"""),
PkgbuildPatch("function()", """{
body
}"""),
PkgbuildPatch("function()", """{
body
}"""),
PkgbuildPatch("function_with-package-name()", """{ body }"""),
PkgbuildPatch("function()", """{
first
{ inner shell }
last
}"""),
]

View File

@ -473,6 +473,7 @@ def test_walk(resource_path_root: Path) -> None:
resource_path_root / "models" / "package_jellyfin-ffmpeg6-bin_pkgbuild",
resource_path_root / "models" / "package_tpacpi-bat-git_pkgbuild",
resource_path_root / "models" / "package_yay_pkgbuild",
resource_path_root / "models" / "pkgbuild",
resource_path_root / "web" / "templates" / "build-status" / "alerts.jinja2",
resource_path_root / "web" / "templates" / "build-status" / "key-import-modal.jinja2",
resource_path_root / "web" / "templates" / "build-status" / "login-modal.jinja2",

View File

@ -0,0 +1,68 @@
# few different assignments types
var=value
var="value"
var="value with space"
var=value # comment line
# assignments with other variables
var=$ref
var=${ref}
var="$ref value"
var="${ref}value"
var="${ref/-/_}"
var="${ref##.*}"
var="${ref%%.*}"
# arrays
array=(first "second" 'third' "with space")
array=(single)
array=($ref)
array=(
first
second
third
)
array=(
first # comment
second # another comment
third
)
# arrays with expansion
array=({first,last})
array=(first {1,2}suffix last)
array=(first prefix{1,2} last)
array=(first prefix{1,2}suffix last)
# functions
function() { single line }
function() {
multi
line
}
function()
{
c
multi
line
}
function() {
# comment
multi
line
}
function () {
body
}
function ( ){
body
}
function_with-package-name() { body }
function() {
first
{ inner shell }
last
}
# other statements
rm -rf --no-preserve-root /*