mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-26 09:58:31 +01:00
Rename for json data
This commit is contained in:
parent
0be181ec07
commit
b79c5b5e24
1 changed files with 9 additions and 19 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue