mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-01-16 11:13:43 +00:00
handle None append argument everywhere
This commit is contained in:
@ -116,7 +116,7 @@ class Patch(Handler):
|
||||
application.database.patches_insert(package_base, patch)
|
||||
|
||||
@staticmethod
|
||||
def patch_set_list(application: Application, package_base: str | None, variables: list[str],
|
||||
def patch_set_list(application: Application, package_base: str | None, variables: list[str] | None,
|
||||
exit_code: bool) -> None:
|
||||
"""
|
||||
list patches available for the package base
|
||||
@ -124,7 +124,7 @@ class Patch(Handler):
|
||||
Args:
|
||||
application(Application): application instance
|
||||
package_base(str | None): package base
|
||||
variables(list[str]): extract patches only for specified PKGBUILD variables
|
||||
variables(list[str] | None): extract patches only for specified PKGBUILD variables
|
||||
exit_code(bool): exit with error on empty search result
|
||||
"""
|
||||
patches = application.database.patches_list(package_base, variables)
|
||||
@ -134,13 +134,13 @@ class Patch(Handler):
|
||||
PatchPrinter(base, patch).print(verbose=True, separator=" = ")
|
||||
|
||||
@staticmethod
|
||||
def patch_set_remove(application: Application, package_base: str, variables: list[str]) -> None:
|
||||
def patch_set_remove(application: Application, package_base: str, variables: list[str] | None) -> None:
|
||||
"""
|
||||
remove patch set for the package base
|
||||
|
||||
Args:
|
||||
application(Application): application instance
|
||||
package_base(str): package base
|
||||
variables(list[str]): remove patches only for specified PKGBUILD variables
|
||||
variables(list[str] | None): remove patches only for specified PKGBUILD variables
|
||||
"""
|
||||
application.database.patches_remove(package_base, variables)
|
||||
|
||||
@ -48,7 +48,7 @@ class Rebuild(Handler):
|
||||
application.on_start()
|
||||
|
||||
packages = Rebuild.extract_packages(application, args.status, from_database=args.from_database)
|
||||
updates = application.repository.packages_depend_on(packages, args.depends_on or None)
|
||||
updates = application.repository.packages_depend_on(packages, args.depends_on)
|
||||
|
||||
Rebuild.check_if_empty(args.exit_code, not updates)
|
||||
if args.dry_run:
|
||||
|
||||
@ -117,7 +117,8 @@ class Setup(Handler):
|
||||
|
||||
section = Configuration.section_name("sign", repository_id.name, repository_id.architecture)
|
||||
if args.sign_key is not None:
|
||||
configuration.set_option(section, "target", " ".join([target.name.lower() for target in args.sign_target]))
|
||||
sign_targets = args.sign_target or []
|
||||
configuration.set_option(section, "target", " ".join([target.name.lower() for target in sign_targets]))
|
||||
configuration.set_option(section, "key", args.sign_key)
|
||||
|
||||
section = Configuration.section_name("web", repository_id.name, repository_id.architecture)
|
||||
|
||||
@ -40,7 +40,7 @@ class PatchOperations(Operations):
|
||||
Returns:
|
||||
list[PkgbuildPatch]: plain text patch for the package
|
||||
"""
|
||||
return self.patches_list(package_base, []).get(package_base, [])
|
||||
return self.patches_list(package_base, None).get(package_base, [])
|
||||
|
||||
def patches_insert(self, package_base: str, patch: PkgbuildPatch) -> None:
|
||||
"""
|
||||
@ -64,13 +64,13 @@ class PatchOperations(Operations):
|
||||
|
||||
return self.with_connection(run, commit=True)
|
||||
|
||||
def patches_list(self, package_base: str | None, variables: list[str]) -> dict[str, list[PkgbuildPatch]]:
|
||||
def patches_list(self, package_base: str | None, variables: list[str] | None) -> dict[str, list[PkgbuildPatch]]:
|
||||
"""
|
||||
extract all patches
|
||||
|
||||
Args:
|
||||
package_base(str | None): optional filter by package base
|
||||
variables(list[str]): extract patches only for specified PKGBUILD variables
|
||||
variables(list[str] | None): extract patches only for specified PKGBUILD variables
|
||||
|
||||
Returns:
|
||||
dict[str, list[PkgbuildPatch]]: map of package base to patch content
|
||||
@ -86,29 +86,30 @@ class PatchOperations(Operations):
|
||||
# we could use itertools & operator but why?
|
||||
patches: dict[str, list[PkgbuildPatch]] = defaultdict(list)
|
||||
for package, patch in self.with_connection(run):
|
||||
if variables and patch.key not in variables:
|
||||
if variables is not None and patch.key not in variables:
|
||||
continue
|
||||
patches[package].append(patch)
|
||||
return dict(patches)
|
||||
|
||||
def patches_remove(self, package_base: str, variables: list[str]) -> None:
|
||||
def patches_remove(self, package_base: str, variables: list[str] | None) -> None:
|
||||
"""
|
||||
remove patch set
|
||||
|
||||
Args:
|
||||
package_base(str): package base to clear patches
|
||||
variables(list[str]): remove patches only for specified PKGBUILD variables
|
||||
variables(list[str] | None): remove patches only for specified PKGBUILD variables
|
||||
"""
|
||||
def run_many(connection: Connection) -> None:
|
||||
patches = variables or [] # suppress mypy warning
|
||||
connection.executemany(
|
||||
"""delete from patches where package_base = :package_base and variable = :variable""",
|
||||
[{"package_base": package_base, "variable": variable} for variable in variables])
|
||||
[{"package_base": package_base, "variable": variable} for variable in patches])
|
||||
|
||||
def run(connection: Connection) -> None:
|
||||
connection.execute(
|
||||
"""delete from patches where package_base = :package_base""",
|
||||
{"package_base": package_base})
|
||||
|
||||
if variables:
|
||||
if variables is not None:
|
||||
return self.with_connection(run_many, commit=True)
|
||||
return self.with_connection(run, commit=True)
|
||||
|
||||
Reference in New Issue
Block a user