mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2026-03-05 12:01:45 +01:00
opening lamedb5
This commit is contained in:
@@ -10,9 +10,9 @@ from .neutrino.services import get_services as get_neutrino_services, write_serv
|
||||
from .satxml import get_satellites, write_satellites
|
||||
|
||||
|
||||
def get_services(data_path, profile):
|
||||
def get_services(data_path, profile, format_version):
|
||||
if profile is Profile.ENIGMA_2:
|
||||
return get_enigma_services(data_path)
|
||||
return get_enigma_services(data_path, format_version)
|
||||
elif profile is Profile.NEUTRINO_MP:
|
||||
return get_neutrino_services(data_path)
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ _SEP = ":" # separator
|
||||
_FILE_NAME = "lamedb"
|
||||
|
||||
|
||||
def get_services(path):
|
||||
return parse(path)
|
||||
def get_services(path, format_version):
|
||||
return parse(path, format_version)
|
||||
|
||||
|
||||
def write_services(path, services):
|
||||
@@ -41,9 +41,13 @@ def write_services(path, services):
|
||||
file.writelines(lines)
|
||||
|
||||
|
||||
def parse(path, version=None):
|
||||
def parse(path, version=4):
|
||||
""" Parsing lamedb """
|
||||
return parse_v4(path)
|
||||
if version == 4:
|
||||
return parse_v4(path)
|
||||
elif version == 5:
|
||||
return parse_v5(path)
|
||||
raise SyntaxError("Unsupported version of the format.")
|
||||
|
||||
|
||||
def parse_v4(path):
|
||||
@@ -62,7 +66,7 @@ def parse_v4(path):
|
||||
transponders, sep, services = services.partition("services") # 2 step
|
||||
services, sep, _ = services.partition("\nend") # 3 step
|
||||
|
||||
return parse_services(services.split("\n"), transponders.split("/"), path)
|
||||
return parse_services(services.split("\n"), parse_transponders(transponders.split("/")), path)
|
||||
|
||||
|
||||
def parse_v5(path):
|
||||
@@ -79,7 +83,7 @@ def parse_v5(path):
|
||||
srvs.extend(l.strip("s:").split(",", 2))
|
||||
elif l.startswith("t:"):
|
||||
tr, srv = l.split(",")
|
||||
trs[tr.strip("t:")] = srv.strip()
|
||||
trs[tr.strip("t:")] = srv.strip().replace(":", " ", 1)
|
||||
|
||||
return parse_services(srvs, trs, path)
|
||||
|
||||
@@ -98,7 +102,6 @@ def parse_transponders(arg):
|
||||
def parse_services(services, transponders, path):
|
||||
""" Parsing channels """
|
||||
channels = []
|
||||
transponders = parse_transponders(transponders)
|
||||
blacklist = str(get_blacklist(path))
|
||||
srv = split(services, 3)
|
||||
if srv[0][0] == "": # remove first empty element
|
||||
|
||||
@@ -173,7 +173,7 @@ class MainAppWindow:
|
||||
self._profile_label = builder.get_object("profile_label")
|
||||
self._ip_label = builder.get_object("ip_label")
|
||||
self._ip_label.set_text(self._options.get(self._profile).get("host"))
|
||||
self._profile_label.set_text("Enigma2 v.4" if Profile(self._profile) is Profile.ENIGMA_2 else "Neutrino-MP")
|
||||
self.update_profile_label()
|
||||
# dynamically active elements depending on the selected view
|
||||
self._tool_elements = {k: builder.get_object(k) for k in self._DYNAMIC_ELEMENTS}
|
||||
self._picons_download_tool_button = builder.get_object("picons_download_tool_button")
|
||||
@@ -589,7 +589,8 @@ class MainAppWindow:
|
||||
|
||||
def append_services(self, data_path):
|
||||
try:
|
||||
services = get_services(data_path, Profile(self._profile))
|
||||
profile = Profile(self._profile)
|
||||
services = get_services(data_path, profile, self.get_format_version() if profile is Profile.ENIGMA_2 else 0)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
log("Append services error: " + str(e))
|
||||
@@ -736,12 +737,14 @@ class MainAppWindow:
|
||||
if response != Gtk.ResponseType.CANCEL:
|
||||
profile = self._options.get("profile")
|
||||
self._ip_label.set_text(self._options.get(profile).get("host"))
|
||||
|
||||
if profile != self._profile:
|
||||
self._profile_label.set_text("Enigma 2 v.4" if Profile(profile) is Profile.ENIGMA_2 else "Neutrino-MP")
|
||||
self._profile = profile
|
||||
self.clear_current_data()
|
||||
self.update_services_counts()
|
||||
|
||||
self.update_profile_label()
|
||||
|
||||
def on_tree_view_key_release(self, view, event):
|
||||
""" Handling keystrokes """
|
||||
key = event.keyval
|
||||
@@ -1130,6 +1133,16 @@ class MainAppWindow:
|
||||
gen_bouquets(self._services_view, self._bouquets_view, self._main_window, g_type, self._TV_TYPES,
|
||||
Profile(self._profile), self.append_bouquet)
|
||||
|
||||
def update_profile_label(self):
|
||||
profile = Profile(self._profile)
|
||||
if profile is Profile.ENIGMA_2:
|
||||
self._profile_label.set_text("Enigma2 v.{}".format(self.get_format_version()))
|
||||
elif profile is Profile.NEUTRINO_MP:
|
||||
self._profile_label.set_text("Neutrino-MP")
|
||||
|
||||
def get_format_version(self):
|
||||
return 5 if self._options.get(self._profile).get("v5_support", False) else 4
|
||||
|
||||
|
||||
def start_app():
|
||||
MainAppWindow()
|
||||
|
||||
Reference in New Issue
Block a user