mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-27 09:58:10 +01:00
Updated for read json
This commit is contained in:
parent
e347f1913f
commit
302a404796
3 changed files with 39 additions and 22 deletions
|
@ -109,7 +109,7 @@ class InstallData(Configs):
|
|||
path_changelog: Path = Path(self.repos.sbo_repo_path, self.repos.sbo_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.sbo_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.sbo_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.sbo_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
@ -188,7 +188,7 @@ class InstallData(Configs):
|
|||
path_changelog: Path = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.ponce_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.ponce_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.ponce_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
@ -283,7 +283,7 @@ class InstallData(Configs):
|
|||
path_changelog: Path = Path(self.repos.slack_repo_path, self.repos.slack_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.slack_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.slack_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.slack_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
@ -378,7 +378,7 @@ class InstallData(Configs):
|
|||
path_changelog: Path = Path(self.repos.slack_extra_repo_path, self.repos.slack_extra_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.slack_extra_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.slack_extra_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.slack_extra_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
@ -473,7 +473,7 @@ class InstallData(Configs):
|
|||
path_changelog: Path = Path(self.repos.slack_patches_repo_path, self.repos.slack_patches_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.slack_patches_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.slack_patches_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.slack_patches_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
@ -573,7 +573,7 @@ class InstallData(Configs):
|
|||
path_changelog: Path = Path(self.repos.alien_repo_path, self.repos.alien_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.alien_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.alien_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.alien_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
@ -668,7 +668,7 @@ class InstallData(Configs):
|
|||
path_changelog: Path = Path(self.repos.multilib_repo_path, self.repos.multilib_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.multilib_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.multilib_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.multilib_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
@ -763,7 +763,7 @@ class InstallData(Configs):
|
|||
path_changelog: Path = Path(self.repos.restricted_repo_path, self.repos.restricted_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.restricted_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.restricted_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.restricted_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
@ -859,7 +859,7 @@ class InstallData(Configs):
|
|||
path_changelog: Path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.gnome_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.gnome_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.gnome_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
@ -954,7 +954,7 @@ class InstallData(Configs):
|
|||
path_changelog: Path = Path(self.repos.msb_repo_path, self.repos.msb_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.msb_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.msb_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.msb_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
@ -1049,7 +1049,7 @@ class InstallData(Configs):
|
|||
path_changelog: Path = Path(self.repos.csb_repo_path, self.repos.csb_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.csb_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.csb_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.csb_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
@ -1145,7 +1145,7 @@ class InstallData(Configs):
|
|||
path_changelog: Path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.conraid_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.conraid_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.conraid_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
@ -1245,7 +1245,7 @@ class InstallData(Configs):
|
|||
path_changelog: Path = Path(self.repos.slackdce_repo_path, self.repos.slackdce_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.conraid_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.slackdce_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.slackdce_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
@ -1345,7 +1345,7 @@ class InstallData(Configs):
|
|||
path_changelog: Path = Path(self.repos.slackonly_repo_path, self.repos.slackonly_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.slackonly_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.slackonly_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.slackonly_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
@ -1453,7 +1453,7 @@ class InstallData(Configs):
|
|||
path_changelog: Path = Path(self.repos.salixos_repo_path, self.repos.salixos_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.salixos_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.salixos_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.salixos_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
@ -1561,7 +1561,7 @@ class InstallData(Configs):
|
|||
path_changelog: Path = Path(self.repos.salixos_extra_repo_path, self.repos.salixos_extra_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.salixos_extra_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.salixos_extra_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.salixos_extra_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
@ -1672,7 +1672,7 @@ class InstallData(Configs):
|
|||
self.repos.salixos_patches_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.salixos_patches_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.salixos_patches_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.salixos_patches_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
@ -1780,7 +1780,7 @@ class InstallData(Configs):
|
|||
path_changelog: Path = Path(self.repos.slackel_repo_path, self.repos.slackel_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.slackel_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.slackel_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.slackel_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
@ -1888,7 +1888,7 @@ class InstallData(Configs):
|
|||
path_changelog: Path = Path(self.repos.slint_repo_path, self.repos.slint_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.slint_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.slint_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.slint_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
@ -1983,7 +1983,7 @@ class InstallData(Configs):
|
|||
path_changelog: Path = Path(self.repos.pprkut_repo_path, self.repos.pprkut_repo_changelog)
|
||||
self.write_last_update(path_changelog, self.repos.pprkut_repo_name)
|
||||
|
||||
data_file: Path = Path(self.repos.pprkut_repo_path, self.repos.data_json)
|
||||
data_file: Path = Path(self.repos.pprkut_repo_path, self.repos.json_file)
|
||||
data_file.write_text(json.dumps(data, indent=4))
|
||||
|
||||
self.view_done_message()
|
||||
|
|
|
@ -303,8 +303,8 @@ class Menu(Configs):
|
|||
if self.repository != '*' and not self.data:
|
||||
print('\rDatabase loading... ', end='')
|
||||
|
||||
json_data: Path = Path(f'{self.repos.repositories_path}/{self.repository}', self.repos.data_json)
|
||||
self.data: dict = json.loads(json_data.read_text())
|
||||
json_file: Path = Path(f'{self.repos.repositories_path}/{self.repository}', self.repos.json_file)
|
||||
self.data: dict = self.utils.read_json_file(json_file)
|
||||
|
||||
print(f'{self.yellow}{self.ascii.done}{self.endc}')
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ from __future__ import annotations
|
|||
import os
|
||||
import re
|
||||
import time
|
||||
import json
|
||||
import shutil
|
||||
import fnmatch
|
||||
import subprocess
|
||||
|
@ -192,3 +193,19 @@ class Utilities(Configs):
|
|||
packages.remove(package)
|
||||
break
|
||||
return packages
|
||||
|
||||
def read_json_file(self, file: Path) -> dict:
|
||||
"""
|
||||
Read JSON data from the file.
|
||||
Args:
|
||||
file: Path file for reading.
|
||||
Returns:
|
||||
Dictionary with data.
|
||||
"""
|
||||
json_data: dict = {}
|
||||
try:
|
||||
json_data: dict = json.loads(file.read_text(encoding='utf-8'))
|
||||
except FileNotFoundError:
|
||||
print(f'\n{self.prog_name}: Error file {file} not found.\n')
|
||||
raise SystemExit(1)
|
||||
return json_data
|
||||
|
|
Loading…
Reference in a new issue