refactor for Pamac 9.0

source formatting
parent 699191e1
__version__ = "1.1.4"
__version__ = "2.0dev1"
__all__ = ["browser", "__version__", "translation", "constants", "config"]
......@@ -23,11 +23,13 @@ from application_utility.browser.app_config import AppConfig
from application_utility.browser.application_browser import ApplicationBrowser
from application_utility.__init__ import __version__
from application_utility.translation import custom_help_formatter
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GObject, GdkPixbuf
_ = custom_help_formatter.CustomHelpFormatter
# print(dir(gi.repository.Gtk))
# cat /usr/lib/python3.7/site-packages/gi/overrides/Gtk.py
# doc api
......
......@@ -27,7 +27,7 @@ import glob
import logging
import subprocess
gi.require_version("Pamac", "9.0")
gi.require_version("Pamac", "8.0")
from gi.repository import Pamac
from application_utility.translation import i18n
......
......@@ -24,6 +24,7 @@ import sys
from .config import Config
from application_utility.translation import i18n
_ = i18n.language.gettext
......
......@@ -32,10 +32,12 @@ from application_utility.constants import txt
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
# /usr/share/gir-10.0/Pamac-9.0.gir
gi.require_version("Pamac", "9.0")
from gi.repository import Pamac
from application_utility.translation import i18n
_ = i18n.language.gettext
# Applications class constants
......
......@@ -27,6 +27,7 @@ import requests
# from requests.exceptions import ConnectionError
from application_utility.translation import i18n
_ = i18n.language.gettext
from application_utility.constants import txt
......@@ -66,7 +67,7 @@ class BaseConfig:
raise NotImplementedError
@staticmethod
def read_json_file(filename: str, dictionary: bool = True) ->list:
def read_json_file(filename: str, dictionary: bool = True) -> list:
"""
Read json data from file
"""
......@@ -85,17 +86,17 @@ class BaseConfig:
return result
@staticmethod
def get_arg_value(key: str, default: str = "") ->str:
def get_arg_value(key: str, default: str = "") -> str:
"""read param value"""
for arg in sys.argv:
if arg.lower().startswith(f"--{key}="):
value = arg[len(key)+3:]
value = arg[len(key) + 3:]
if value.startswith('"'):
value = value[1:-1]
return value
return default
def get_datafile(self, filedefault: str, key: str = "file") ->str:
def get_datafile(self, filedefault: str, key: str = "file") -> str:
"""read param,
if value is url then download file
return empty if not exists
......@@ -109,7 +110,7 @@ class BaseConfig:
logging.warning("File not exist ? %s", arg_file)
@staticmethod
def download_file(src: str) ->str:
def download_file(src: str) -> str:
"""download file in tmp file
return file name
"""
......@@ -119,7 +120,7 @@ class BaseConfig:
logging.info("iso json to use: %s", src)
request = requests.get(src, allow_redirects=True)
# TODO create /tmp/m-apps ?
tmp_file = tempfile.NamedTemporaryFile(delete=False) # dir="m-apps"
tmp_file = tempfile.NamedTemporaryFile(delete=False) # dir="m-apps"
tmp_file.write(request.content)
tmp_file.close()
return tmp_file.name
......@@ -132,7 +133,7 @@ class BaseConfig:
return None
@staticmethod
def get_desktop() ->str:
def get_desktop() -> str:
""" get local desktop"""
desktop = BaseConfig.get_arg_value("desktop")
if not desktop:
......@@ -158,33 +159,33 @@ class BaseConfig:
return desktop.lower()
@staticmethod
def get_manjaro_desktop(find_desktop: str, prefix: bool = True) ->str:
def get_manjaro_desktop(find_desktop: str, prefix: bool = True) -> str:
"""return generator on all manjaro desktop available"""
desks = ["xfce", "kde", "gnome"]
if find_desktop in desks:
if prefix:
find_desktop = "manjaro/"+find_desktop
find_desktop = "manjaro/" + find_desktop
return find_desktop
desks = ["openbox", "mate", "deepin", "bspwm", "cinnamon", "lxqt", "awesome", "budgie", "lxde", "i3", "webdad"]
if find_desktop in desks:
if prefix:
find_desktop = "community/"+find_desktop
find_desktop = "community/" + find_desktop
return find_desktop
return ""
#TODO to remove or move to tests
# TODO to remove or move to tests
@staticmethod
def get_desktop_tests():
for test in ["LXDE", "lxde", 'MATE', 'mate', "budgie-desktop", "/usr/share/xsessions/plasma"]:
os.environ["DESKTOP_SESSION"] = test
desktop = BaseConfig.get_desktop()
print("desktop", desktop, "for env:"+test)
print("desktop", desktop, "for env:" + test)
desktop = BaseConfig.get_manjaro_desktop(desktop)
print("\t", desktop)
def get_iso_filename(self) ->str:
def get_iso_filename(self) -> str:
"""get filename from env, if url create temp file
can use parameter:
can use parameter:
app.py --iso="https://gitlab.manjaro.org/papajoke/application-utility/raw/dev/share/kde.json"
app.py --iso="/home/****.json"
app.py --desktop=gnome
......@@ -208,6 +209,6 @@ class BaseConfig:
else:
return src
#test desktops
#BaseConfig.get_desktop_tests()
#exit(0)
# test desktops
# BaseConfig.get_desktop_tests()
# exit(0)
......@@ -28,6 +28,7 @@ from .data import Data
from .base_config import BaseConfig
from application_utility.translation import i18n
_ = i18n.language.gettext
......@@ -64,7 +65,7 @@ class Config(BaseConfig, Data):
iso_file = self.get_iso_filename()
if iso_file:
# iso to merge found
#iso_json = json.loads(iso_file)
# iso_json = json.loads(iso_file)
with open(iso_file, "rb") as infile:
iso_json = json.loads(
infile.read().decode("utf8"),
......@@ -80,4 +81,4 @@ class Config(BaseConfig, Data):
self.save_apps_to_json(self._MERGE_FILE)
# load complete json
self.load_from_file(self._MERGE_FILE)
#exit(0)
# exit(0)
......@@ -27,10 +27,12 @@ from typing import Iterator
import gi
# /usr/share/gir-10.0/Pamac-9.0.gir
gi.require_version("Pamac", "9.0")
from gi.repository import Pamac
from application_utility.translation import i18n
_ = i18n.language.gettext
......
......@@ -18,6 +18,7 @@
# fhdk
from application_utility.translation import i18n
_ = i18n.language.gettext
......
......@@ -26,6 +26,7 @@ from .config import Config
from .exceptions import NoAppInIsoError
from application_utility.translation import i18n
_ = i18n.language.gettext
......
......@@ -23,6 +23,7 @@ import os
from .config import Config
from application_utility.translation import i18n
_ = i18n.language.gettext
......
......@@ -55,8 +55,3 @@ DOWNLOAD_COMPLETE = _("App data has been downloaded and list is reset")
SYSTEM_UPDATED = _("Your system has been updated")
DOWNLOAD_NA = _("Download not available")
SERVER_NA = _("server could not be reached")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment