예제 #1
0
 def add_theme(self, path, button):
     response = get_chooser_dialog(self._dialog, self._settings,
                                   "Themes Archive [*.xz, *.zip]",
                                   ("*.xz", "*.zip"))
     if response in (Gtk.ResponseType.CANCEL,
                     Gtk.ResponseType.DELETE_EVENT):
         return
     self._theme_frame.set_sensitive(False)
     self.unpack_theme(response, path, button)
예제 #2
0
def import_bouquet(transient,
                   model,
                   path,
                   settings,
                   services,
                   appender,
                   file_path=None):
    """ Import of single bouquet """
    itr = model.get_iter(path)
    bq_type = BqType(model.get(itr, Column.BQ_TYPE)[0])
    pattern, f_pattern = None, None
    profile = settings.setting_type

    if profile is SettingsType.ENIGMA_2:
        pattern = ".{}".format(bq_type.value)
        f_pattern = "userbouquet.*{}".format(pattern)
    elif profile is SettingsType.NEUTRINO_MP:
        pattern = "webtv.xml" if bq_type is BqType.WEBTV else "bouquets.xml"
        f_pattern = "bouquets.xml"
        if bq_type is BqType.TV:
            f_pattern = "ubouquets.xml"
        elif bq_type is BqType.WEBTV:
            f_pattern = "webtv.xml"

    file_path = file_path or get_chooser_dialog(transient, settings,
                                                "bouquet files", (f_pattern, ))
    if file_path == Gtk.ResponseType.CANCEL:
        return

    if not str(file_path).endswith(pattern):
        show_dialog(DialogType.ERROR,
                    transient,
                    text="No bouquet file is selected!")
        return

    if profile is SettingsType.ENIGMA_2:
        bq = get_enigma2_bouquet(file_path)
        imported = list(
            filter(
                lambda x: x.data in services or x.type is BqServiceType.IPTV,
                bq.services))

        if len(imported) == 0:
            show_dialog(
                DialogType.ERROR,
                transient,
                text="The main list does not contain services for this bouquet!"
            )
            return

        if model.iter_n_children(itr):
            appender(bq, itr)
        else:
            p_itr = model.iter_parent(itr)
            appender(bq, p_itr) if p_itr else appender(bq, itr)
    elif profile is SettingsType.NEUTRINO_MP:
        if bq_type is BqType.WEBTV:
            bqs = parse_webtv(file_path, "WEBTV", bq_type.value)
        else:
            bqs = get_neutrino_bouquets(file_path, "", bq_type.value)
        file_path = "{}/".format(Path(file_path).parent)
        ImportDialog(transient, file_path, settings, services.keys(),
                     lambda b, s: appender(b), (bqs, )).show()