diff --git a/main/eparser/__constants.py b/main/eparser/__constants.py
index 7f0e3fce..5b3ffa9f 100644
--- a/main/eparser/__constants.py
+++ b/main/eparser/__constants.py
@@ -14,28 +14,18 @@ class Type(Enum):
Cable = "c"
-class Polarization(Enum):
- H = 0
- V = 1
- L = 2
- R = 3
+POLARIZATION = {"0": "H", "1": "V", "2": "L", "3": "R"}
+PLS_MODE = {"0": "Root", "1": "Gold", "2": "Combo"}
-class PlsMode(Enum):
- Root = 0
- Gold = 1
- Combo = 2
+FEC = {"0": "None", "1": "Auto", "2": "1/2",
+ "3": "2/3", "4": "3/4", "5": "5/6",
+ "6": "7/8", "7": "3/5", "8": "4/5",
+ "9": "8/9", "10": "9/10"}
+SYSTEM = {"0": "DVB-S", "1": "DVB-S2"}
-# Symbol rate
-FEC = {0: "None", 1: "Auto", 2: "1/2",
- 3: "2/3", 4: "3/4", 5: "5/6",
- 6: "7/8", 7: "3/5", 8: "4/5",
- 9: "8/9", 10: "9/10"}
-
-SYSTEM = {0: "DVB-S", 1: "DVB-S2"}
-
-MODULATION = {0: "Auto", 1: "QPSK", 2: "8PSK", 3: "16APSK", 5: "32APSK"}
+MODULATION = {"0": "Auto", "1": "QPSK", "2": "8PSK", "3": "16APSK", "5": "32APSK"}
SERVICE_TYPE = {-2: "Unknown", 1: "TV", 2: "Radio", 3: "Data",
10: "Radio", 12: "Data", 22: "TV", 25: "TV",
diff --git a/main/eparser/__init__.py b/main/eparser/__init__.py
index 79a78a6c..f97e5428 100644
--- a/main/eparser/__init__.py
+++ b/main/eparser/__init__.py
@@ -1,6 +1,6 @@
from .lamedb import get_channels
from .bouquets import get_bouquets, get_bouquet
-from .satxml import get_satellites
+from .satxml import get_satellites, write_satellites, Satellite, Transponder
if __name__ == "__main__":
diff --git a/main/eparser/lamedb.py b/main/eparser/lamedb.py
index 87b749ae..2b92ae35 100644
--- a/main/eparser/lamedb.py
+++ b/main/eparser/lamedb.py
@@ -3,7 +3,7 @@
Currently implemented only for satellite channels!!!
Description of format taken from here: http://www.satsupreme.com/showthread.php/194074-Lamedb-format-explained
"""
-from main.eparser.__constants import Polarization, SYSTEM, FEC, Channel, SERVICE_TYPE
+from main.eparser.__constants import POLARIZATION, SYSTEM, FEC, Channel, SERVICE_TYPE
_HEADER = "eDVB services /4/"
_FILE_PATH = "../data/lamedb"
@@ -55,7 +55,7 @@ def parse_channels(*args):
tr = str(transponder)[2:].split(_SEP) # Removing type of DVB transponders (s , t, c) and split
pack = pack[2:] if pack.find(",") < 0 else pack[2:pack.find(",")]
channels.append(Channel(ch[1], pack, SERVICE_TYPE.get(int(data[4]), SERVICE_TYPE[-2]), data[0], tr[0],
- tr[1], Polarization(int(tr[2])).name, FEC[int(tr[3])], SYSTEM[int(tr[6])],
+ tr[1], POLARIZATION[tr[2]], FEC[tr[3]], SYSTEM[tr[6]],
"{}{}.{}".format(*list(tr[4])), ch[0], fav_id.upper()))
return channels
diff --git a/main/eparser/satxml.py b/main/eparser/satxml.py
index e228598d..1256a312 100644
--- a/main/eparser/satxml.py
+++ b/main/eparser/satxml.py
@@ -13,21 +13,82 @@ pls_mode: 0 - Root, 1 - Gold, 2 - Combo
pls_code: 0 - 262142
"""
from collections import namedtuple
-from xml.dom.minidom import parse
-from main.eparser.__constants import Polarization, FEC, SYSTEM, MODULATION, PlsMode
+from xml.dom.minidom import parse, Document
+from main.eparser.__constants import POLARIZATION, FEC, SYSTEM, MODULATION, PLS_MODE
+
# temporary
-__XML_PATH = "../data/satellites.xml"
+__XML_PATH = "../data/"
Satellite = namedtuple("Satellite", ["name", "flags", "position", "transponders"])
Transponder = namedtuple("Transponder", ["frequency", "symbol_rate", "polarization", "fec_inner",
"system", "modulation", "pls_mode", "pls_code", "is_id"])
+__COMMENT = (" File was created in DemonEditor\n\n"
+ "useable flags are\n"
+ " 1: Network Scan\n"
+ " 2: use BAT\n"
+ " 4: use ONIT\n"
+ " 8: skip NITs of known networks\n"
+ " and combinations of this.\n\n"
+
+ "transponder parameters:\n"
+ "polarization: 0 - Horizontal, 1 - Vertical, 2 - Left Circular, 3 - Right Circular\n"
+ "fec_inner: 0 - Auto, 1 - 1/2, 2 - 2_3, 3 - 3/4, 4 - 5/6, 5 - 6/7, 6 - 7/8, 7 - 8/9, "
+ "8 - 3/5, 9 - 4/5, 10 - 9/10\n"
+ "modulation: 0 - Auto, 1 - QPSK, 2 - 8PSK, 3 - 16APSK, 5 - 32APSK\n"
+ "rolloff: 0 - 0.35, 1 - 0.25, 2 - 0.20, 3 - Auto\n"
+ "pilot: 0 - Off, 1 - On, 2 - Auto\n"
+ "inversion: 0 = Off, 1 = On, 2 = Auto (default)\n"
+ "system: 0 = DVB-S, 1 = DVB-S2\n"
+ "is_id: 0 - 255\n"
+ "pls_mode: 0 - Root, 1 - Gold, 2 - Combo\n"
+ "pls_code: 0 - 262142\n\n"
+
+ "Info taken from satellites.xml generated by http://satellites-xml.eu\n")
+
def get_satellites(path):
return parse_satellites(path + "satellites.xml")
+def write_satellites(satellites, data_path):
+ """ Creation satellites.xml file """
+ doc = Document()
+ comment = doc.createComment(__COMMENT)
+ doc.appendChild(comment)
+ root = doc.createElement("satellites")
+ doc.appendChild(root)
+ for sat in satellites:
+ # Create Element
+ sat_child = doc.createElement("sat")
+ sat_child.setAttribute("name", sat.name)
+ sat_child.setAttribute("flags", sat.flags)
+ sat_child.setAttribute("position", sat.position)
+ for tr in sat.transponders:
+ transponder_child = doc.createElement("transponder")
+ transponder_child.setAttribute("frequency", tr.frequency)
+ transponder_child.setAttribute("symbol_rate", tr.symbol_rate)
+ transponder_child.setAttribute("polarization", get_key_by_value(POLARIZATION, tr.polarization))
+ transponder_child.setAttribute("fec_inner", get_key_by_value(FEC, tr.fec_inner))
+ transponder_child.setAttribute("system", get_key_by_value(SYSTEM, tr.system))
+ transponder_child.setAttribute("modulation", get_key_by_value(MODULATION, tr.modulation))
+ if tr.pls_mode:
+ transponder_child.setAttribute("pls_mode", get_key_by_value(PLS_MODE, tr.pls_mode))
+ if tr.pls_code:
+ transponder_child.setAttribute("pls_code", tr.pls_code)
+ if tr.is_id:
+ transponder_child.setAttribute("is_id", tr.is_id)
+ sat_child.appendChild(transponder_child)
+ root.appendChild(sat_child)
+ doc.writexml(open(data_path + "new_satellites.xml", "w"),
+ # indent="",
+ addindent=" ",
+ newl='\n',
+ encoding="iso-8859-1")
+ doc.unlink()
+
+
def parse_transponders(elem):
""" Parsing satellite transponders """
transponders = []
@@ -36,11 +97,11 @@ def parse_transponders(elem):
atr = el.attributes
tr = Transponder(atr["frequency"].value,
atr["symbol_rate"].value,
- Polarization(int(atr["polarization"].value)).name,
- FEC[int(atr["fec_inner"].value)],
- SYSTEM[int(atr["system"].value)],
- MODULATION[int(atr["modulation"].value)],
- PlsMode(int(atr["pls_mode"].value)).name if "pls_mode" in atr else None,
+ POLARIZATION[atr["polarization"].value],
+ FEC[atr["fec_inner"].value],
+ SYSTEM[atr["system"].value],
+ MODULATION[atr["modulation"].value],
+ PLS_MODE[atr["pls_mode"].value] if "pls_mode" in atr else None,
atr["pls_code"].value if "pls_code" in atr else None,
atr["is_id"].value if "is_id" in atr else None)
transponders.append(tr)
@@ -65,5 +126,16 @@ def parse_satellites(path):
return satellites
+def get_key_by_value(dictionary, value):
+ for k, v in dictionary.items():
+ if v == value:
+ return k
+
+
if __name__ == "__main__":
- pass
+ sats = get_satellites(__XML_PATH)
+ for sat in sats:
+ trnsp = sat.transponders
+ for tr in trnsp:
+ if tr.pls_mode or tr.pls_code or tr.is_id:
+ print(tr, sat.name)
diff --git a/main/ui/main_app_window.py b/main/ui/main_app_window.py
index d8350382..26961e47 100644
--- a/main/ui/main_app_window.py
+++ b/main/ui/main_app_window.py
@@ -127,7 +127,10 @@ def on_to_fav_move(view):
""" Move items from main to fav list """
selection = get_selection(view)
if selection:
- receive_selection(view=__fav_view, drop_info=None, data=selection)
+ if is_bouquet_selected():
+ receive_selection(view=__fav_view, drop_info=None, data=selection)
+ else:
+ show_message_dialog("Error. No bouquet is selected!")
def get_selection(view):
@@ -189,7 +192,10 @@ def on_fav_tree_view_drag_data_get(view, drag_context, data, info, time):
def on_fav_tree_view_drag_data_received(view, drag_context, x, y, data, info, time):
""" DnD """
- receive_selection(view=view, drop_info=view.get_dest_row_at_pos(x, y), data=data.get_text())
+ if is_bouquet_selected():
+ receive_selection(view=view, drop_info=view.get_dest_row_at_pos(x, y), data=data.get_text())
+ else:
+ show_message_dialog("Error. No bouquet is selected!")
def on_view_popup_menu(menu, event):
@@ -231,26 +237,44 @@ def on_data_open(model):
def on_services_selection(model, path, column):
- delete_selection(__fav_view, __bouquets_view)
+ delete_selection(__fav_view)
def on_fav_selection(model, path, column):
- delete_selection(__services_view, __bouquets_view)
+ delete_selection(__services_view)
def on_bouquets_selection(model, path, column):
+ __fav_model.clear()
if len(path) > 1:
delete_selection(__services_view)
tree_iter = model.get_iter(path)
name = model.get_value(tree_iter, 0)
# 'tv' Temporary! It is necessary to implement a row type attribute.
bq = get_bouquet(__options["data_dir_path"], name, SERVICE_TYPE[1].lower())
- __fav_model.clear()
for num, ch_id in enumerate(bq):
channel = __channels.get(ch_id, None)
__fav_model.append((num + 1, channel[0], channel[2], channel[9]))
+def is_bouquet_selected():
+ """ Checks whether the bouquet is selected """
+ selection = __bouquets_view.get_selection()
+ model, path = selection.get_selected_rows()
+ if len(path) < 1:
+ return False
+ return not model.iter_has_child(model.get_iter(path))
+
+
+def show_message_dialog(text):
+ builder = Gtk.Builder()
+ builder.add_from_file("ui/main_window.glade")
+ dialog = builder.get_object("message_dialog")
+ dialog.set_markup(text)
+ dialog.run()
+ dialog.destroy()
+
+
def delete_selection(view, *args):
""" Used for clear selection on given view(s) """
for v in [view, *args]:
diff --git a/main/ui/main_window.glade b/main/ui/main_window.glade
index f6b8ef89..1b7e1f7f 100644
--- a/main/ui/main_window.glade
+++ b/main/ui/main_window.glade
@@ -1022,8 +1022,11 @@
main_window
DemonEditor
0.1 Pre-alpha
+ 2017 Dmitriy Yefremov
+
Enigma2 channel list editor for GNU/Linux
- Dmitriy Yefremov
+ Dmitriy Yefremov
+
accessories-text-editor
mit-x11
@@ -1048,12 +1051,15 @@
-