Rename for json data

This commit is contained in:
Dimitris Zlatanidis 2024-03-15 21:28:32 +02:00
parent 0be181ec07
commit b79c5b5e24

View file

@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
import shutil
from pathlib import Path
from slpkg.configs import Configs
from slpkg.utilities import Utilities
@ -39,29 +40,18 @@ class RepoInfo(Configs):
self.view_the_repositories_information()
def count_the_packages(self, repository: str) -> int:
sbo_table: dict = {
self.repos.sbo_repo_name: SBoTable,
self.repos.ponce_repo_name: PonceTable
}
if self.utils.is_binary_repo(repository):
count = self.session.query(BinariesTable).where(
BinariesTable.repo == repository).count()
else:
count = self.session.query(sbo_table[repository].id).count()
json_file: Path = Path(f'{self.repos.repositories_path}/{repository}', self.repos.json_file)
repo_data: dict = self.utils.read_json_file(json_file)
count: int = len(repo_data.keys())
self.total_packages += count
return count
def last_repository_updated(self, repository: str) -> str:
date: str = self.session.query(
LastRepoUpdated.date).where(
LastRepoUpdated.repo == repository).first()
if date is None:
date: tuple = ('',)
return date[0]
last_updated_json: Path = Path(f'{self.repos.repositories_path}', self.repos.last_update_json)
dates: dict = self.utils.read_json_file(last_updated_json)
if dates.get(repository):
return dates[repository]
return ''
def view_the_title(self) -> None:
title: str = f'repositories information:'.title()