Esempio n. 1
0
	def __init__(self):
		
		self.epgimport = None
		self.epgimportversion = "0"
		self.xmltvimport = None
		self.xmltvimportversion = "0"
		self.crossepg = None
		self.crossepgversion = "0"
		
		# Check if xmltvimport exists
		if os.path.exists("/etc/epgimport"):
			log.debug("readXMLTV: Found epgimport")
			path = "/etc/epgimport/wunschliste.sources.xml"
			self.epgimport = XMLFile(path)
		
		# Check if xmltvimport exists
		if os.path.exists("/etc/xmltvimport"):
			log.debug("readXMLTV: Found xmltvimport")
			path = "/etc/xmltvimport/wunschliste.sources.xml"
			self.xmltvimport = XMLFile(path)
		
		# Check if crossepg exists
		if os.path.exists("/etc/crossepg"):
			log.debug("readXMLTV: Found crossepg")
			path = "/etc/crossepg/wunschliste.sources.xml"
			self.crossepg = XMLFile(path)
		
		self.readXMLTVConfig()
Esempio n. 2
0
    def salvar_lista(self):
        """Função responsável por salvar uma lista.
        """

        try:
            parents = set()
            flag_lista = False
            # Verifica todos itens clicados na árvore
            for nomeProjeto in self.ui.treeView.selectedIndexes():
                while nomeProjeto.parent().isValid(
                ):  # enquanto o item clicado possuir um ramo pai, o nome desse item é
                    # alterado para o do pai, de forma a armazenar o nome do projeto
                    # da lista que foi clicada
                    # a flag_lista é alterada pra indicar que uma lista foi clicada
                    nomeProjeto = nomeProjeto.parent()
                    flag_lista = True

                parents.add(nomeProjeto.sibling(nomeProjeto.row(), 0))

            nomeProjeto = [
                nomeProjeto.data() for nomeProjeto in sorted(parents)
            ]
            nomeProjeto = nomeProjeto[0]

            # a variável 'key_projeto' armazena a id (chave) do projeto atual
            for keys in sorted(self.dirProject):
                if self.dirProject[keys].name == nomeProjeto:
                    key_projeto = keys

            if flag_lista == True:
                for index in self.ui.treeView.selectedIndexes():
                    nomeLista = index.data()

                    for keys in sorted(self.dirProject[key_projeto].dirList):
                        if self.dirProject[key_projeto].dirList[
                                keys].name == nomeLista:
                            lista = self.dirProject[key_projeto].dirList[keys]

                    # O nome default do arquivo é "Untitled"
                    title = "Untitled"

            try:
                print(lista)
                # Abre-se uma janela de diálogo para salvar o arquivo desejado
                filename, _ = QtWidgets.QFileDialog.getSaveFileName(
                    self, "Salvar Lista como", title, "*.xml")

                # Se o usuário clicou em Ok, a função save_xml da classe XMLFile é chamada para então criar um arquivo .xml
                # com os projetos, listas e linhas criadas pelo usuário
                if filename:
                    XMLFile.save_lista_xml(self, filename, lista)
            except UnboundLocalError:
                QtWidgets.QMessageBox.warning(self, "Aviso",
                                              "Selecione uma lista")

        except IndexError:
            QtWidgets.QMessageBox.warning(self, "Aviso", "Selecione uma lista")
Esempio n. 3
0
    def salvar_projeto(self):
        """Função responsável por salvar o projeto.
        """

        # O nome default do arquivo é "Untitled"
        title = "Untitled"

        # Abre-se uma janela de diálogo para salvar o arquivo desejado
        filename, _ = QtWidgets.QFileDialog.getSaveFileName(
            self, "Salvar Projeto como", title, "*.xml")

        # Se o usuário clicou em Ok, a função save_xml da classe XMLFile é chamada para então criar um arquivo .xml
        # com os projetos, listas e linhas criadas pelo usuário
        if filename:
            XMLFile.save_xml(self, filename)
Esempio n. 4
0
    def __init__(self):

        self.epgimport = None
        self.epgimportversion = "0"
        self.xmltvimport = None
        self.xmltvimportversion = "0"

        # Check if xmltvimport exists
        if os.path.exists("/etc/epgimport"):
            log.debug("readXMLTV: Found epgimport")
            path = "/etc/epgimport/wunschliste.sources.xml"
            self.epgimport = XMLFile(path)

        # Check if xmltvimport exists
        elif os.path.exists("/etc/xmltvimport"):
            log.debug("readXMLTV: Found xmltvimport")
            path = "/etc/xmltvimport/wunschliste.sources.xml"
            self.xmltvimport = XMLFile(path)

        self.readXMLTVConfig()
Esempio n. 5
0
    def abrir_projeto(self):
        """Função responsável por abrir um novo projeto na janela principal.
        """
        """
        Todas informações atuais da árvore são apagadas para abrir o arquivo desejado
        """
        treeModel = QStandardItemModel()
        self.ui.treeView.setModel(treeModel)
        self.rootNode = treeModel.invisibleRootItem()

        # As informações antigas do dicionário de projetos são removidas

        # A variável 'fileinfo' armazena o caminho do arquivo que deseja-se abrir
        fileinfo, _ = QtWidgets.QFileDialog.getOpenFileName(
            self, 'Abrir', '', '*.xml')
        if not fileinfo:
            return
        filename = os.path.basename(fileinfo)
        filepath = os.path.dirname(fileinfo)

        # Se o usuário clicou escolheu um arquivo, a função carrega_xml da classe XMLFile é chamada para então carregar
        # o arquivo .xml selecionado com os seus respectivos projetos, listas e linhas criadas pelo usuário
        # A variável 'flag' é utiliza para verificar se o arquivo .xml é consistente, retornando -1 caso seja inválido e
        # retornando 1 caso seja válido.
        flag = XMLFile.carrega_xml(self, filename, filepath)

        if flag == -1:
            QtWidgets.QMessageBox.warning(self, "Aviso", "XML Inválido")
        else:
            self.ui.actionSalvarProjeto.setEnabled(True)
            self.ui.salvarListaButton.setEnabled(True)
            self.ui.salvarProjetoButton.setEnabled(True)

            # A nova árvore aberta então é expandida e qualquer projeto antigo aberto é fechado
            self.ui.treeView.expandAll()

            try:
                subwindow = self.ui.mdiArea.currentSubWindow()
                subwindow.close()
            except AttributeError:
                pass
    def __init__(self):

        path = config.plugins.seriesplugin.channel_file.value
        XMLFile.__init__(self, path)

        self.resetChannels()
Esempio n. 7
0
	def __init__(self):
		
		path = config.plugins.seriesplugin.channel_file.value
		XMLFile.__init__(self, path)
		
		self.resetChannels()
Esempio n. 8
0
def demo():
    """
    Main program to handle command line parameters and then run what they want.
    """
    if BibleOrgSysGlobals.verbosityLevel > 0:
        print(ProgNameVersion)

    if 1:  # Demo the writer object with XML
        outputFolder = "OutputFiles"
        outputFilename = "test.xml"
        if not os.access(outputFolder, os.F_OK):
            os.mkdir(outputFolder)  # Make the empty folder if there wasn't already one there
        # schema = "http://someURL.net/myOwn.xsd"
        schema = "~/imaginary.xsd"
        mlWr = MLWriter(outputFilename, outputFolder)
        mlWr.setHumanReadable("All")
        mlWr.start()
        mlWr.setSectionName("Header")
        mlWr.writeLineOpen(
            "vwxyz",
            [
                ("xmlns", "http://someURL.net/namespace"),
                ("xmlns:xsi", "http://someURL.net/XMLSchema-instance"),
                ("xsi:schemaLocation", "http://someURL.net/namespace {}".format(schema)),
            ],
        )
        mlWr.writeLineOpen("header")
        mlWr.writeLineOpenClose("title", "myTitle")
        mlWr.writeLineClose("header")
        mlWr.setSectionName("Main")
        mlWr.writeLineOpen("body")
        mlWr.writeLineOpen("division", [("id", "Div1"), ("name", "First division")])
        mlWr.writeLineOpenClose("text", "myText in here", ("font", "favouriteFont"))
        mlWr.autoClose()
        print(mlWr)  # Just print a summary
        print(mlWr.validate(schema))

        from XMLFile import XMLFile

        xf = XMLFile(outputFilename, outputFolder)
        try:
            xf.validateByLoading()
            xf.validateWithLint()
        except FileNotFoundError:
            logging.warning("Unable to try validating XML file for some reason")
        # print( xf.validateAll() )
        print(xf)

    if 1:  # Demo the writer object with HTML5
        import datetime

        outputFolder = "OutputFiles"
        outputFilename = "test.html"
        if not os.access(outputFolder, os.F_OK):
            os.mkdir(outputFolder)  # Make the empty folder if there wasn't already one there
        schema = ""
        mlWr = MLWriter(outputFilename, outputFolder, "HTML")
        mlWr.setHumanReadable("All")
        mlWr.start()
        mlWr.setSectionName("Header")
        mlWr.writeLineText("<!DOCTYPE html>", noTextCheck=True)
        mlWr.writeLineOpen("html")
        mlWr.writeLineOpen("head")
        mlWr.writeLineText('<meta http-equiv="Content-Type" content="text/html;charset=utf-8">', noTextCheck=True)
        mlWr.writeLineText('<link rel="stylesheet" type="text/css" href="CSS/BibleBook.css">', noTextCheck=True)
        mlWr.writeLineOpenClose("title", "My HTML5 Test Page")
        mlWr.writeLineClose("head")

        mlWr.setSectionName("Main")
        mlWr.writeLineOpen("body")
        mlWr.writeLineOpen("header")
        mlWr.writeLineText("HEADER STUFF GOES HERE")
        mlWr.writeLineClose("header")
        mlWr.writeLineOpen("nav")
        mlWr.writeLineText("NAVIGATION STUFF GOES HERE")
        mlWr.writeLineClose("nav")
        # mlWr.writeLineOpen( "div", [('id','Div1'),('name','First division')] )
        mlWr.writeLineOpenClose("h1", "myHeading in here", ("class", "testHeading"))
        mlWr.writeLineOpenClose("p", "myText in here", [("class", "funParagraph"), ("id", "myAnchor")])
        mlWr.writeLineOpen("footer")
        mlWr.writeLineOpen("p", ("class", "footerLine"))
        mlWr.writeLineOpen("a", ("href", "http://www.w3.org/html/logo/"))
        mlWr.writeLineText(
            '<img src="http://www.w3.org/html/logo/badge/html5-badge-h-css3-semantics.png" width="165" height="64" alt="HTML5 Powered with CSS3 / Styling, and Semantics" title="HTML5 Powered with CSS3 / Styling, and Semantics">',
            noTextCheck=True,
        )
        mlWr.writeLineClose("a")
        mlWr.writeLineText(
            "This page automatically created by: {} v{} {}".format(
                ProgName, ProgVersion, datetime.date.today().strftime("%d-%b-%Y")
            )
        )
        mlWr.writeLineClose("p")
        mlWr.writeLineClose("footer")
        mlWr.writeLineClose("body")
        mlWr.autoClose()
        print(mlWr)  # Just print a summary
        print(mlWr.validate(schema))
Esempio n. 9
0
class XMLTVBase(object):
	
	def __init__(self):
		
		self.epgimport = None
		self.epgimportversion = "0"
		self.xmltvimport = None
		self.xmltvimportversion = "0"
		self.crossepg = None
		self.crossepgversion = "0"
		
		# Check if xmltvimport exists
		if os.path.exists("/etc/epgimport"):
			log.debug("readXMLTV: Found epgimport")
			path = "/etc/epgimport/wunschliste.sources.xml"
			self.epgimport = XMLFile(path)
		
		# Check if xmltvimport exists
		if os.path.exists("/etc/xmltvimport"):
			log.debug("readXMLTV: Found xmltvimport")
			path = "/etc/xmltvimport/wunschliste.sources.xml"
			self.xmltvimport = XMLFile(path)
		
		# Check if crossepg exists
		if os.path.exists("/etc/crossepg"):
			log.debug("readXMLTV: Found crossepg")
			path = "/etc/crossepg/wunschliste.sources.xml"
			self.crossepg = XMLFile(path)
		
		self.readXMLTVConfig()

	def readXMLTVConfig(self):
		
		if self.epgimport:
			etree = self.epgimport.readXML()
			if etree:
				self.epgimportversion = etree.getroot().get("version", "1")
				log.debug("readXMLTVConfig: EPGImport Version " + self.epgimportversion)
		
		if self.xmltvimport:
			etree = self.xmltvimport.readXML()
			if etree:
				self.xmltvimportversion = etree.getroot().get("version", "1")
				log.debug("readXMLTVConfig: XMLTVImport Version " + self.xmltvimportversion)
		
		if self.crossepg:
			etree = self.crossepg.readXML()
			if etree:
				self.crossepgversion = etree.getroot().get("version", "1")
				log.debug("readXMLTVConfig: crossepg Version " + self.crossepgversion)
	
	def writeXMLTVConfig(self):
		
		if self.epgimport is None and self.xmltvimport is None and self.crossepg is None:
			return
		
		if int(self.epgimportversion[0]) >= 5 and int(self.xmltvimportversion[0]) >= 5 and int(self.crossepgversion[0]) >= 5:
			return;
		
		if config.plugins.seriesplugin.epgimport.value == False and config.plugins.seriesplugin.xmltvimport.value == False and config.plugins.seriesplugin.crossepg.value == False:
			return
		
		# Build Header
		from plugin import NAME, VERSION
		root = Element("sources")
		root.set('version', VERSION)
		root.set('created_by', NAME)
		root.append(Comment(_("Don't edit this manually unless you really know what you are doing")))
		
		element = SubElement( root, "source", type = "gen_xmltv", channels = "wunschliste.channels.xml" )
		
		SubElement( element, "description" ).text = "Wunschliste XMLTV"
		SubElement( element, "url" ).text = config.plugins.seriesplugin.xmltv_url.value
		
		etree = ElementTree( root )
		
		indent(etree.getroot())
		
		if config.plugins.seriesplugin.epgimport.value:
			log.debug("Write: xml channels for epgimport")
			if self.epgimport:
				try:
					self.epgimport.writeXML( etree )
				except Exception as e:
					log.exception("Exception in write XML: " + str(e))
		
		if config.plugins.seriesplugin.xmltvimport.value:
			log.debug("Write: xml channels for xmltvimport")
			if self.xmltvimport:
				try:
					self.xmltvimport.writeXML( etree )
				except Exception as e:
					log.exception("Exception in write XML: " + str(e))
		
		if config.plugins.seriesplugin.crossepg.value:
			log.debug("Write: xml channels for crossepg")
			if self.crossepg:
				try:
					self.crossepg.writeXML( etree )
				except Exception as e:
					log.exception("Exception in write XML: " + str(e))
Esempio n. 10
0
def demo():
    """
    Main program to handle command line parameters and then run what they want.
    """
    if Globals.verbosityLevel > 0: print(ProgNameVersion)

    if 1:  # Demo the writer object with XML
        outputFolder = "OutputFiles"
        outputFilename = "test.xml"
        if not os.access(outputFolder, os.F_OK):
            os.mkdir(
                outputFolder
            )  # Make the empty folder if there wasn't already one there
        #schema = "http://someURL.net/myOwn.xsd"
        schema = "~/imaginary.xsd"
        mlWr = MLWriter(outputFilename, outputFolder)
        mlWr.setHumanReadable('All')
        mlWr.start()
        mlWr.setSectionName('Header')
        mlWr.writeLineOpen(
            "vwxyz", [("xmlns", "http://someURL.net/namespace"),
                      ("xmlns:xsi", "http://someURL.net/XMLSchema-instance"),
                      ("xsi:schemaLocation",
                       "http://someURL.net/namespace {}".format(schema))])
        mlWr.writeLineOpen('header')
        mlWr.writeLineOpenClose("title", "myTitle")
        mlWr.writeLineClose('header')
        mlWr.setSectionName('Main')
        mlWr.writeLineOpen('body')
        mlWr.writeLineOpen("division", [('id', 'Div1'),
                                        ('name', 'First division')])
        mlWr.writeLineOpenClose("text", "myText in here",
                                ("font", "favouriteFont"))
        mlWr.autoClose()
        print(mlWr)  # Just print a summary
        print(mlWr.validate(schema))

        from XMLFile import XMLFile
        xf = XMLFile(outputFilename, outputFolder)
        try:
            xf.validateByLoading()
            xf.validateWithLint()
        except:
            logging.warning(
                "Unable to try validating XML file for some reason")
        #print( xf.validateAll() )
        print(xf)

    if 1:  # Demo the writer object with HTML5
        import datetime
        outputFolder = "OutputFiles"
        outputFilename = "test.html"
        if not os.access(outputFolder, os.F_OK):
            os.mkdir(
                outputFolder
            )  # Make the empty folder if there wasn't already one there
        schema = ""
        mlWr = MLWriter(outputFilename, outputFolder, 'HTML')
        mlWr.setHumanReadable('All')
        mlWr.start()
        mlWr.setSectionName('Header')
        mlWr.writeLineText('<!DOCTYPE html>', noTextCheck=True)
        mlWr.writeLineOpen('html')
        mlWr.writeLineOpen('head')
        mlWr.writeLineText(
            '<meta http-equiv="Content-Type" content="text/html;charset=utf-8">',
            noTextCheck=True)
        mlWr.writeLineText(
            '<link rel="stylesheet" type="text/css" href="CSS/BibleBook.css">',
            noTextCheck=True)
        mlWr.writeLineOpenClose('title', "My HTML5 Test Page")
        mlWr.writeLineClose('head')

        mlWr.setSectionName('Main')
        mlWr.writeLineOpen('body')
        mlWr.writeLineOpen('header')
        mlWr.writeLineText('HEADER STUFF GOES HERE')
        mlWr.writeLineClose('header')
        mlWr.writeLineOpen('nav')
        mlWr.writeLineText('NAVIGATION STUFF GOES HERE')
        mlWr.writeLineClose('nav')
        #mlWr.writeLineOpen( "div", [('id','Div1'),('name','First division')] )
        mlWr.writeLineOpenClose("h1", "myHeading in here",
                                ('class', 'testHeading'))
        mlWr.writeLineOpenClose("p", "myText in here", [
            ("class", "funParagraph"),
            ('id', 'myAnchor'),
        ])
        mlWr.writeLineOpen('footer')
        mlWr.writeLineOpen('p', ('class', 'footerLine'))
        mlWr.writeLineOpen('a', ('href', 'http://www.w3.org/html/logo/'))
        mlWr.writeLineText(
            '<img src="http://www.w3.org/html/logo/badge/html5-badge-h-css3-semantics.png" width="165" height="64" alt="HTML5 Powered with CSS3 / Styling, and Semantics" title="HTML5 Powered with CSS3 / Styling, and Semantics">',
            noTextCheck=True)
        mlWr.writeLineClose('a')
        mlWr.writeLineText(
            "This page automatically created by: {} v{} {}".format(
                ProgName, ProgVersion,
                datetime.date.today().strftime("%d-%b-%Y")))
        mlWr.writeLineClose('p')
        mlWr.writeLineClose('footer')
        mlWr.writeLineClose('body')
        mlWr.autoClose()
        print(mlWr)  # Just print a summary
        print(mlWr.validate(schema))
Esempio n. 11
0
class XMLTVBase(object):
    def __init__(self):

        self.epgimport = None
        self.epgimportversion = "0"
        self.xmltvimport = None
        self.xmltvimportversion = "0"

        # Check if xmltvimport exists
        if os.path.exists("/etc/epgimport"):
            log.debug("readXMLTV: Found epgimport")
            path = "/etc/epgimport/wunschliste.sources.xml"
            self.epgimport = XMLFile(path)

        # Check if xmltvimport exists
        elif os.path.exists("/etc/xmltvimport"):
            log.debug("readXMLTV: Found xmltvimport")
            path = "/etc/xmltvimport/wunschliste.sources.xml"
            self.xmltvimport = XMLFile(path)

        self.readXMLTVConfig()

    def readXMLTVConfig(self):

        if self.epgimport:
            etree = self.epgimport.readXML()
            if etree:
                self.epgimportversion = etree.getroot().get("version", "1")
                log.debug("readXMLTVConfig: EPGImport Version " +
                          self.epgimportversion)

        if self.xmltvimport:
            etree = self.xmltvimport.readXML()
            if etree:
                self.xmltvimportversion = etree.getroot().get("version", "1")
                log.debug("readXMLTVConfig: XMLTVImport Version " +
                          self.xmltvimportversion)

    def writeXMLTVConfig(self):

        if int(self.epgimportversion[0]) >= 5 and int(
                self.xmltvimportversion[0]) >= 5:
            return

        if self.epgimport is None and self.xmltvimport is None:
            return

        if config.plugins.seriesplugin.epgimport.value == False and config.plugins.seriesplugin.xmltvimport.value == False:
            return

        # Build Header
        from plugin import NAME, VERSION
        root = Element("sources")
        root.set('version', VERSION)
        root.set('created_by', NAME)
        root.append(
            Comment(
                _("Don't edit this manually unless you really know what you are doing"
                  )))

        element = SubElement(root,
                             "source",
                             type="gen_xmltv",
                             channels="wunschliste.channels.xml")

        SubElement(element, "description").text = "Wunschliste XMLTV"
        SubElement(element,
                   "url").text = config.plugins.seriesplugin.xmltv_url.value

        etree = ElementTree(root)

        indent(etree.getroot())

        if config.plugins.seriesplugin.epgimport.value:
            log.debug("Write: xml channels for epgimport")
            try:
                self.epgimport.writeXML(etree)
            except Exception as e:
                log.exception("Exception in write XML: " + str(e))

        if config.plugins.seriesplugin.xmltvimport.value:
            log.debug("Write: xml channels for xmltvimport")
            try:
                self.xmltvimport.writeXML(etree)
            except Exception as e:
                log.exception("Exception in write XML: " + str(e))