showing flags in the service details dialog

This commit is contained in:
DYefremov
2018-02-19 23:18:01 +03:00
parent 25ee7f3538
commit f70913832c
5 changed files with 35 additions and 9 deletions

View File

@@ -35,7 +35,13 @@ class Type(Enum):
class Flag(Enum):
""" Service flags """
""" Service flags
K - last bit (1)
H - second from end (10)
P - third (100)
N - seventh (1000000)
"""
KEEP = 1 # Do not automatically update the services parameters.
HIDE = 2
PIDS = 4 # Always use the cached instead of current pids.
@@ -43,8 +49,20 @@ class Flag(Enum):
NEW = 40 # Marked as new at the last scan
@staticmethod
def hide_values():
return 2, 3, 6, 7, 10, 42, 43, 46, 47
def is_hide(value: int):
return value & 1 << 1
@staticmethod
def is_keep(value: int):
return value & 1 << 0
@staticmethod
def is_pids(value: int):
return value & 1 << 2
@staticmethod
def is_new(value: int):
return value & 1 << 5
class Inversion(Enum):

View File

@@ -52,7 +52,7 @@ def to_bouquet_id(ch):
def get_bouquet(path, name, bq_type):
""" Parsing services ids from bouquet file """
with open(path + "userbouquet.{}.{}".format(name, bq_type), encoding="utf-8") as file:
with open(path + "userbouquet.{}.{}".format(name, bq_type), encoding="utf-8", errors="replace") as file:
chs_list = file.read()
services = []
srvs = list(filter(None, chs_list.split("\n#SERVICE"))) # filtering ['']
@@ -70,7 +70,7 @@ def get_bouquet(path, name, bq_type):
def parse_bouquets(path, bq_name, bq_type):
with open(path + bq_name) as file:
with open(path + bq_name, encoding="utf-8", errors="replace") as file:
lines = file.readlines()
bouquets = None
nm_sep = "#NAME"

View File

@@ -101,7 +101,7 @@ def parse_services(services, transponders, path):
all_flags = ch[2].split(",")
coded = CODED_ICON if list(filter(lambda x: x.startswith("C:"), all_flags)) else None
flags = list(filter(lambda x: x.startswith("f:"), all_flags))
hide = HIDE_ICON if flags and int(flags[0][2:]) in Flag.hide_values() else None
hide = HIDE_ICON if flags and Flag.is_hide(int(flags[0][2:])) else None
locked = LOCKED_ICON if fav_id in blacklist else None
package = list(filter(lambda x: x.startswith("p:"), all_flags))

View File

@@ -223,11 +223,11 @@ def set_hide(channels, model, paths):
value = int(flag[2:]) if flag else 0
if not hide:
if value in Flag.hide_values():
if Flag.is_hide(value):
continue # skip if already hidden
value += Flag.HIDE.value
else:
if value not in Flag.hide_values():
if not Flag.is_hide(value):
continue # skip if already allowed to show
value -= Flag.HIDE.value

View File

@@ -3,7 +3,7 @@ from functools import lru_cache
from app.commons import run_idle
from app.eparser import Service, get_satellites
from app.eparser.ecommons import MODULATION, Inversion, ROLL_OFF, Pilot
from app.eparser.ecommons import MODULATION, Inversion, ROLL_OFF, Pilot, Flag
from app.properties import Profile
from app.ui.dialogs import show_dialog, DialogType
from . import Gtk, UI_RESOURCES_PATH
@@ -117,6 +117,14 @@ class ServiceDetailsDialog:
if cas:
self._cas_entry.set_text(",".join(cas))
flags = list(filter(lambda x: x.startswith("f:"), flags))
if flags:
value = int(flags[0][2:])
self._keep_check_button.set_active(Flag.is_keep(value))
self._hide_check_button.set_active(Flag.is_hide(value))
self._use_pids_check_button.set_active(Flag.is_pids(value))
self._new_check_button.set_active(Flag.is_new(value))
pids = list(filter(lambda x: x.startswith("c:"), flags))
if pids:
for pid in pids: