mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-30 20:34:38 +01:00
Updated for generators
This commit is contained in:
parent
96a43b4d3e
commit
8a34ce52a7
5 changed files with 31 additions and 21 deletions
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from typing import Union
|
from typing import Union, Generator
|
||||||
|
|
||||||
from slpkg.configs import Configs
|
from slpkg.configs import Configs
|
||||||
from slpkg.blacklist import Blacklist
|
from slpkg.blacklist import Blacklist
|
||||||
|
@ -32,21 +32,25 @@ class BinQueries(Configs):
|
||||||
|
|
||||||
return count
|
return count
|
||||||
|
|
||||||
def all_package_names_by_repo(self) -> list:
|
def all_package_names_by_repo(self) -> Generator:
|
||||||
""" Returns all the names of the binaries packages. """
|
""" Returns all the names of the binaries packages. """
|
||||||
pkgs: tuple = self.session.query(
|
pkgs: tuple = self.session.query(
|
||||||
BinariesTable.name).where(
|
BinariesTable.name).where(
|
||||||
BinariesTable.repo == self.repo).all()
|
BinariesTable.repo == self.repo).all()
|
||||||
|
|
||||||
return [pkg[0] for pkg in pkgs]
|
for pkg in pkgs:
|
||||||
|
if pkg[0] not in self.black.packages():
|
||||||
|
yield pkg[0]
|
||||||
|
|
||||||
def all_binaries_packages_by_repo(self) -> list:
|
def all_binaries_packages_by_repo(self) -> Generator:
|
||||||
""" Returns all the binaries packages. """
|
""" Returns all the binaries packages. """
|
||||||
pkgs: tuple = self.session.query(
|
pkgs: tuple = self.session.query(
|
||||||
BinariesTable.package).where(
|
BinariesTable.package).where(
|
||||||
BinariesTable.repo == self.repo).all()
|
BinariesTable.repo == self.repo).all()
|
||||||
|
|
||||||
return [pkg[0] for pkg in pkgs]
|
for pkg in pkgs:
|
||||||
|
if pkg[0] not in self.black.packages():
|
||||||
|
yield pkg[0]
|
||||||
|
|
||||||
def all_package_names_from_repositories(self) -> tuple:
|
def all_package_names_from_repositories(self) -> tuple:
|
||||||
""" Returns the package name with the repo. """
|
""" Returns the package name with the repo. """
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Generator
|
||||||
|
|
||||||
from slpkg.checks import Check
|
from slpkg.checks import Check
|
||||||
from slpkg.upgrade import Upgrade
|
from slpkg.upgrade import Upgrade
|
||||||
|
@ -417,9 +418,9 @@ class Argparse(Configs):
|
||||||
choices: list = []
|
choices: list = []
|
||||||
title: str = f' Choose packages you want to {method} '
|
title: str = f' Choose packages you want to {method} '
|
||||||
|
|
||||||
repo_packages: list = SBoQueries('').sbos()
|
repo_packages: Generator = SBoQueries('').sbos()
|
||||||
if self.utils.is_option(self.flag_binaries, self.flags):
|
if self.utils.is_option(self.flag_binaries, self.flags):
|
||||||
repo_packages: list = BinQueries('', self.binary_repo).all_package_names_by_repo()
|
repo_packages: Generator = BinQueries('', self.binary_repo).all_package_names_by_repo()
|
||||||
|
|
||||||
installed: list = self.utils.installed_packages
|
installed: list = self.utils.installed_packages
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from typing import Union
|
from typing import Union, Generator
|
||||||
from sqlalchemy import inspect
|
from sqlalchemy import inspect
|
||||||
|
|
||||||
from slpkg.configs import Configs
|
from slpkg.configs import Configs
|
||||||
|
@ -45,15 +45,18 @@ class SBoQueries(Configs):
|
||||||
|
|
||||||
return repo
|
return repo
|
||||||
|
|
||||||
def sbos(self) -> list:
|
def sbos(self) -> Generator:
|
||||||
""" Returns all the slackbuilds. """
|
""" Returns all the slackbuilds. """
|
||||||
sbos: tuple = self.session.query(self.sbo_table.name).all() # type: ignore
|
sbos: tuple = self.session.query(self.sbo_table.name).all()
|
||||||
return [sbo[0] for sbo in sbos]
|
|
||||||
|
for sbo in sbos:
|
||||||
|
if sbo[0] not in self.black.packages():
|
||||||
|
yield sbo[0]
|
||||||
|
|
||||||
def slackbuild(self) -> str:
|
def slackbuild(self) -> str:
|
||||||
""" Returns a slackbuild. """
|
""" Returns a slackbuild. """
|
||||||
sbo: tuple = self.session.query(
|
sbo: tuple = self.session.query(
|
||||||
self.sbo_table.name).filter(self.sbo_table.name == self.name).first() # type: ignore
|
self.sbo_table.name).filter(self.sbo_table.name == self.name).first()
|
||||||
|
|
||||||
if sbo:
|
if sbo:
|
||||||
return sbo[0]
|
return sbo[0]
|
||||||
|
@ -62,7 +65,7 @@ class SBoQueries(Configs):
|
||||||
def location(self) -> str:
|
def location(self) -> str:
|
||||||
""" Returns the category of a slackbuild. """
|
""" Returns the category of a slackbuild. """
|
||||||
location: tuple = self.session.query(
|
location: tuple = self.session.query(
|
||||||
self.sbo_table.location).filter(self.sbo_table.name == self.name).first() # type: ignore
|
self.sbo_table.location).filter(self.sbo_table.name == self.name).first()
|
||||||
|
|
||||||
if location:
|
if location:
|
||||||
return location[0]
|
return location[0]
|
||||||
|
@ -71,7 +74,7 @@ class SBoQueries(Configs):
|
||||||
def sources(self) -> list:
|
def sources(self) -> list:
|
||||||
""" Returns the source of a slackbuild. """
|
""" Returns the source of a slackbuild. """
|
||||||
source, source64 = self.session.query(
|
source, source64 = self.session.query(
|
||||||
self.sbo_table.download, self.sbo_table.download64).filter( # type: ignore
|
self.sbo_table.download, self.sbo_table.download64).filter(
|
||||||
self.sbo_table.name == self.name).first()
|
self.sbo_table.name == self.name).first()
|
||||||
|
|
||||||
if self.os_arch == 'x86_64' and source64:
|
if self.os_arch == 'x86_64' and source64:
|
||||||
|
@ -106,7 +109,7 @@ class SBoQueries(Configs):
|
||||||
def checksum(self) -> list:
|
def checksum(self) -> list:
|
||||||
""" Returns the source checksum. """
|
""" Returns the source checksum. """
|
||||||
mds5, md5s64 = self.session.query(
|
mds5, md5s64 = self.session.query(
|
||||||
self.sbo_table.md5sum, self.sbo_table.md5sum64).filter( # type: ignore
|
self.sbo_table.md5sum, self.sbo_table.md5sum64).filter(
|
||||||
self.sbo_table.name == self.name).first()
|
self.sbo_table.name == self.name).first()
|
||||||
|
|
||||||
if self.os_arch == 'x86_64' and md5s64:
|
if self.os_arch == 'x86_64' and md5s64:
|
||||||
|
@ -117,7 +120,7 @@ class SBoQueries(Configs):
|
||||||
def description(self) -> str:
|
def description(self) -> str:
|
||||||
""" Returns the slackbuild description. """
|
""" Returns the slackbuild description. """
|
||||||
desc: tuple = self.session.query(
|
desc: tuple = self.session.query(
|
||||||
self.sbo_table.short_description).filter( # type: ignore
|
self.sbo_table.short_description).filter(
|
||||||
self.sbo_table.name == self.name).first()
|
self.sbo_table.name == self.name).first()
|
||||||
|
|
||||||
if desc:
|
if desc:
|
||||||
|
@ -127,7 +130,7 @@ class SBoQueries(Configs):
|
||||||
def files(self) -> str:
|
def files(self) -> str:
|
||||||
""" Returns the files of a slackbuild. """
|
""" Returns the files of a slackbuild. """
|
||||||
files: tuple = self.session.query(
|
files: tuple = self.session.query(
|
||||||
self.sbo_table.files).filter( # type: ignore
|
self.sbo_table.files).filter(
|
||||||
self.sbo_table.name == self.name).first()
|
self.sbo_table.name == self.name).first()
|
||||||
|
|
||||||
if files:
|
if files:
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from typing import Generator
|
||||||
|
|
||||||
from slpkg.configs import Configs
|
from slpkg.configs import Configs
|
||||||
from slpkg.utilities import Utilities
|
from slpkg.utilities import Utilities
|
||||||
from slpkg.sbos.queries import SBoQueries
|
from slpkg.sbos.queries import SBoQueries
|
||||||
|
@ -55,7 +57,7 @@ class SearchPackage(Configs):
|
||||||
print(f'{repository}{self.cyan}{pr[0]}{self.endc} {self.yellow}{version}{self.endc}'
|
print(f'{repository}{self.cyan}{pr[0]}{self.endc} {self.yellow}{version}{self.endc}'
|
||||||
f'{self.green}{desc}{self.endc}')
|
f'{self.green}{desc}{self.endc}')
|
||||||
else:
|
else:
|
||||||
pkg_repo: list = BinQueries('', repo).all_package_names_by_repo()
|
pkg_repo: Generator = BinQueries('', repo).all_package_names_by_repo()
|
||||||
|
|
||||||
for pkg in packages:
|
for pkg in packages:
|
||||||
for pr in pkg_repo:
|
for pr in pkg_repo:
|
||||||
|
@ -71,7 +73,7 @@ class SearchPackage(Configs):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Searching for slackbuilds.
|
# Searching for slackbuilds.
|
||||||
names: list = SBoQueries('').sbos()
|
names: Generator = SBoQueries('').sbos()
|
||||||
for name in names:
|
for name in names:
|
||||||
for package in packages:
|
for package in packages:
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,9 @@ class Upgrade(Configs):
|
||||||
def packages(self) -> Generator[str, None, None]:
|
def packages(self) -> Generator[str, None, None]:
|
||||||
""" Compares version of packages and returns the maximum. """
|
""" Compares version of packages and returns the maximum. """
|
||||||
if self.utils.is_option(self.flag_bin_repository, self.flags):
|
if self.utils.is_option(self.flag_bin_repository, self.flags):
|
||||||
repo_packages: list = BinQueries('', self.repo).all_package_names_by_repo()
|
repo_packages: Generator = BinQueries('', self.repo).all_package_names_by_repo()
|
||||||
else:
|
else:
|
||||||
repo_packages: list = SBoQueries('').sbos()
|
repo_packages: Generator = SBoQueries('').sbos()
|
||||||
|
|
||||||
for pkg in self.all_installed:
|
for pkg in self.all_installed:
|
||||||
inst_package: str = self.utils.split_binary_pkg(pkg)[0]
|
inst_package: str = self.utils.split_binary_pkg(pkg)[0]
|
||||||
|
|
Loading…
Add table
Reference in a new issue