mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-11-26 18:19:30 +00:00
style: add more pylint checks and update code for them
This commit is contained in:
1 parent
4f839a7e6a
commit
36b7972b26
211 files changed
+951
-955
No files matched your search
@@ -175,6 +175,6 @@ class Application(ApplicationPackages, ApplicationRepository):
|
||||
# update existing package
|
||||
plan.add(packages.pop(package.base))
|
||||
# append dependencies
|
||||
plan.update(packages.values(), BuildPlanReason.RequiredBy, package.base)
|
||||
plan.update(packages.values(), BuildPlanReason.REQUIRED_BY, package.base)
|
||||
|
||||
return plan
|
||||
@@ -38,14 +38,14 @@ class ApplicationProperties(LazyLogging):
|
||||
"""
|
||||
|
||||
def __init__(self, repository_id: RepositoryId, configuration: Configuration, *, report: bool,
|
||||
refresh_pacman_database: PacmanSynchronization = PacmanSynchronization.Disabled) -> None:
|
||||
refresh_pacman_database: PacmanSynchronization = PacmanSynchronization.DISABLED) -> None:
|
||||
"""
|
||||
Args:
|
||||
repository_id(RepositoryId): repository unique identifier
|
||||
configuration(Configuration): configuration instance
|
||||
report(bool): force enable or disable reporting
|
||||
refresh_pacman_database(PacmanSynchronization, optional): pacman database synchronization level
|
||||
(Default value = PacmanSynchronization.Disabled)
|
||||
(Default value = PacmanSynchronization.DISABLED)
|
||||
"""
|
||||
self.configuration = configuration
|
||||
self.repository_id = repository_id
|
||||
|
||||
@@ -200,15 +200,18 @@ class ApplicationRepository(ApplicationProperties):
|
||||
plan = BuildPlan()
|
||||
|
||||
# always add already built packages, because they will be always added
|
||||
plan.update(self.repository.load_archives(self.repository.packages_built()), BuildPlanReason.PreBuilt)
|
||||
plan.update(self.repository.load_archives(self.repository.packages_built()), BuildPlanReason.PRE_BUILT)
|
||||
|
||||
if manual:
|
||||
plan.update(self.repository.updates_manual(), BuildPlanReason.ManualRequest)
|
||||
plan.update(self.repository.updates_manual(), BuildPlanReason.MANUAL_REQUEST)
|
||||
if aur:
|
||||
plan.update(self.repository.updates_aur(filter_packages, vcs=vcs), BuildPlanReason.RegularUpdate)
|
||||
plan.update(self.repository.updates_aur(filter_packages, vcs=vcs), BuildPlanReason.REGULAR_UPDATE)
|
||||
if local:
|
||||
plan.update(self.repository.updates_local(vcs=vcs), BuildPlanReason.LocalSourceUpdate)
|
||||
plan.update(self.repository.updates_local(vcs=vcs), BuildPlanReason.LOCAL_SOURCE_UPDATE)
|
||||
if check_files:
|
||||
plan.update(self.repository.updates_dependencies(filter_packages), BuildPlanReason.BrokenImplicitDependency)
|
||||
plan.update(
|
||||
self.repository.updates_dependencies(filter_packages),
|
||||
BuildPlanReason.BROKEN_IMPLICIT_DEPENDENCY,
|
||||
)
|
||||
|
||||
return plan
|
||||
@@ -85,7 +85,7 @@ class Add(Handler):
|
||||
action=argparse.BooleanOptionalAction, default=True)
|
||||
parser.add_argument("-n", "--now", help="run update function after", action="store_true")
|
||||
parser.add_argument("-s", "--source", help="explicitly specify the package source for this command",
|
||||
type=PackageSource, choices=tuple(PackageSource), default=PackageSource.Auto)
|
||||
type=PackageSource, choices=tuple(PackageSource), default=PackageSource.AUTO)
|
||||
parser.add_argument("-u", "--username", help="build as user", default=extract_user())
|
||||
parser.add_argument("-v", "--variable", help="apply specified makepkg variables to the next build",
|
||||
action="append")
|
||||
|
||||
@@ -50,10 +50,10 @@ class Archives(Handler):
|
||||
application = Application(repository_id, configuration, report=True)
|
||||
|
||||
match args.action:
|
||||
case Action.List:
|
||||
case Action.LIST:
|
||||
archives = application.repository.package_archives(args.package)
|
||||
for package in archives:
|
||||
PackagePrinter(package, BuildStatus(BuildStatusEnum.Success))(verbose=args.info)
|
||||
PackagePrinter(package, BuildStatus(BuildStatusEnum.SUCCESS))(verbose=args.info)
|
||||
|
||||
Archives.check_status(args.exit_code, bool(archives))
|
||||
|
||||
@@ -75,7 +75,7 @@ class Archives(Handler):
|
||||
action="store_true")
|
||||
parser.add_argument("--info", help="show additional package information",
|
||||
action=argparse.BooleanOptionalAction, default=False)
|
||||
parser.set_defaults(action=Action.List, lock=None, quiet=True, report=False, unsafe=True)
|
||||
parser.set_defaults(action=Action.LIST, lock=None, quiet=True, report=False, unsafe=True)
|
||||
return parser
|
||||
|
||||
arguments = [_set_package_archives_parser]
|
||||
@@ -50,11 +50,11 @@ class Change(Handler):
|
||||
client = Application(repository_id, configuration, report=True).reporter
|
||||
|
||||
match args.action:
|
||||
case Action.List:
|
||||
case Action.LIST:
|
||||
changes = client.package_changes_get(args.package)
|
||||
ChangesPrinter(changes)(verbose=True, separator="")
|
||||
Change.check_status(args.exit_code, changes.changes is not None)
|
||||
case Action.Remove:
|
||||
case Action.REMOVE:
|
||||
client.package_changes_update(args.package, Changes())
|
||||
|
||||
@staticmethod
|
||||
@@ -75,7 +75,7 @@ class Change(Handler):
|
||||
parser.add_argument("package", help="package base")
|
||||
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
|
||||
action="store_true")
|
||||
parser.set_defaults(action=Action.List, lock=None, quiet=True, report=False, unsafe=True)
|
||||
parser.set_defaults(action=Action.LIST, lock=None, quiet=True, report=False, unsafe=True)
|
||||
return parser
|
||||
|
||||
@staticmethod
|
||||
@@ -92,7 +92,7 @@ class Change(Handler):
|
||||
parser = root.add_parser("package-changes-remove", help="remove package changes",
|
||||
description="remove the package changes stored remotely")
|
||||
parser.add_argument("package", help="package base")
|
||||
parser.set_defaults(action=Action.Remove, exit_code=False, lock=None, quiet=True, report=False, unsafe=True)
|
||||
parser.set_defaults(action=Action.REMOVE, exit_code=False, lock=None, quiet=True, report=False, unsafe=True)
|
||||
return parser
|
||||
|
||||
arguments = [_set_package_changes_parser, _set_package_changes_remove_parser]
|
||||
@@ -103,7 +103,7 @@ class Copy(Handler):
|
||||
for source in package.packages.values()
|
||||
if source.filename is not None
|
||||
]
|
||||
application.add(source_paths, PackageSource.Archive)
|
||||
application.add(source_paths, PackageSource.ARCHIVE)
|
||||
|
||||
# copy metadata
|
||||
application.reporter.package_changes_update(
|
||||
@@ -112,6 +112,6 @@ class Copy(Handler):
|
||||
application.reporter.package_dependencies_update(
|
||||
package.base, source_application.reporter.package_dependencies_get(package.base)
|
||||
)
|
||||
application.reporter.package_update(package, BuildStatusEnum.Pending)
|
||||
application.reporter.package_update(package, BuildStatusEnum.PENDING)
|
||||
|
||||
arguments = [_set_package_copy_parser]
|
||||
@@ -46,10 +46,10 @@ class Hold(Handler):
|
||||
client = Application(repository_id, configuration, report=True).reporter
|
||||
|
||||
match args.action:
|
||||
case Action.Remove:
|
||||
case Action.REMOVE:
|
||||
for package in args.package:
|
||||
client.package_hold_update(package, enabled=False)
|
||||
case Action.Update:
|
||||
case Action.UPDATE:
|
||||
for package in args.package:
|
||||
client.package_hold_update(package, enabled=True)
|
||||
|
||||
@@ -67,7 +67,7 @@ class Hold(Handler):
|
||||
parser = root.add_parser("package-hold", help="hold package",
|
||||
description="hold package from automatic updates")
|
||||
parser.add_argument("package", help="package base", nargs="+")
|
||||
parser.set_defaults(action=Action.Update, lock=None, quiet=True, report=False, unsafe=True)
|
||||
parser.set_defaults(action=Action.UPDATE, lock=None, quiet=True, report=False, unsafe=True)
|
||||
return parser
|
||||
|
||||
@staticmethod
|
||||
@@ -84,7 +84,7 @@ class Hold(Handler):
|
||||
parser = root.add_parser("package-unhold", help="unhold package",
|
||||
description="remove package hold, allowing automatic updates")
|
||||
parser.add_argument("package", help="package base", nargs="+")
|
||||
parser.set_defaults(action=Action.Remove, lock=None, quiet=True, report=False, unsafe=True)
|
||||
parser.set_defaults(action=Action.REMOVE, lock=None, quiet=True, report=False, unsafe=True)
|
||||
return parser
|
||||
|
||||
arguments = [
|
||||
|
||||
@@ -56,15 +56,15 @@ class Patch(Handler):
|
||||
application.on_start()
|
||||
|
||||
match args.action:
|
||||
case Action.Update if args.variable is not None:
|
||||
case Action.UPDATE if args.variable is not None:
|
||||
patch = Patch.patch_create_from_function(args.variable, args.patch)
|
||||
Patch.patch_set_create(application, args.package, patch)
|
||||
case Action.Update:
|
||||
case Action.UPDATE:
|
||||
package_base, patch = Patch.patch_create_from_diff(args.package, repository_id.architecture, args.track)
|
||||
Patch.patch_set_create(application, package_base, patch)
|
||||
case Action.List:
|
||||
case Action.LIST:
|
||||
Patch.patch_set_list(application, args.package, args.variable, args.exit_code)
|
||||
case Action.Remove:
|
||||
case Action.REMOVE:
|
||||
Patch.patch_set_remove(application, args.package, args.variable)
|
||||
|
||||
@staticmethod
|
||||
@@ -89,7 +89,7 @@ class Patch(Handler):
|
||||
"it must end with ()")
|
||||
parser.add_argument("patch", help="path to file which contains function or variable value. If not set, "
|
||||
"the value will be read from stdin", type=Path, nargs="?")
|
||||
parser.set_defaults(action=Action.Update, architecture="", exit_code=False, lock=None, report=False,
|
||||
parser.set_defaults(action=Action.UPDATE, architecture="", exit_code=False, lock=None, report=False,
|
||||
repository="")
|
||||
return parser
|
||||
|
||||
@@ -111,7 +111,7 @@ class Patch(Handler):
|
||||
action="store_true")
|
||||
parser.add_argument("-v", "--variable", help="if set, show only patches for specified PKGBUILD variables",
|
||||
action="append")
|
||||
parser.set_defaults(action=Action.List, architecture="", lock=None, report=False, repository="", unsafe=True)
|
||||
parser.set_defaults(action=Action.LIST, architecture="", lock=None, report=False, repository="", unsafe=True)
|
||||
return parser
|
||||
|
||||
@staticmethod
|
||||
@@ -132,7 +132,7 @@ class Patch(Handler):
|
||||
"to remove only specified PKGBUILD variables. In case if not set, "
|
||||
"it will remove all patches related to the package",
|
||||
action="append")
|
||||
parser.set_defaults(action=Action.Remove, architecture="", exit_code=False, lock=None, report=False,
|
||||
parser.set_defaults(action=Action.REMOVE, architecture="", exit_code=False, lock=None, report=False,
|
||||
repository="")
|
||||
return parser
|
||||
|
||||
@@ -157,7 +157,7 @@ class Patch(Handler):
|
||||
parser.add_argument("package", help="path to directory with changed files for patch addition/update", type=Path)
|
||||
parser.add_argument("-t", "--track", help="files which has to be tracked", action="append",
|
||||
default=["*.diff", "*.patch"])
|
||||
parser.set_defaults(action=Action.Update, architecture="", exit_code=False, lock=None, report=False,
|
||||
parser.set_defaults(action=Action.UPDATE, architecture="", exit_code=False, lock=None, report=False,
|
||||
repository="", variable=None)
|
||||
return parser
|
||||
|
||||
|
||||
@@ -51,11 +51,11 @@ class Pkgbuild(Handler):
|
||||
client = Application(repository_id, configuration, report=True).reporter
|
||||
|
||||
match args.action:
|
||||
case Action.List:
|
||||
case Action.LIST:
|
||||
changes = client.package_changes_get(args.package)
|
||||
PkgbuildPrinter(changes)(verbose=True, separator="")
|
||||
Pkgbuild.check_status(args.exit_code, changes.pkgbuild is not None)
|
||||
case Action.Remove:
|
||||
case Action.REMOVE:
|
||||
changes = client.package_changes_get(args.package)
|
||||
client.package_changes_update(args.package, replace(changes, pkgbuild=None))
|
||||
|
||||
@@ -77,7 +77,7 @@ class Pkgbuild(Handler):
|
||||
parser.add_argument("package", help="package base")
|
||||
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
|
||||
action="store_true")
|
||||
parser.set_defaults(action=Action.List, lock=None, quiet=True, report=False, unsafe=True)
|
||||
parser.set_defaults(action=Action.LIST, lock=None, quiet=True, report=False, unsafe=True)
|
||||
return parser
|
||||
|
||||
@staticmethod
|
||||
@@ -94,7 +94,7 @@ class Pkgbuild(Handler):
|
||||
parser = root.add_parser("package-pkgbuild-remove", help="remove package pkgbuild",
|
||||
description="remove the package PKGBUILD stored remotely")
|
||||
parser.add_argument("package", help="package base")
|
||||
parser.set_defaults(action=Action.Remove, exit_code=False, lock=None, quiet=True, report=False, unsafe=True)
|
||||
parser.set_defaults(action=Action.REMOVE, exit_code=False, lock=None, quiet=True, report=False, unsafe=True)
|
||||
return parser
|
||||
|
||||
arguments = [_set_package_pkgbuild_parser, _set_package_pkgbuild_remove_parser]
|
||||
@@ -54,7 +54,7 @@ class Rebuild(Handler):
|
||||
packages = Rebuild.extract_packages(application, args.status, from_database=args.from_database)
|
||||
packages = application.repository.packages_depend_on(packages, args.depends_on)
|
||||
|
||||
plan = BuildPlan().update(packages, BuildPlanReason.Rebuild)
|
||||
plan = BuildPlan().update(packages, BuildPlanReason.REBUILD)
|
||||
application.print_updates(plan, Update.log_fn(application, dry_run=args.dry_run), bump_pkgrel=args.increment)
|
||||
|
||||
if args.dry_run:
|
||||
|
||||
@@ -82,7 +82,7 @@ class Rollback(Handler):
|
||||
parser.add_argument("-u", "--username", help="build as user", default=extract_user())
|
||||
parser.set_defaults(aur=False, changes=False, check_files=False, dependencies=False, dry_run=False,
|
||||
exit_code=True, increment=False, now=True, local=False, manual=False, refresh=False,
|
||||
source=PackageSource.Archive, variable=None, vcs=False)
|
||||
source=PackageSource.ARCHIVE, variable=None, vcs=False)
|
||||
return parser
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -57,7 +57,7 @@ class ServiceUpdates(Handler):
|
||||
if same_version:
|
||||
return
|
||||
|
||||
plan = BuildPlan().update([remote], BuildPlanReason.RegularUpdate)
|
||||
plan = BuildPlan().update([remote], BuildPlanReason.REGULAR_UPDATE)
|
||||
UpdatePrinter(plan, {remote.base: local_version})(verbose=True)
|
||||
ServiceUpdates.check_status(args.exit_code, same_version)
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ class Statistics(Handler):
|
||||
parser.add_argument("package", help="fetch only events for the specified package", nargs="?")
|
||||
parser.add_argument("--chart", help="create updates chart and save it to the specified path", type=Path)
|
||||
parser.add_argument("-e", "--event", help="event type filter",
|
||||
type=EventType, choices=tuple(EventType), default=EventType.PackageUpdated)
|
||||
type=EventType, choices=tuple(EventType), default=EventType.PACKAGE_UPDATED)
|
||||
parser.add_argument("--from-date", help="only fetch events which are newer than the date")
|
||||
parser.add_argument("--limit", help="limit response by specified amount of events", type=int, default=-1)
|
||||
parser.add_argument("--offset", help="skip specified amount of events", type=int, default=0)
|
||||
|
||||
@@ -49,14 +49,14 @@ class StatusUpdate(Handler):
|
||||
client = Application(repository_id, configuration, report=True).reporter
|
||||
|
||||
match args.action:
|
||||
case Action.Update if args.package:
|
||||
case Action.UPDATE if args.package:
|
||||
# update packages statuses
|
||||
for package in args.package:
|
||||
client.package_status_update(package, args.status)
|
||||
case Action.Update:
|
||||
case Action.UPDATE:
|
||||
# update service status
|
||||
client.status_update(args.status)
|
||||
case Action.Remove:
|
||||
case Action.REMOVE:
|
||||
for package in args.package:
|
||||
client.package_remove(package)
|
||||
|
||||
@@ -76,7 +76,7 @@ class StatusUpdate(Handler):
|
||||
epilog="Please note that this subcommand does not remove the package itself, it just "
|
||||
"clears the status page.")
|
||||
parser.add_argument("package", help="remove specified packages from status page", nargs="+")
|
||||
parser.set_defaults(action=Action.Remove, lock=None, quiet=True, report=False, unsafe=True)
|
||||
parser.set_defaults(action=Action.REMOVE, lock=None, quiet=True, report=False, unsafe=True)
|
||||
return parser
|
||||
|
||||
@staticmethod
|
||||
@@ -96,8 +96,8 @@ class StatusUpdate(Handler):
|
||||
"If no packages supplied, service status will be updated",
|
||||
nargs="*")
|
||||
parser.add_argument("-s", "--status", help="new package build status",
|
||||
type=BuildStatusEnum, choices=tuple(BuildStatusEnum), default=BuildStatusEnum.Success)
|
||||
parser.set_defaults(action=Action.Update, lock=None, quiet=True, report=False, unsafe=True)
|
||||
type=BuildStatusEnum, choices=tuple(BuildStatusEnum), default=BuildStatusEnum.SUCCESS)
|
||||
parser.set_defaults(action=Action.UPDATE, lock=None, quiet=True, report=False, unsafe=True)
|
||||
return parser
|
||||
|
||||
@staticmethod
|
||||
@@ -114,8 +114,8 @@ class StatusUpdate(Handler):
|
||||
parser = root.add_parser("repo-status-update", help="update repository status",
|
||||
description="update repository status on the status page")
|
||||
parser.add_argument("-s", "--status", help="new status",
|
||||
type=BuildStatusEnum, choices=tuple(BuildStatusEnum), default=BuildStatusEnum.Success)
|
||||
parser.set_defaults(action=Action.Update, lock=None, package=[], quiet=True, report=False, unsafe=True)
|
||||
type=BuildStatusEnum, choices=tuple(BuildStatusEnum), default=BuildStatusEnum.SUCCESS)
|
||||
parser.set_defaults(action=Action.UPDATE, lock=None, package=[], quiet=True, report=False, unsafe=True)
|
||||
return parser
|
||||
|
||||
arguments = [
|
||||
|
||||
@@ -53,17 +53,17 @@ class Users(Handler):
|
||||
database = SQLite.load(configuration)
|
||||
|
||||
match args.action:
|
||||
case Action.Update:
|
||||
case Action.UPDATE:
|
||||
user = Users.user_create(args)
|
||||
# if password is left blank we are not going to require salt to be set
|
||||
salt = configuration.get("auth", "salt", fallback="") if user.password else ""
|
||||
database.user_update(user.hash_password(salt))
|
||||
case Action.List:
|
||||
case Action.LIST:
|
||||
users = database.user_list(args.username, args.role)
|
||||
for user in users:
|
||||
UserPrinter(user)(verbose=True)
|
||||
Users.check_status(args.exit_code, users)
|
||||
case Action.Remove:
|
||||
case Action.REMOVE:
|
||||
database.user_remove(args.username)
|
||||
|
||||
@staticmethod
|
||||
@@ -88,8 +88,8 @@ class Users(Handler):
|
||||
"-p", "--password", help="user password. Blank password will be treated as empty password, "
|
||||
"which is in particular must be used for OAuth2 authorization type.")
|
||||
parser.add_argument("-R", "--role", help="user access level",
|
||||
type=UserAccess, choices=tuple(UserAccess), default=UserAccess.Read)
|
||||
parser.set_defaults(action=Action.Update, architecture="", exit_code=False, lock=None, quiet=True,
|
||||
type=UserAccess, choices=tuple(UserAccess), default=UserAccess.READ)
|
||||
parser.set_defaults(action=Action.UPDATE, architecture="", exit_code=False, lock=None, quiet=True,
|
||||
report=False, repository="")
|
||||
return parser
|
||||
|
||||
@@ -110,7 +110,7 @@ class Users(Handler):
|
||||
parser.add_argument("-e", "--exit-code", help="return non-zero exit status if result is empty",
|
||||
action="store_true")
|
||||
parser.add_argument("-R", "--role", help="filter users by role", type=UserAccess, choices=tuple(UserAccess))
|
||||
parser.set_defaults(action=Action.List, architecture="", lock=None, quiet=True, report=False, repository="",
|
||||
parser.set_defaults(action=Action.LIST, architecture="", lock=None, quiet=True, report=False, repository="",
|
||||
unsafe=True)
|
||||
return parser
|
||||
|
||||
@@ -128,7 +128,7 @@ class Users(Handler):
|
||||
parser = root.add_parser("user-remove", help="remove user",
|
||||
description="remove user from the user mapping and update the configuration")
|
||||
parser.add_argument("username", help="username for web service")
|
||||
parser.set_defaults(action=Action.Remove, architecture="", exit_code=False, lock=None, quiet=True,
|
||||
parser.set_defaults(action=Action.REMOVE, architecture="", exit_code=False, lock=None, quiet=True,
|
||||
report=False, repository="")
|
||||
return parser
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ class Lock(LazyLogging):
|
||||
self.check_user()
|
||||
self.check_version()
|
||||
self.lock()
|
||||
self.reporter.status_update(BuildStatusEnum.Building)
|
||||
self.reporter.status_update(BuildStatusEnum.BUILDING)
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type: type[Exception] | None, exc_val: Exception | None,
|
||||
@@ -226,6 +226,6 @@ class Lock(LazyLogging):
|
||||
Literal[False]: always ``False`` (do not suppress any exception)
|
||||
"""
|
||||
self.clear()
|
||||
status = BuildStatusEnum.Success if exc_val is None else BuildStatusEnum.Failed
|
||||
status = BuildStatusEnum.SUCCESS if exc_val is None else BuildStatusEnum.FAILED
|
||||
self.reporter.status_update(status)
|
||||
return False
|
||||
@@ -96,7 +96,7 @@ class Pacman(LazyLogging):
|
||||
self.database_init(handle, self.repository_id.name, self.repository_id.architecture)
|
||||
|
||||
if use_ahriman_cache and refresh_database:
|
||||
self.database_sync(handle, force=refresh_database == PacmanSynchronization.Force)
|
||||
self.database_sync(handle, force=refresh_database == PacmanSynchronization.FORCE)
|
||||
|
||||
return handle
|
||||
|
||||
|
||||
@@ -35,32 +35,32 @@ class PkgbuildNodeType(StrEnum):
|
||||
tree-sitter node types used by parser
|
||||
|
||||
Attributes:
|
||||
Append(PkgbuildNodeType): append node
|
||||
Array(PkgbuildNodeType): array node
|
||||
Comment(PkgbuildNodeType): comment node
|
||||
Concatenation(PkgbuildNodeType): concatenation node
|
||||
Error(PkgbuildNodeType): syntax error node
|
||||
FunctionDefinition(PkgbuildNodeType): function definition node
|
||||
Number(PkgbuildNodeType): numeric word node
|
||||
RawString(PkgbuildNodeType): single-quoted string node
|
||||
String(PkgbuildNodeType): double-quoted string node
|
||||
StringContent(PkgbuildNodeType): string content node
|
||||
VariableAssignment(PkgbuildNodeType): assignment node
|
||||
Word(PkgbuildNodeType): word node
|
||||
APPEND(PkgbuildNodeType): append node
|
||||
ARRAY(PkgbuildNodeType): array node
|
||||
COMMENT(PkgbuildNodeType): comment node
|
||||
CONCATENATION(PkgbuildNodeType): concatenation node
|
||||
ERROR(PkgbuildNodeType): syntax error node
|
||||
FUNCTION_DEFINITION(PkgbuildNodeType): function definition node
|
||||
NUMBER(PkgbuildNodeType): numeric word node
|
||||
RAW_STRING(PkgbuildNodeType): single-quoted string node
|
||||
STRING(PkgbuildNodeType): double-quoted string node
|
||||
STRING_CONTENT(PkgbuildNodeType): string content node
|
||||
VARIABLE_ASSIGNMENT(PkgbuildNodeType): assignment node
|
||||
WORD(PkgbuildNodeType): word node
|
||||
"""
|
||||
|
||||
Append = "+="
|
||||
Array = "array"
|
||||
Comment = "comment"
|
||||
Concatenation = "concatenation"
|
||||
Error = "ERROR"
|
||||
FunctionDefinition = "function_definition"
|
||||
Number = "number"
|
||||
RawString = "raw_string"
|
||||
String = "string"
|
||||
StringContent = "string_content"
|
||||
VariableAssignment = "variable_assignment"
|
||||
Word = "word"
|
||||
APPEND = "+="
|
||||
ARRAY = "array"
|
||||
COMMENT = "comment"
|
||||
CONCATENATION = "concatenation"
|
||||
ERROR = "ERROR"
|
||||
FUNCTION_DEFINITION = "function_definition"
|
||||
NUMBER = "number"
|
||||
RAW_STRING = "raw_string"
|
||||
STRING = "string"
|
||||
STRING_CONTENT = "string_content"
|
||||
VARIABLE_ASSIGNMENT = "variable_assignment"
|
||||
WORD = "word"
|
||||
|
||||
|
||||
class PkgbuildNodeField(StrEnum):
|
||||
@@ -68,14 +68,14 @@ class PkgbuildNodeField(StrEnum):
|
||||
tree-sitter node fields used by parser
|
||||
|
||||
Attributes:
|
||||
Body(PkgbuildNodeField): function body field
|
||||
Name(PkgbuildNodeField): variable or function name field
|
||||
Value(PkgbuildNodeField): assignment value field
|
||||
BODY(PkgbuildNodeField): function body field
|
||||
NAME(PkgbuildNodeField): variable or function name field
|
||||
VALUE(PkgbuildNodeField): assignment value field
|
||||
"""
|
||||
|
||||
Body = "body"
|
||||
Name = "name"
|
||||
Value = "value"
|
||||
BODY = "body"
|
||||
NAME = "name"
|
||||
VALUE = "value"
|
||||
|
||||
|
||||
class PkgbuildParser(Iterable[PkgbuildPatch]):
|
||||
@@ -169,17 +169,17 @@ class PkgbuildParser(Iterable[PkgbuildPatch]):
|
||||
source = source.replace(original, replacement)
|
||||
return source
|
||||
|
||||
if node.type == PkgbuildNodeType.Concatenation:
|
||||
if node.type == PkgbuildNodeType.CONCATENATION:
|
||||
return "".join(PkgbuildParser.value(child) for child in node.named_children)
|
||||
|
||||
value = PkgbuildParser.text(node)
|
||||
match node.type:
|
||||
case PkgbuildNodeType.String | PkgbuildNodeType.StringContent:
|
||||
if node.type == PkgbuildNodeType.String:
|
||||
case PkgbuildNodeType.STRING | PkgbuildNodeType.STRING_CONTENT:
|
||||
if node.type == PkgbuildNodeType.STRING:
|
||||
value = PkgbuildParser.unquote(value)
|
||||
# protect escaped backslashes from being interpreted a second time.
|
||||
return "\\".join(unescape(part) for part in value.split("\\\\"))
|
||||
case PkgbuildNodeType.Number | PkgbuildNodeType.RawString | PkgbuildNodeType.Word:
|
||||
case PkgbuildNodeType.NUMBER | PkgbuildNodeType.RAW_STRING | PkgbuildNodeType.WORD:
|
||||
return PkgbuildParser.unquote(value)
|
||||
case _:
|
||||
return value
|
||||
@@ -194,17 +194,17 @@ class PkgbuildParser(Iterable[PkgbuildPatch]):
|
||||
Returns:
|
||||
PkgbuildPatch: parsed assignment
|
||||
"""
|
||||
key = self.text(cast(Node, node.child_by_field_name(PkgbuildNodeField.Name)))
|
||||
value = node.child_by_field_name(PkgbuildNodeField.Value)
|
||||
key = self.text(cast(Node, node.child_by_field_name(PkgbuildNodeField.NAME)))
|
||||
value = node.child_by_field_name(PkgbuildNodeField.VALUE)
|
||||
# bash permits assignments without a value (for example ``IFS=``).
|
||||
# tree-sitter represents those assignments without a value node.
|
||||
if value is None:
|
||||
return PkgbuildPatch(key, "")
|
||||
|
||||
match value.type:
|
||||
case PkgbuildNodeType.Array:
|
||||
case PkgbuildNodeType.ARRAY:
|
||||
values = []
|
||||
for element in filter(lambda child: child.type != PkgbuildNodeType.Comment, value.named_children):
|
||||
for element in filter(lambda child: child.type != PkgbuildNodeType.COMMENT, value.named_children):
|
||||
values.extend(self._expand_array(element))
|
||||
return PkgbuildPatch(key, values)
|
||||
|
||||
@@ -221,7 +221,7 @@ class PkgbuildParser(Iterable[PkgbuildPatch]):
|
||||
Returns:
|
||||
list[str]: expanded element values
|
||||
"""
|
||||
if node.type != PkgbuildNodeType.Concatenation:
|
||||
if node.type != PkgbuildNodeType.CONCATENATION:
|
||||
return [self.value(node)]
|
||||
|
||||
values = [""]
|
||||
@@ -229,9 +229,9 @@ class PkgbuildParser(Iterable[PkgbuildPatch]):
|
||||
while children:
|
||||
match children[:3]:
|
||||
case [
|
||||
Node(type=PkgbuildNodeType.Word, text=b"{"),
|
||||
Node(type=PkgbuildNodeType.Word) as content,
|
||||
Node(type=PkgbuildNodeType.Word, text=b"}"),
|
||||
Node(type=PkgbuildNodeType.WORD, text=b"{"),
|
||||
Node(type=PkgbuildNodeType.WORD) as content,
|
||||
Node(type=PkgbuildNodeType.WORD, text=b"}"),
|
||||
] if "," in (escaped := self.text(content).replace("\\,", ShellInterpolator.DATA_LINK_ESCAPE)):
|
||||
parts = [
|
||||
self.unquote(part).replace(ShellInterpolator.DATA_LINK_ESCAPE, ",")
|
||||
@@ -258,7 +258,7 @@ class PkgbuildParser(Iterable[PkgbuildPatch]):
|
||||
PkgbuildPatch: parsed entries
|
||||
"""
|
||||
match node.type:
|
||||
case PkgbuildNodeType.VariableAssignment if any(child.type == PkgbuildNodeType.Append for child in node.children):
|
||||
case PkgbuildNodeType.VARIABLE_ASSIGNMENT if any(child.type == PkgbuildNodeType.APPEND for child in node.children):
|
||||
patch = self._assignment(node)
|
||||
match values.get(patch.key), patch.value:
|
||||
case PkgbuildPatch(value=str() as previous), str() as appended:
|
||||
@@ -270,25 +270,25 @@ class PkgbuildParser(Iterable[PkgbuildPatch]):
|
||||
values[patch.key] = patch
|
||||
yield patch
|
||||
|
||||
case PkgbuildNodeType.VariableAssignment:
|
||||
case PkgbuildNodeType.VARIABLE_ASSIGNMENT:
|
||||
patch = self._assignment(node)
|
||||
values[patch.key] = patch
|
||||
yield patch
|
||||
|
||||
case PkgbuildNodeType.FunctionDefinition:
|
||||
name = cast(Node, node.child_by_field_name(PkgbuildNodeField.Name))
|
||||
body = cast(Node, node.child_by_field_name(PkgbuildNodeField.Body))
|
||||
case PkgbuildNodeType.FUNCTION_DEFINITION:
|
||||
name = cast(Node, node.child_by_field_name(PkgbuildNodeField.NAME))
|
||||
body = cast(Node, node.child_by_field_name(PkgbuildNodeField.BODY))
|
||||
yield PkgbuildPatch(f"{self.text(name)}()", self.text(body))
|
||||
|
||||
case _:
|
||||
# descend into statements, but skip command arguments and values
|
||||
for child in node.named_children:
|
||||
if child.type not in (
|
||||
PkgbuildNodeType.Array,
|
||||
PkgbuildNodeType.Comment,
|
||||
PkgbuildNodeType.RawString,
|
||||
PkgbuildNodeType.String,
|
||||
PkgbuildNodeType.Word,
|
||||
PkgbuildNodeType.ARRAY,
|
||||
PkgbuildNodeType.COMMENT,
|
||||
PkgbuildNodeType.RAW_STRING,
|
||||
PkgbuildNodeType.STRING,
|
||||
PkgbuildNodeType.WORD,
|
||||
):
|
||||
yield from self._read(child, values)
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class RemotePull(LazyLogging):
|
||||
web_url="",
|
||||
path=".",
|
||||
branch=configuration.get(section, "pull_branch", fallback="master"),
|
||||
source=PackageSource.Local,
|
||||
source=PackageSource.LOCAL,
|
||||
)
|
||||
self.architecture = repository_id.architecture
|
||||
self.repository_paths = configuration.repository_paths
|
||||
|
||||
@@ -62,7 +62,7 @@ class RemotePush(LazyLogging):
|
||||
web_url="",
|
||||
path=".",
|
||||
branch=configuration.get(section, "push_branch", fallback="master"),
|
||||
source=PackageSource.Local,
|
||||
source=PackageSource.LOCAL,
|
||||
)
|
||||
|
||||
def package_update(self, package: Package, target_dir: Path) -> str:
|
||||
|
||||
@@ -52,9 +52,9 @@ class LogLoader:
|
||||
"""
|
||||
try to guess default log handler. In case if ``selected`` is set, it will return specified value with appended
|
||||
_handler suffix. Otherwise, it will try to import journald handler and returns
|
||||
:attr:`ahriman.models.log_handler.LogHandler.Journald` if library is available. Otherwise, it will check if
|
||||
there is ``/dev/log`` device and returns :attr:`ahriman.models.log_handler.LogHandler.Syslog` in this
|
||||
case. And, finally, it will fall back to :attr:`ahriman.models.log_handler.LogHandler.Console`
|
||||
:attr:`ahriman.models.log_handler.LogHandler.JOURNALD` if library is available. Otherwise, it will check if
|
||||
there is ``/dev/log`` device and returns :attr:`ahriman.models.log_handler.LogHandler.SYSLOG` in this
|
||||
case. And, finally, it will fall back to :attr:`ahriman.models.log_handler.LogHandler.CONSOLE`
|
||||
if none were found
|
||||
|
||||
Args:
|
||||
@@ -67,10 +67,10 @@ class LogLoader:
|
||||
return selected
|
||||
|
||||
if optional_module("systemd.journal"):
|
||||
return LogHandler.Journald # journald import was found
|
||||
return LogHandler.JOURNALD # journald import was found
|
||||
if LogLoader.DEFAULT_SYSLOG_DEVICE.exists():
|
||||
return LogHandler.Syslog
|
||||
return LogHandler.Console
|
||||
return LogHandler.SYSLOG
|
||||
return LogHandler.CONSOLE
|
||||
|
||||
@staticmethod
|
||||
def load(repository_id: RepositoryId, configuration: Configuration, handler: LogHandler, *,
|
||||
|
||||
@@ -155,8 +155,8 @@ class JinjaTemplate:
|
||||
homepage=self.homepage,
|
||||
last_update=self.format_datetime(utcnow()),
|
||||
link_path=self.link_path,
|
||||
has_package_signed=SignSettings.Packages in self.sign_targets,
|
||||
has_repo_signed=SignSettings.Repository in self.sign_targets,
|
||||
has_package_signed=SignSettings.PACKAGES in self.sign_targets,
|
||||
has_repo_signed=SignSettings.REPOSITORY in self.sign_targets,
|
||||
packages=self.sort_content(content),
|
||||
pgp_key=self.default_pgp_key,
|
||||
repository=self.name,
|
||||
|
||||
@@ -81,19 +81,19 @@ class Report(LazyLogging):
|
||||
case ReportSettings.HTML:
|
||||
from ahriman.core.report.html import HTML
|
||||
return HTML(repository_id, configuration, section)
|
||||
case ReportSettings.Email:
|
||||
case ReportSettings.EMAIL:
|
||||
from ahriman.core.report.email import Email
|
||||
return Email(repository_id, configuration, section)
|
||||
case ReportSettings.Console:
|
||||
case ReportSettings.CONSOLE:
|
||||
from ahriman.core.report.console import Console
|
||||
return Console(repository_id, configuration, section)
|
||||
case ReportSettings.Telegram:
|
||||
case ReportSettings.TELEGRAM:
|
||||
from ahriman.core.report.telegram import Telegram
|
||||
return Telegram(repository_id, configuration, section)
|
||||
case ReportSettings.RSS:
|
||||
from ahriman.core.report.rss import RSS
|
||||
return RSS(repository_id, configuration, section)
|
||||
case ReportSettings.RemoteCall:
|
||||
case ReportSettings.REMOTE_CALL:
|
||||
from ahriman.core.report.remote_call import RemoteCall
|
||||
return RemoteCall(repository_id, configuration, section)
|
||||
case _:
|
||||
|
||||
@@ -103,7 +103,7 @@ class RSS(Report, JinjaTemplate):
|
||||
"""
|
||||
ctx = context.get()
|
||||
reporter = ctx.get(Client)
|
||||
events = reporter.event_get(EventType.PackageUpdated, None, limit=self.max_entries)
|
||||
events = reporter.event_get(EventType.PACKAGE_UPDATED, None, limit=self.max_entries)
|
||||
|
||||
known_packages = {package.base: package for package in packages}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class EventLogger:
|
||||
This method must be used as simple wrapper for :class:`ahriman.core.status.Client` methods, e.g.::
|
||||
|
||||
>>> do_something()
|
||||
>>> self.event(package_base, EventType.PackageUpdated)
|
||||
>>> self.event(package_base, EventType.PACKAGE_UPDATED)
|
||||
"""
|
||||
self.reporter.event_add(Event(event, package_base, message))
|
||||
|
||||
@@ -68,7 +68,7 @@ class EventLogger:
|
||||
Examples:
|
||||
This method must be used to perform action in context with time measurement::
|
||||
|
||||
>>> with self.in_event(package_base, EventType.PackageUpdated):
|
||||
>>> with self.in_event(package_base, EventType.PACKAGE_UPDATED):
|
||||
>>> do_something()
|
||||
|
||||
Additional parameter ``failure`` can be set in order to emit an event on exception occurred. If none set
|
||||
|
||||
@@ -117,7 +117,7 @@ class Executor(PackageInfo, Cleaner):
|
||||
package_base(str): package base name
|
||||
"""
|
||||
try:
|
||||
with self.in_event(package_base, EventType.PackageRemoved):
|
||||
with self.in_event(package_base, EventType.PACKAGE_REMOVED):
|
||||
self.reporter.package_remove(package_base)
|
||||
except Exception:
|
||||
self.logger.exception("could not remove base %s", package_base)
|
||||
@@ -169,7 +169,7 @@ class Executor(PackageInfo, Cleaner):
|
||||
with self.in_package_context(single.base, local_versions.get(single.base)), \
|
||||
TemporaryDirectory(ignore_cleanup_errors=True) as dir_name:
|
||||
try:
|
||||
with self.in_event(single.base, EventType.PackageUpdated, failure=EventType.PackageUpdateFailed):
|
||||
with self.in_event(single.base, EventType.PACKAGE_UPDATED, failure=EventType.PACKAGE_UPDATE_FAILED):
|
||||
packager = self.packager(packagers, single.base)
|
||||
local_version = local_versions.get(single.base) if bump_pkgrel else None
|
||||
commit_sha = self._package_build(single, Path(dir_name), packager.packager_id, local_version)
|
||||
|
||||
@@ -57,7 +57,7 @@ class Repository(Executor, UpdateHandler):
|
||||
|
||||
@classmethod
|
||||
def load(cls, repository_id: RepositoryId, configuration: Configuration, database: SQLite, *, report: bool,
|
||||
refresh_pacman_database: PacmanSynchronization = PacmanSynchronization.Disabled) -> Self:
|
||||
refresh_pacman_database: PacmanSynchronization = PacmanSynchronization.DISABLED) -> Self:
|
||||
"""
|
||||
load instance from argument list
|
||||
|
||||
@@ -67,7 +67,7 @@ class Repository(Executor, UpdateHandler):
|
||||
database(SQLite): database instance
|
||||
report(bool): force enable or disable reporting
|
||||
refresh_pacman_database(PacmanSynchronization, optional): pacman database synchronization level
|
||||
(Default value = PacmanSynchronization.Disabled)
|
||||
(Default value = PacmanSynchronization.DISABLED)
|
||||
|
||||
Returns:
|
||||
Self: fully loaded repository class instance
|
||||
|
||||
@@ -90,9 +90,9 @@ class RepositoryProperties(EventLogger, LazyLogging):
|
||||
"""
|
||||
username = packagers.for_base(package_base)
|
||||
if username is None: # none to search
|
||||
return User(username="", password="", access=UserAccess.Read, packager_id=None, key=None) # nosec
|
||||
return User(username="", password="", access=UserAccess.READ, packager_id=None, key=None) # nosec
|
||||
|
||||
if (user := self.database.user_get(username)) is not None: # found user
|
||||
return user
|
||||
# empty user with the username
|
||||
return User(username=username, password="", access=UserAccess.Read, packager_id=None, key=None) # nosec
|
||||
return User(username=username, password="", access=UserAccess.READ, packager_id=None, key=None) # nosec
|
||||
@@ -62,7 +62,7 @@ class UpdateHandler(PackageInfo, Cleaner):
|
||||
# try to load package from base and if none found try to load by separated packages
|
||||
for probe in [package.base] + sorted(package.packages.keys()):
|
||||
try:
|
||||
if package.remote.source == PackageSource.Repository:
|
||||
if package.remote.source == PackageSource.REPOSITORY:
|
||||
return Package.from_official(probe, self.pacman, None)
|
||||
return Package.from_aur(probe, None)
|
||||
except UnknownPackageError:
|
||||
@@ -85,10 +85,10 @@ class UpdateHandler(PackageInfo, Cleaner):
|
||||
|
||||
if PackageVersion(local).is_outdated(remote, self.configuration, calculate_version=vcs):
|
||||
self.reporter.set_pending(local.base)
|
||||
self.event(local.base, EventType.PackageOutdated, "Remote version is newer than local")
|
||||
self.event(local.base, EventType.PACKAGE_OUTDATED, "Remote version is newer than local")
|
||||
result.append(remote)
|
||||
else:
|
||||
self.reporter.package_status_update(local.base, BuildStatusEnum.Success)
|
||||
self.reporter.package_status_update(local.base, BuildStatusEnum.SUCCESS)
|
||||
except Exception:
|
||||
self.reporter.set_failed(local.base)
|
||||
self.logger.exception("could not load remote package %s", local.base)
|
||||
@@ -136,7 +136,7 @@ class UpdateHandler(PackageInfo, Cleaner):
|
||||
|
||||
# there are no packages found in filesystem with the same paths
|
||||
self.reporter.set_pending(local.base)
|
||||
self.event(local.base, EventType.PackageOutdated, "Implicit dependencies are broken")
|
||||
self.event(local.base, EventType.PACKAGE_OUTDATED, "Implicit dependencies are broken")
|
||||
result.append(local)
|
||||
|
||||
break
|
||||
@@ -165,7 +165,7 @@ class UpdateHandler(PackageInfo, Cleaner):
|
||||
with self.in_package_context(cache_dir.name, local_versions.get(cache_dir.name)):
|
||||
try:
|
||||
source = RemoteSource(
|
||||
source=PackageSource.Local,
|
||||
source=PackageSource.LOCAL,
|
||||
git_url=cache_dir.absolute().as_uri(),
|
||||
web_url="",
|
||||
path=".",
|
||||
@@ -186,7 +186,7 @@ class UpdateHandler(PackageInfo, Cleaner):
|
||||
|
||||
if PackageVersion(local).is_outdated(remote, self.configuration, calculate_version=vcs):
|
||||
self.reporter.set_pending(local.base)
|
||||
self.event(local.base, EventType.PackageOutdated, "Locally pulled sources are outdated")
|
||||
self.event(local.base, EventType.PACKAGE_OUTDATED, "Locally pulled sources are outdated")
|
||||
result.append(remote)
|
||||
|
||||
except Exception:
|
||||
@@ -211,7 +211,7 @@ class UpdateHandler(PackageInfo, Cleaner):
|
||||
self.reporter.set_unknown(local)
|
||||
else:
|
||||
self.reporter.set_pending(local.base)
|
||||
self.event(local.base, EventType.PackageOutdated, "Manual update is requested")
|
||||
self.event(local.base, EventType.PACKAGE_OUTDATED, "Manual update is requested")
|
||||
|
||||
except Exception:
|
||||
self.logger.exception("could not load packages from database")
|
||||
|
||||
@@ -53,7 +53,7 @@ class GPG(SyncHttpClient):
|
||||
Returns:
|
||||
list[str]: command line arguments for repo-add command to sign database
|
||||
"""
|
||||
if SignSettings.Repository not in self.targets:
|
||||
if SignSettings.REPOSITORY not in self.targets:
|
||||
return []
|
||||
if self.default_key is None:
|
||||
self.logger.error("no default key set, skip repository sign")
|
||||
@@ -88,7 +88,7 @@ class GPG(SyncHttpClient):
|
||||
targets: set[SignSettings] = set()
|
||||
for option in configuration.getlist("sign", "target", fallback=[]):
|
||||
target = SignSettings.from_option(option)
|
||||
if target == SignSettings.Disabled:
|
||||
if target == SignSettings.DISABLED:
|
||||
continue
|
||||
targets.add(target)
|
||||
default_key = configuration.get("sign", "key") if targets else None
|
||||
@@ -204,7 +204,7 @@ class GPG(SyncHttpClient):
|
||||
# the file was already signed before, just use its signature
|
||||
return [path, signature]
|
||||
|
||||
if SignSettings.Packages not in self.targets:
|
||||
if SignSettings.PACKAGES not in self.targets:
|
||||
return [path]
|
||||
|
||||
key = packager_key or self.default_key
|
||||
@@ -226,7 +226,7 @@ class GPG(SyncHttpClient):
|
||||
Returns:
|
||||
list[Path]: list of generated files including original file
|
||||
"""
|
||||
if SignSettings.Repository not in self.targets:
|
||||
if SignSettings.REPOSITORY not in self.targets:
|
||||
return [path]
|
||||
if self.default_key is None:
|
||||
self.logger.error("no default key set, skip repository sign")
|
||||
|
||||
@@ -341,7 +341,7 @@ class Client:
|
||||
Args:
|
||||
package_base(str): package base to update
|
||||
"""
|
||||
self.package_status_update(package_base, BuildStatusEnum.Building)
|
||||
self.package_status_update(package_base, BuildStatusEnum.BUILDING)
|
||||
|
||||
def set_failed(self, package_base: str) -> None:
|
||||
"""
|
||||
@@ -350,7 +350,7 @@ class Client:
|
||||
Args:
|
||||
package_base(str): package base to update
|
||||
"""
|
||||
self.package_status_update(package_base, BuildStatusEnum.Failed)
|
||||
self.package_status_update(package_base, BuildStatusEnum.FAILED)
|
||||
|
||||
def set_pending(self, package_base: str) -> None:
|
||||
"""
|
||||
@@ -359,7 +359,7 @@ class Client:
|
||||
Args:
|
||||
package_base(str): package base to update
|
||||
"""
|
||||
self.package_status_update(package_base, BuildStatusEnum.Pending)
|
||||
self.package_status_update(package_base, BuildStatusEnum.PENDING)
|
||||
|
||||
def set_success(self, package: Package) -> None:
|
||||
"""
|
||||
@@ -368,7 +368,7 @@ class Client:
|
||||
Args:
|
||||
package(Package): current package properties
|
||||
"""
|
||||
self.package_update(package, BuildStatusEnum.Success)
|
||||
self.package_update(package, BuildStatusEnum.SUCCESS)
|
||||
|
||||
def set_unknown(self, package: Package) -> None:
|
||||
"""
|
||||
@@ -380,7 +380,7 @@ class Client:
|
||||
"""
|
||||
if self.package_get(package.base):
|
||||
return # skip update in case if package is already known
|
||||
self.package_update(package, BuildStatusEnum.Unknown)
|
||||
self.package_update(package, BuildStatusEnum.UNKNOWN)
|
||||
|
||||
def statistics(self) -> RepositoryStats:
|
||||
"""
|
||||
|
||||
@@ -197,7 +197,7 @@ class Watcher(LazyLogging):
|
||||
self._known[package_base] = (package, replace(status, is_held=enabled))
|
||||
self.client.package_hold_update(package_base, enabled=enabled)
|
||||
|
||||
await self.event_bus.broadcast(EventType.PackageHeld, package_base, is_held=enabled)
|
||||
await self.event_bus.broadcast(EventType.PACKAGE_HELD, package_base, is_held=enabled)
|
||||
|
||||
async def package_logs_add(self, log_record: LogRecord) -> None:
|
||||
"""
|
||||
@@ -208,7 +208,7 @@ class Watcher(LazyLogging):
|
||||
"""
|
||||
self.client.package_logs_add(log_record)
|
||||
|
||||
await self.event_bus.broadcast(EventType.BuildLog, log_record.log_record_id.package_base, **log_record.view())
|
||||
await self.event_bus.broadcast(EventType.BUILD_LOG, log_record.log_record_id.package_base, **log_record.view())
|
||||
|
||||
async def package_logs_get(self, package_base: str, version: str | None = None, process_id: str | None = None,
|
||||
limit: int = -1, offset: int = 0) -> list[LogRecord]:
|
||||
@@ -281,7 +281,7 @@ class Watcher(LazyLogging):
|
||||
self._known.pop(package_base, None)
|
||||
self.client.package_remove(package_base)
|
||||
|
||||
await self.event_bus.broadcast(EventType.PackageRemoved, package_base)
|
||||
await self.event_bus.broadcast(EventType.PACKAGE_REMOVED, package_base)
|
||||
|
||||
async def package_status_update(self, package_base: str, status: BuildStatusEnum) -> None:
|
||||
"""
|
||||
@@ -296,7 +296,7 @@ class Watcher(LazyLogging):
|
||||
self._known[package_base] = (package, BuildStatus(status, is_held=current_status.is_held))
|
||||
self.client.package_status_update(package_base, status)
|
||||
|
||||
await self.event_bus.broadcast(EventType.PackageStatusChanged, package_base, status=status.value)
|
||||
await self.event_bus.broadcast(EventType.PACKAGE_STATUS_CHANGED, package_base, status=status.value)
|
||||
|
||||
async def package_update(self, package: Package, status: BuildStatusEnum) -> None:
|
||||
"""
|
||||
@@ -312,7 +312,7 @@ class Watcher(LazyLogging):
|
||||
self.client.package_update(package, status)
|
||||
|
||||
await self.event_bus.broadcast(
|
||||
EventType.PackageUpdated, package.base, status=status.value, version=package.version,
|
||||
EventType.PACKAGE_UPDATED, package.base, status=status.value, version=package.version,
|
||||
)
|
||||
|
||||
async def packages(self) -> list[tuple[Package, BuildStatus]]:
|
||||
@@ -340,7 +340,7 @@ class Watcher(LazyLogging):
|
||||
"""
|
||||
self.status = BuildStatus(status)
|
||||
|
||||
await self.event_bus.broadcast(EventType.ServiceStatusChanged, None, status=status.value)
|
||||
await self.event_bus.broadcast(EventType.SERVICE_STATUS_CHANGED, None, status=status.value)
|
||||
|
||||
def __call__(self, package_base: str | None) -> Self:
|
||||
"""
|
||||
|
||||
@@ -79,16 +79,16 @@ class Upload(LazyLogging):
|
||||
"""
|
||||
section, provider_name = configuration.gettype(target, repository_id)
|
||||
match UploadSettings.from_option(provider_name):
|
||||
case UploadSettings.Rsync:
|
||||
case UploadSettings.RSYNC:
|
||||
from ahriman.core.upload.rsync import Rsync
|
||||
return Rsync(repository_id, configuration, section)
|
||||
case UploadSettings.S3:
|
||||
from ahriman.core.upload.s3 import S3
|
||||
return S3(repository_id, configuration, section)
|
||||
case UploadSettings.GitHub:
|
||||
case UploadSettings.GITHUB:
|
||||
from ahriman.core.upload.github import GitHub
|
||||
return GitHub(repository_id, configuration, section)
|
||||
case UploadSettings.RemoteService:
|
||||
case UploadSettings.REMOTE_SERVICE:
|
||||
from ahriman.core.upload.remote_service import RemoteService
|
||||
return RemoteService(repository_id, configuration, section)
|
||||
case _:
|
||||
|
||||
@@ -25,11 +25,11 @@ class Action(StrEnum):
|
||||
base action enumeration
|
||||
|
||||
Attributes:
|
||||
List(Action): list available values
|
||||
Remove(Action): remove everything from local storage
|
||||
Update(Action): update local storage or add to
|
||||
LIST(Action): list available values
|
||||
REMOVE(Action): remove everything from local storage
|
||||
UPDATE(Action): update local storage or add to
|
||||
"""
|
||||
|
||||
List = "list"
|
||||
Remove = "remove"
|
||||
Update = "update"
|
||||
LIST = "list"
|
||||
REMOVE = "remove"
|
||||
UPDATE = "update"
|
||||
@@ -27,15 +27,15 @@ class AuthSettings(StrEnum):
|
||||
web authorization type
|
||||
|
||||
Attributes:
|
||||
Disabled(AuthSettings): authorization is disabled
|
||||
Configuration(AuthSettings): configuration based authorization
|
||||
OAuth(AuthSettings): OAuth based provider
|
||||
DISABLED(AuthSettings): authorization is disabled
|
||||
CONFIGURATION(AuthSettings): configuration based authorization
|
||||
OAUTH(AuthSettings): OAuth based provider
|
||||
PAM(AuthSettings): PAM based provider
|
||||
"""
|
||||
|
||||
Disabled = "disabled"
|
||||
Configuration = "configuration"
|
||||
OAuth = "oauth2"
|
||||
DISABLED = "disabled"
|
||||
CONFIGURATION = "configuration"
|
||||
OAUTH = "oauth2"
|
||||
PAM = "pam"
|
||||
|
||||
@property
|
||||
@@ -46,7 +46,7 @@ class AuthSettings(StrEnum):
|
||||
Returns:
|
||||
bool: ``False`` in case if authorization is disabled and ``True`` otherwise
|
||||
"""
|
||||
return self != AuthSettings.Disabled
|
||||
return self != AuthSettings.DISABLED
|
||||
|
||||
@staticmethod
|
||||
def from_option(value: str) -> AuthSettings:
|
||||
@@ -61,10 +61,10 @@ class AuthSettings(StrEnum):
|
||||
"""
|
||||
match value.lower():
|
||||
case "configuration" | "mapping":
|
||||
return AuthSettings.Configuration
|
||||
return AuthSettings.CONFIGURATION
|
||||
case "oauth" | "oauth2":
|
||||
return AuthSettings.OAuth
|
||||
return AuthSettings.OAUTH
|
||||
case "pam":
|
||||
return AuthSettings.PAM
|
||||
case _:
|
||||
return AuthSettings.Disabled
|
||||
return AuthSettings.DISABLED
|
||||
@@ -30,22 +30,22 @@ class BuildPlanReason(StrEnum):
|
||||
reason why package was selected for a build plan
|
||||
|
||||
Attributes:
|
||||
BrokenImplicitDependency(BuildPlanReason): package has a broken implicit dependency
|
||||
LocalSourceUpdate(BuildPlanReason): locally sourced package has an update
|
||||
ManualRequest(BuildPlanReason): package was manually queued
|
||||
PreBuilt(BuildPlanReason): package has already been built
|
||||
Rebuild(BuildPlanReason): package was selected for rebuild
|
||||
RegularUpdate(BuildPlanReason): package has an AUR update
|
||||
RequiredBy(BuildPlanReason): package is required by another selected package
|
||||
BROKEN_IMPLICIT_DEPENDENCY(BuildPlanReason): package has a broken implicit dependency
|
||||
LOCAL_SOURCE_UPDATE(BuildPlanReason): locally sourced package has an update
|
||||
MANUAL_REQUEST(BuildPlanReason): package was manually queued
|
||||
PRE_BUILT(BuildPlanReason): package has already been built
|
||||
REBUILD(BuildPlanReason): package was selected for rebuild
|
||||
REGULAR_UPDATE(BuildPlanReason): package has an AUR update
|
||||
REQUIRED_BY(BuildPlanReason): package is required by another selected package
|
||||
"""
|
||||
|
||||
BrokenImplicitDependency = "broken implicit dependency"
|
||||
LocalSourceUpdate = "local source update"
|
||||
ManualRequest = "manual request"
|
||||
PreBuilt = "pre-built"
|
||||
Rebuild = "rebuild"
|
||||
RegularUpdate = "regular update"
|
||||
RequiredBy = "required by"
|
||||
BROKEN_IMPLICIT_DEPENDENCY = "broken implicit dependency"
|
||||
LOCAL_SOURCE_UPDATE = "local source update"
|
||||
MANUAL_REQUEST = "manual request"
|
||||
PRE_BUILT = "pre-built"
|
||||
REBUILD = "rebuild"
|
||||
REGULAR_UPDATE = "regular update"
|
||||
REQUIRED_BY = "required by"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -95,14 +95,14 @@ class BuildPlan(Iterable[Package]):
|
||||
"""
|
||||
return [item.package for item in self.items]
|
||||
|
||||
def add(self, package: Package, reason: BuildPlanReason = BuildPlanReason.ManualRequest,
|
||||
def add(self, package: Package, reason: BuildPlanReason = BuildPlanReason.MANUAL_REQUEST,
|
||||
requester: str | None = None) -> BuildPlanItem:
|
||||
"""
|
||||
add or update a package while preserving its first reason and requester
|
||||
|
||||
Args:
|
||||
package(Package): package selected for the plan
|
||||
reason(BuildPlanReason, optional): reason for selecting it (Default value = BuildPlanReason.ManualRequest)
|
||||
reason(BuildPlanReason, optional): reason for selecting it (Default value = BuildPlanReason.MANUAL_REQUEST)
|
||||
requester(str | None, optional): package requiring this dependency (Default value = None)
|
||||
|
||||
Returns:
|
||||
@@ -125,14 +125,14 @@ class BuildPlan(Iterable[Package]):
|
||||
"""
|
||||
return self._items[package_base]
|
||||
|
||||
def update(self, packages: Iterable[Package], reason: BuildPlanReason = BuildPlanReason.ManualRequest,
|
||||
def update(self, packages: Iterable[Package], reason: BuildPlanReason = BuildPlanReason.MANUAL_REQUEST,
|
||||
requester: str | None = None) -> Self:
|
||||
"""
|
||||
bulk update packages with the same reason
|
||||
|
||||
Args:
|
||||
packages(Iterable[Package]): list of new packages to be added
|
||||
reason(BuildPlanReason, optional): reason for selecting it (Default value = BuildPlanReason.ManualRequest)
|
||||
reason(BuildPlanReason, optional): reason for selecting it (Default value = BuildPlanReason.MANUAL_REQUEST)
|
||||
requester(str | None, optional): package requiring these dependencies (Default value = None)
|
||||
|
||||
Returns:
|
||||
|
||||
@@ -29,18 +29,18 @@ class BuildStatusEnum(StrEnum):
|
||||
build status enumeration
|
||||
|
||||
Attributes:
|
||||
Unknown(BuildStatusEnum): build status is unknown
|
||||
Pending(BuildStatusEnum): package is out-of-dated and will be built soon
|
||||
Building(BuildStatusEnum): package is building right now
|
||||
Failed(BuildStatusEnum): package build failed
|
||||
Success(BuildStatusEnum): package has been built without errors
|
||||
UNKNOWN(BuildStatusEnum): build status is unknown
|
||||
PENDING(BuildStatusEnum): package is out-of-dated and will be built soon
|
||||
BUILDING(BuildStatusEnum): package is building right now
|
||||
FAILED(BuildStatusEnum): package build failed
|
||||
SUCCESS(BuildStatusEnum): package has been built without errors
|
||||
"""
|
||||
|
||||
Unknown = "unknown"
|
||||
Pending = "pending"
|
||||
Building = "building"
|
||||
Failed = "failed"
|
||||
Success = "success"
|
||||
UNKNOWN = "unknown"
|
||||
PENDING = "pending"
|
||||
BUILDING = "building"
|
||||
FAILED = "failed"
|
||||
SUCCESS = "success"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -54,7 +54,7 @@ class BuildStatus:
|
||||
is_held(bool | None): whether package held or not
|
||||
"""
|
||||
|
||||
status: BuildStatusEnum = BuildStatusEnum.Unknown
|
||||
status: BuildStatusEnum = BuildStatusEnum.UNKNOWN
|
||||
timestamp: int = field(default_factory=lambda: int(utcnow().timestamp()))
|
||||
is_held: bool | None = field(default=None, kw_only=True)
|
||||
|
||||
|
||||
@@ -28,24 +28,24 @@ class EventType(StrEnum):
|
||||
predefined event types
|
||||
|
||||
Attributes:
|
||||
BuildLog(EventType): new build log line
|
||||
PackageHeld(EventType): package hold status has been changed
|
||||
PackageOutdated(EventType): package has been marked as out-of-date
|
||||
PackageRemoved(EventType): package has been removed
|
||||
PackageStatusChanged(EventType): package build status has been changed
|
||||
PackageUpdateFailed(EventType): package update has been failed
|
||||
PackageUpdated(EventType): package has been updated
|
||||
ServiceStatusChanged(EventType): service status has been changed
|
||||
BUILD_LOG(EventType): new build log line
|
||||
PACKAGE_HELD(EventType): package hold status has been changed
|
||||
PACKAGE_OUTDATED(EventType): package has been marked as out-of-date
|
||||
PACKAGE_REMOVED(EventType): package has been removed
|
||||
PACKAGE_STATUS_CHANGED(EventType): package build status has been changed
|
||||
PACKAGE_UPDATE_FAILED(EventType): package update has been failed
|
||||
PACKAGE_UPDATED(EventType): package has been updated
|
||||
SERVICE_STATUS_CHANGED(EventType): service status has been changed
|
||||
"""
|
||||
|
||||
BuildLog = "build-log"
|
||||
PackageHeld = "package-held"
|
||||
PackageOutdated = "package-outdated"
|
||||
PackageRemoved = "package-removed"
|
||||
PackageStatusChanged = "package-status-changed"
|
||||
PackageUpdateFailed = "package-update-failed"
|
||||
PackageUpdated = "package-updated"
|
||||
ServiceStatusChanged = "service-status-changed"
|
||||
BUILD_LOG = "build-log"
|
||||
PACKAGE_HELD = "package-held"
|
||||
PACKAGE_OUTDATED = "package-outdated"
|
||||
PACKAGE_REMOVED = "package-removed"
|
||||
PACKAGE_STATUS_CHANGED = "package-status-changed"
|
||||
PACKAGE_UPDATE_FAILED = "package-update-failed"
|
||||
PACKAGE_UPDATED = "package-updated"
|
||||
SERVICE_STATUS_CHANGED = "service-status-changed"
|
||||
|
||||
|
||||
class Event:
|
||||
|
||||
@@ -25,11 +25,11 @@ class LogHandler(StrEnum):
|
||||
log handler as described by default configuration
|
||||
|
||||
Attributes:
|
||||
Console(LogHandler): write logs to console
|
||||
Syslog(LogHandler): write logs to syslog device /dev/null
|
||||
Journald(LogHandler): write logs to journald directly
|
||||
CONSOLE(LogHandler): write logs to console
|
||||
SYSLOG(LogHandler): write logs to syslog device /dev/null
|
||||
JOURNALD(LogHandler): write logs to journald directly
|
||||
"""
|
||||
|
||||
Console = "console"
|
||||
Syslog = "syslog"
|
||||
Journald = "journald"
|
||||
CONSOLE = "console"
|
||||
SYSLOG = "syslog"
|
||||
JOURNALD = "journald"
|
||||
@@ -50,13 +50,8 @@ class LogRecord:
|
||||
Returns:
|
||||
Self: log record object
|
||||
"""
|
||||
if "process_id" in dump:
|
||||
log_record_id = LogRecordId(package_base, dump["version"], dump["process_id"])
|
||||
else:
|
||||
log_record_id = LogRecordId(package_base, dump["version"])
|
||||
|
||||
return cls(
|
||||
log_record_id=log_record_id,
|
||||
log_record_id=LogRecordId(package_base, dump["version"], dump.get("process_id", "")),
|
||||
created=dump["created"],
|
||||
message=dump["message"],
|
||||
)
|
||||
|
||||
@@ -62,10 +62,10 @@ class Package(LazyLogging):
|
||||
|
||||
The specific class load method must be defined based on the source provided. The following methods (mostly) must
|
||||
be used: :func:`from_archive()`, :func:`from_aur()`, :func:`from_build()`, :func:`from_official()` for sources
|
||||
:attr:`ahriman.models.package_source.PackageSource.Archive`,
|
||||
:attr:`ahriman.models.package_source.PackageSource.ARCHIVE`,
|
||||
:attr:`ahriman.models.package_source.PackageSource.AUR`,
|
||||
:attr:`ahriman.models.package_source.PackageSource.Local` and
|
||||
:attr:`ahriman.models.package_source.PackageSource.Repository` respectively:
|
||||
:attr:`ahriman.models.package_source.PackageSource.LOCAL` and
|
||||
:attr:`ahriman.models.package_source.PackageSource.REPOSITORY` respectively:
|
||||
|
||||
>>> ahriman_package = Package.from_aur("ahriman")
|
||||
>>> pacman_package = Package.from_official("pacman", pacman)
|
||||
@@ -192,7 +192,7 @@ class Package(LazyLogging):
|
||||
return cls(
|
||||
base=package.base or package.name,
|
||||
version=package.version,
|
||||
remote=RemoteSource(source=PackageSource.Archive),
|
||||
remote=RemoteSource(source=PackageSource.ARCHIVE),
|
||||
packages={package.name: description},
|
||||
packager=package.packager,
|
||||
)
|
||||
@@ -255,7 +255,7 @@ class Package(LazyLogging):
|
||||
version = full_version(pkgbuild.get("epoch"), pkgbuild["pkgver"], pkgbuild["pkgrel"])
|
||||
|
||||
remote = RemoteSource(
|
||||
source=PackageSource.Local,
|
||||
source=PackageSource.LOCAL,
|
||||
git_url=path.absolute().as_uri(),
|
||||
web_url=None,
|
||||
path=".",
|
||||
@@ -315,7 +315,7 @@ class Package(LazyLogging):
|
||||
package = impl.info(name, pacman=pacman, include_provides=include_provides)
|
||||
|
||||
remote = RemoteSource(
|
||||
source=PackageSource.Repository,
|
||||
source=PackageSource.REPOSITORY,
|
||||
git_url=Official.remote_git_url(package.package_base, package.repository),
|
||||
web_url=Official.remote_web_url(package.package_base),
|
||||
path=".",
|
||||
|
||||
@@ -32,31 +32,31 @@ class PackageSource(StrEnum):
|
||||
package source for addition enumeration
|
||||
|
||||
Attributes:
|
||||
Auto(PackageSource): automatically determine type of the source
|
||||
Archive(PackageSource): source is a package archive
|
||||
AUTO(PackageSource): automatically determine type of the source
|
||||
ARCHIVE(PackageSource): source is a package archive
|
||||
AUR(PackageSource): source is an AUR package for which it should search
|
||||
Directory(PackageSource): source is a directory which contains packages
|
||||
Local(PackageSource): source is locally stored PKGBUILD
|
||||
Remote(PackageSource): source is remote (http, ftp etc...) link
|
||||
Repository(PackageSource): source is official repository
|
||||
DIRECTORY(PackageSource): source is a directory which contains packages
|
||||
LOCAL(PackageSource): source is locally stored PKGBUILD
|
||||
REMOTE(PackageSource): source is remote (http, ftp etc...) link
|
||||
REPOSITORY(PackageSource): source is official repository
|
||||
|
||||
Examples:
|
||||
In case if source is unknown the :func:`resolve()` and the source
|
||||
descriptor is available method must be used::
|
||||
|
||||
>>> real_source = PackageSource.Auto.resolve("ahriman", configuration.repository_paths)
|
||||
>>> real_source = PackageSource.AUTO.resolve("ahriman", configuration.repository_paths)
|
||||
|
||||
the code above will ensure that the presudo-source :attr:`Auto`
|
||||
the code above will ensure that the presudo-source :attr:`AUTO`
|
||||
will not be processed later.
|
||||
"""
|
||||
|
||||
Auto = "auto"
|
||||
Archive = "archive"
|
||||
AUTO = "auto"
|
||||
ARCHIVE = "archive"
|
||||
AUR = "aur"
|
||||
Directory = "directory"
|
||||
Local = "local"
|
||||
Remote = "remote"
|
||||
Repository = "repository"
|
||||
DIRECTORY = "directory"
|
||||
LOCAL = "local"
|
||||
REMOTE = "remote"
|
||||
REPOSITORY = "repository"
|
||||
|
||||
def resolve(self, source: str, paths: RepositoryPaths) -> PackageSource:
|
||||
"""
|
||||
@@ -69,21 +69,21 @@ class PackageSource(StrEnum):
|
||||
Returns:
|
||||
PackageSource: non-auto type of the package source
|
||||
"""
|
||||
if self != PackageSource.Auto:
|
||||
if self != PackageSource.AUTO:
|
||||
return self
|
||||
|
||||
maybe_url = urlparse(source) # handle file:// like paths
|
||||
maybe_path = Path(maybe_url.path)
|
||||
|
||||
if maybe_url.scheme and maybe_url.scheme not in ("data", "file") and package_like(maybe_path):
|
||||
return PackageSource.Remote
|
||||
return PackageSource.REMOTE
|
||||
try:
|
||||
if (maybe_path / "PKGBUILD").is_file() or paths.cache_for(source).is_dir():
|
||||
return PackageSource.Local
|
||||
return PackageSource.LOCAL
|
||||
if maybe_path.is_dir():
|
||||
return PackageSource.Directory
|
||||
return PackageSource.DIRECTORY
|
||||
if maybe_path.is_file() and package_like(maybe_path):
|
||||
return PackageSource.Archive
|
||||
return PackageSource.ARCHIVE
|
||||
except PermissionError:
|
||||
# in some cases (e.g. if you run from your home directory with sudo)
|
||||
# it will try to read files to which it has no access.
|
||||
|
||||
@@ -25,11 +25,11 @@ class PacmanSynchronization(IntEnum):
|
||||
pacman database synchronization flag
|
||||
|
||||
Attributes:
|
||||
Disabled(PacmanSynchronization): do not synchronize local database
|
||||
Enabled(PacmanSynchronization): synchronize local database (same as pacman -Sy)
|
||||
Force(PacmanSynchronization): force synchronize local database (same as pacman -Syy)
|
||||
DISABLED(PacmanSynchronization): do not synchronize local database
|
||||
ENABLED(PacmanSynchronization): synchronize local database (same as pacman -Sy)
|
||||
FORCE(PacmanSynchronization): force synchronize local database (same as pacman -Syy)
|
||||
"""
|
||||
|
||||
Disabled = 0
|
||||
Enabled = 1
|
||||
Force = 2
|
||||
DISABLED = 0
|
||||
ENABLED = 1
|
||||
FORCE = 2
|
||||
@@ -20,9 +20,10 @@
|
||||
import json
|
||||
import shlex
|
||||
|
||||
from collections.abc import Iterator
|
||||
from dataclasses import dataclass, fields
|
||||
from pathlib import Path
|
||||
from typing import Any, Iterator, Self
|
||||
from typing import Any, Self
|
||||
|
||||
from ahriman.core.configuration.shell_template import ShellTemplate
|
||||
from ahriman.core.utils import dataclass_view, filter_json
|
||||
|
||||
@@ -59,7 +59,7 @@ class RemoteSource:
|
||||
Returns:
|
||||
bool: ``True`` in case if package is well-known remote source (e.g. AUR) and ``False`` otherwise
|
||||
"""
|
||||
return self.source in (PackageSource.AUR, PackageSource.Repository)
|
||||
return self.source in (PackageSource.AUR, PackageSource.REPOSITORY)
|
||||
|
||||
@property
|
||||
def pkgbuild_dir(self) -> Path | None:
|
||||
|
||||
@@ -27,22 +27,22 @@ class ReportSettings(StrEnum):
|
||||
report targets enumeration
|
||||
|
||||
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
|
||||
Email(ReportSettings): email report generation
|
||||
Console(ReportSettings): print result to console
|
||||
Telegram(ReportSettings): Markdown report to telegram channel
|
||||
EMAIL(ReportSettings): email report generation
|
||||
CONSOLE(ReportSettings): print result to console
|
||||
TELEGRAM(ReportSettings): Markdown report to telegram channel
|
||||
RSS(ReportSettings): RSS report generation
|
||||
RemoteCall(ReportSettings): remote ahriman server call
|
||||
REMOTE_CALL(ReportSettings): remote ahriman server call
|
||||
"""
|
||||
|
||||
Disabled = "disabled" # for testing purpose
|
||||
DISABLED = "disabled" # for testing purpose
|
||||
HTML = "html"
|
||||
Email = "email"
|
||||
Console = "console"
|
||||
Telegram = "telegram"
|
||||
EMAIL = "email"
|
||||
CONSOLE = "console"
|
||||
TELEGRAM = "telegram"
|
||||
RSS = "rss"
|
||||
RemoteCall = "remote-call"
|
||||
REMOTE_CALL = "remote-call"
|
||||
|
||||
@staticmethod
|
||||
def from_option(value: str) -> ReportSettings: # pylint: disable=too-many-return-statements
|
||||
@@ -59,14 +59,14 @@ class ReportSettings(StrEnum):
|
||||
case "html":
|
||||
return ReportSettings.HTML
|
||||
case "email":
|
||||
return ReportSettings.Email
|
||||
return ReportSettings.EMAIL
|
||||
case "console":
|
||||
return ReportSettings.Console
|
||||
return ReportSettings.CONSOLE
|
||||
case "telegram":
|
||||
return ReportSettings.Telegram
|
||||
return ReportSettings.TELEGRAM
|
||||
case "rss":
|
||||
return ReportSettings.RSS
|
||||
case "ahriman" | "remote-call":
|
||||
return ReportSettings.RemoteCall
|
||||
return ReportSettings.REMOTE_CALL
|
||||
case _:
|
||||
return ReportSettings.Disabled
|
||||
return ReportSettings.DISABLED
|
||||
@@ -27,14 +27,14 @@ class SignSettings(StrEnum):
|
||||
sign targets enumeration
|
||||
|
||||
Attributes:
|
||||
Disabled(SignSettings): option which generates no report for testing purpose
|
||||
Packages(SignSettings): sign each package
|
||||
Repository(SignSettings): sign repository database file
|
||||
DISABLED(SignSettings): option which generates no report for testing purpose
|
||||
PACKAGES(SignSettings): sign each package
|
||||
REPOSITORY(SignSettings): sign repository database file
|
||||
"""
|
||||
|
||||
Disabled = "disabled"
|
||||
Packages = "packages"
|
||||
Repository = "repository"
|
||||
DISABLED = "disabled"
|
||||
PACKAGES = "packages"
|
||||
REPOSITORY = "repository"
|
||||
|
||||
@staticmethod
|
||||
def from_option(value: str) -> SignSettings:
|
||||
@@ -49,8 +49,8 @@ class SignSettings(StrEnum):
|
||||
"""
|
||||
match value.lower():
|
||||
case "package" | "packages" | "sign-package":
|
||||
return SignSettings.Packages
|
||||
return SignSettings.PACKAGES
|
||||
case "repository" | "sign-repository":
|
||||
return SignSettings.Repository
|
||||
return SignSettings.REPOSITORY
|
||||
case _:
|
||||
return SignSettings.Disabled
|
||||
return SignSettings.DISABLED
|
||||
@@ -27,12 +27,12 @@ class SmtpSSLSettings(StrEnum):
|
||||
SMTP SSL mode enumeration
|
||||
|
||||
Attributes:
|
||||
Disabled(SmtpSSLSettings): no SSL enabled
|
||||
DISABLED(SmtpSSLSettings): no SSL enabled
|
||||
SSL(SmtpSSLSettings): use SMTP_SSL instead of normal SMTP client
|
||||
STARTTLS(SmtpSSLSettings): use STARTTLS in normal SMTP client
|
||||
"""
|
||||
|
||||
Disabled = "disabled"
|
||||
DISABLED = "disabled"
|
||||
SSL = "ssl"
|
||||
STARTTLS = "starttls"
|
||||
|
||||
@@ -53,4 +53,4 @@ class SmtpSSLSettings(StrEnum):
|
||||
case "starttls":
|
||||
return SmtpSSLSettings.STARTTLS
|
||||
case _:
|
||||
return SmtpSSLSettings.Disabled
|
||||
return SmtpSSLSettings.DISABLED
|
||||
@@ -27,18 +27,18 @@ class UploadSettings(StrEnum):
|
||||
remote synchronization targets enumeration
|
||||
|
||||
Attributes:
|
||||
Disabled(UploadSettings): no sync will be performed, required for testing purpose
|
||||
Rsync(UploadSettings): sync via rsync
|
||||
DISABLED(UploadSettings): no sync will be performed, required for testing purpose
|
||||
RSYNC(UploadSettings): sync via rsync
|
||||
S3(UploadSettings): sync to Amazon S3
|
||||
GitHub(UploadSettings): sync to GitHub releases page
|
||||
RemoteService(UploadSettings): sync to another ahriman instance
|
||||
GITHUB(UploadSettings): sync to GitHub releases page
|
||||
REMOTE_SERVICE(UploadSettings): sync to another ahriman instance
|
||||
"""
|
||||
|
||||
Disabled = "disabled" # for testing purpose
|
||||
Rsync = "rsync"
|
||||
DISABLED = "disabled" # for testing purpose
|
||||
RSYNC = "rsync"
|
||||
S3 = "s3"
|
||||
GitHub = "github"
|
||||
RemoteService = "remote-service"
|
||||
GITHUB = "github"
|
||||
REMOTE_SERVICE = "remote-service"
|
||||
|
||||
@staticmethod
|
||||
def from_option(value: str) -> UploadSettings:
|
||||
@@ -53,12 +53,12 @@ class UploadSettings(StrEnum):
|
||||
"""
|
||||
match value.lower():
|
||||
case "rsync":
|
||||
return UploadSettings.Rsync
|
||||
return UploadSettings.RSYNC
|
||||
case "s3":
|
||||
return UploadSettings.S3
|
||||
case "github":
|
||||
return UploadSettings.GitHub
|
||||
return UploadSettings.GITHUB
|
||||
case "ahriman" | "remote-service":
|
||||
return UploadSettings.RemoteService
|
||||
return UploadSettings.REMOTE_SERVICE
|
||||
case _:
|
||||
return UploadSettings.Disabled
|
||||
return UploadSettings.DISABLED
|
||||
@@ -43,7 +43,7 @@ class User:
|
||||
Simply create user from database data and perform required validation::
|
||||
|
||||
>>> password = User.generate_password(24)
|
||||
>>> user = User(username="ahriman", password=password, access=UserAccess.Full)
|
||||
>>> user = User(username="ahriman", password=password, access=UserAccess.FULL)
|
||||
|
||||
Since the password supplied may be plain text, the :func:`hash_password()` method can be used to hash
|
||||
the password::
|
||||
@@ -59,7 +59,7 @@ class User:
|
||||
|
||||
...and finally access can be verified::
|
||||
|
||||
>>> if user.verify_access(UserAccess.Read):
|
||||
>>> if user.verify_access(UserAccess.READ):
|
||||
>>> print(f"user {user.username} has read access")
|
||||
"""
|
||||
|
||||
|
||||
@@ -27,17 +27,17 @@ class UserAccess(StrEnum):
|
||||
web user access enumeration
|
||||
|
||||
Attributes:
|
||||
Unauthorized(UserAccess): user can access specific resources which are marked as available
|
||||
UNAUTHORIZED(UserAccess): user can access specific resources which are marked as available
|
||||
without authorization (e.g. login, logout, static)
|
||||
Read(UserAccess): user can read the page
|
||||
Reporter(UserAccess): user can read everything and is able to perform some modifications
|
||||
Full(UserAccess): user has full access
|
||||
READ(UserAccess): user can read the page
|
||||
REPORTER(UserAccess): user can read everything and is able to perform some modifications
|
||||
FULL(UserAccess): user has full access
|
||||
"""
|
||||
|
||||
Unauthorized = "unauthorized"
|
||||
Read = "read"
|
||||
Reporter = "reporter"
|
||||
Full = "full"
|
||||
UNAUTHORIZED = "unauthorized"
|
||||
READ = "read"
|
||||
REPORTER = "reporter"
|
||||
FULL = "full"
|
||||
|
||||
def permits(self, other: UserAccess) -> bool:
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user