mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-13 22:15:48 +00:00
more properties to be shown in status pages
This commit is contained in:
@ -23,7 +23,7 @@ from typing import Callable, Dict, Iterable
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.report.report import Report
|
||||
from ahriman.core.util import pretty_size, pretty_datetime
|
||||
from ahriman.core.util import pretty_datetime, pretty_size
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.sign_settings import SignSettings
|
||||
|
||||
@ -38,7 +38,18 @@ class HTML(Report):
|
||||
link_path - prefix fo packages to download, string, required
|
||||
has_package_signed - True in case if package sign enabled, False otherwise, required
|
||||
has_repo_signed - True in case if repository database sign enabled, False otherwise, required
|
||||
packages - sorted list of packages properties: archive_size, build_date, filename, installed_size, name, version. Required
|
||||
packages - sorted list of packages properties, required
|
||||
* architecture, string
|
||||
* archive_size, pretty printed size, string
|
||||
* build_date, pretty printed datetime, string
|
||||
* description, string
|
||||
* filename, string,
|
||||
* groups, sorted list of strings
|
||||
* installed_size, pretty printed datetime, string
|
||||
* licenses, sorted list of strings
|
||||
* name, string
|
||||
* url, string
|
||||
* version, string
|
||||
pgp_key - default PGP key ID, string, optional
|
||||
repository - repository name, string, required
|
||||
|
||||
@ -48,7 +59,7 @@ class HTML(Report):
|
||||
:ivar pgp_key: default PGP key
|
||||
:ivar report_path: output path to html report
|
||||
:ivar sign_targets: targets to sign enabled in configuration
|
||||
:ivar tempate_path: path to directory with jinja templates
|
||||
:ivar template_path: path to directory with jinja templates
|
||||
"""
|
||||
|
||||
def __init__(self, architecture: str, config: Configuration) -> None:
|
||||
@ -83,11 +94,16 @@ class HTML(Report):
|
||||
|
||||
content = [
|
||||
{
|
||||
"architecture": properties.architecture or "",
|
||||
"archive_size": pretty_size(properties.archive_size),
|
||||
"build_date": pretty_datetime(properties.build_date),
|
||||
"description": properties.description or "",
|
||||
"filename": properties.filename,
|
||||
"groups": properties.groups,
|
||||
"installed_size": pretty_size(properties.installed_size),
|
||||
"licenses": properties.licenses,
|
||||
"name": package,
|
||||
"url": properties.url or "",
|
||||
"version": base.version
|
||||
} for base in packages for package, properties in base.packages.items()
|
||||
]
|
||||
|
@ -59,6 +59,13 @@ class Package:
|
||||
"""
|
||||
return f"{self.aur_url}/{self.base}.git"
|
||||
|
||||
@property
|
||||
def groups(self) -> List[str]:
|
||||
"""
|
||||
:return: sum of groups per each package
|
||||
"""
|
||||
return sorted(set(sum([package.groups for package in self.packages.values()], start=[])))
|
||||
|
||||
@property
|
||||
def is_single_package(self) -> bool:
|
||||
"""
|
||||
@ -78,6 +85,13 @@ class Package:
|
||||
or self.base.endswith("-hg")\
|
||||
or self.base.endswith("-svn")
|
||||
|
||||
@property
|
||||
def licenses(self) -> List[str]:
|
||||
"""
|
||||
:return: sum of licenses per each package
|
||||
"""
|
||||
return sorted(set(sum([package.licenses for package in self.packages.values()], start=[])))
|
||||
|
||||
@property
|
||||
def web_url(self) -> str:
|
||||
"""
|
||||
@ -95,8 +109,8 @@ class Package:
|
||||
:return: package properties
|
||||
"""
|
||||
package = pacman.handle.load_pkg(str(path))
|
||||
properties = PackageDescription(package.size, package.builddate, path.name, package.isize)
|
||||
return cls(package.base, package.version, aur_url, {package.name: properties})
|
||||
return cls(package.base, package.version, aur_url,
|
||||
{package.name: PackageDescription.from_package(package, path)})
|
||||
|
||||
@classmethod
|
||||
def from_aur(cls: Type[Package], name: str, aur_url: str) -> Package:
|
||||
|
@ -17,25 +17,38 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from dataclasses import dataclass
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
from pyalpm import Package # type: ignore
|
||||
from typing import List, Optional, Type
|
||||
|
||||
|
||||
@dataclass
|
||||
class PackageDescription:
|
||||
"""
|
||||
package specific properties
|
||||
:ivar architecture: package architecture
|
||||
:ivar archive_size: package archive size
|
||||
:ivar build_date: package build date
|
||||
:ivar description: package description
|
||||
:ivar filename: package archive name
|
||||
:ivar groups: package groups
|
||||
:ivar installed_size: package installed size
|
||||
:ivar licenses: package licenses list
|
||||
:ivar url: package url
|
||||
"""
|
||||
|
||||
architecture: Optional[str] = None
|
||||
archive_size: Optional[int] = None
|
||||
build_date: Optional[int] = None
|
||||
description: Optional[str] = None
|
||||
filename: Optional[str] = None
|
||||
groups: List[str] = field(default_factory=list)
|
||||
installed_size: Optional[int] = None
|
||||
licenses: List[str] = field(default_factory=list)
|
||||
url: Optional[str] = None
|
||||
|
||||
@property
|
||||
def filepath(self) -> Optional[Path]:
|
||||
@ -43,3 +56,22 @@ class PackageDescription:
|
||||
:return: path object for current filename
|
||||
"""
|
||||
return Path(self.filename) if self.filename is not None else None
|
||||
|
||||
@classmethod
|
||||
def from_package(cls: Type[PackageDescription], package: Package, path: Path) -> PackageDescription:
|
||||
"""
|
||||
construct class from alpm package class
|
||||
:param package: alpm generated object
|
||||
:param path: path to package archive
|
||||
:return: package properties based on tarball
|
||||
"""
|
||||
return PackageDescription(
|
||||
architecture=package.arch,
|
||||
archive_size=package.size,
|
||||
build_date=package.builddate,
|
||||
description=package.desc,
|
||||
filename=path.name,
|
||||
groups=package.groups,
|
||||
installed_size=package.isize,
|
||||
licenses=package.licenses,
|
||||
url=package.url)
|
||||
|
@ -34,10 +34,20 @@ class IndexView(BaseView):
|
||||
It uses jinja2 templates for report generation, the following variables are allowed:
|
||||
|
||||
architecture - repository architecture, string, required
|
||||
packages - sorted list of packages properties: base, packages (sorted list), status,
|
||||
timestamp, version, web_url. Required
|
||||
packages - sorted list of packages properties, required
|
||||
* base, string
|
||||
* groups, sorted list of strings
|
||||
* licenses, sorted list of strings
|
||||
* packages, sorted list of strings
|
||||
* status, string based on enum value
|
||||
* timestamp, pretty printed datetime, string
|
||||
* version, string
|
||||
* web_url, string
|
||||
repository - repository name, string, required
|
||||
service - service status properties: status, status_color, timestamp. Required
|
||||
service - service status properties, required
|
||||
* status, string based on enum value
|
||||
* status_color, string based on enum value
|
||||
* timestamp, pretty printed datetime, string
|
||||
version - ahriman version, string, required
|
||||
"""
|
||||
|
||||
@ -51,6 +61,8 @@ class IndexView(BaseView):
|
||||
packages = [
|
||||
{
|
||||
"base": package.base,
|
||||
"groups": package.groups,
|
||||
"licenses": package.licenses,
|
||||
"packages": list(sorted(package.packages)),
|
||||
"status": status.status.value,
|
||||
"timestamp": pretty_datetime(status.timestamp),
|
||||
|
Reference in New Issue
Block a user