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