mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2026-07-06 08:48:35 +02:00
write bouquets skeleton for neutrino
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from xml.dom.minidom import parse
|
||||
from enum import Enum
|
||||
from xml.dom.minidom import parse, Document
|
||||
|
||||
from ..ecommons import Bouquets, Bouquet, BouquetService, BqServiceType
|
||||
|
||||
@@ -6,8 +7,14 @@ _FILE = "bouquets.xml"
|
||||
_U_FILE = "ubouquets.xml"
|
||||
|
||||
|
||||
class BqType(Enum):
|
||||
BOUQUET = "bouquet"
|
||||
TV = "tv"
|
||||
|
||||
|
||||
def get_bouquets(path):
|
||||
return parse_bouquets(path + _FILE, "User bouquets", "bouquet"), parse_bouquets(path + _U_FILE, "User TV", "tv")
|
||||
return (parse_bouquets(path + _FILE, "User bouquets", BqType.BOUQUET.value),
|
||||
parse_bouquets(path + _U_FILE, "User TV", BqType.TV.value))
|
||||
|
||||
|
||||
def parse_bouquets(file, name, bq_type):
|
||||
@@ -38,4 +45,34 @@ def parse_bouquets(file, name, bq_type):
|
||||
|
||||
|
||||
def write_bouquets(path, bouquets):
|
||||
pass
|
||||
for bq in bouquets:
|
||||
bq_type = BqType(bq.type)
|
||||
# write_bouquet(path + (_FILE if bq_type is BqType.BOUQUET else _U_FILE), bq)
|
||||
write_bouquet(path + "_" + (_FILE if bq_type is BqType.BOUQUET else _U_FILE), bq) # temporary!
|
||||
|
||||
|
||||
def write_bouquet(file, bouquet):
|
||||
doc = Document()
|
||||
root = doc.createElement("zapit")
|
||||
doc.appendChild(root)
|
||||
comment = doc.createComment(" File was created in DemonEditor. Enjoy watching! ")
|
||||
doc.appendChild(comment)
|
||||
|
||||
for bq in bouquet.bouquets:
|
||||
bq_elem = doc.createElement("Bouquet")
|
||||
bq_elem.setAttribute("name", bq.name)
|
||||
root.appendChild(bq_elem)
|
||||
|
||||
for srv in bq.services:
|
||||
on, sep, ssid = srv.fav_id.partition(":")
|
||||
srv_elem = doc.createElement("S")
|
||||
srv_elem.setAttribute("i", ssid)
|
||||
srv_elem.setAttribute("n", srv.service)
|
||||
srv_elem.setAttribute("t", srv.transponder.split(":")[0].lstrip("0"))
|
||||
srv_elem.setAttribute("on", on)
|
||||
srv_elem.setAttribute("s", srv.pos.replace(".", ""))
|
||||
srv_elem.setAttribute("frq", srv.freq[:-3])
|
||||
srv_elem.setAttribute("l", "0") # temporary !!!
|
||||
bq_elem.appendChild(srv_elem)
|
||||
|
||||
doc.writexml(open(file, "w"), addindent=" ", newl="\n", encoding="UTF-8")
|
||||
|
||||
Reference in New Issue
Block a user