eric6/Helpviewer/UserAgent/UserAgentWriter.py

branch
maintenance
changeset 7286
7eb04391adf7
parent 7226
babe80d84a3e
parent 7285
1ff497f33f31
child 7287
1c17f2191bdd
--- a/eric6/Helpviewer/UserAgent/UserAgentWriter.py	Mon Sep 09 18:52:08 2019 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright (c) 2012 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
-#
-
-"""
-Module implementing a class to write user agent data files.
-"""
-
-from __future__ import unicode_literals
-
-from PyQt5.QtCore import QXmlStreamWriter, QIODevice, QFile
-
-
-class UserAgentWriter(QXmlStreamWriter):
-    """
-    Class implementing a writer object to generate user agent data files.
-    """
-    def __init__(self):
-        """
-        Constructor
-        """
-        super(UserAgentWriter, self).__init__()
-        
-        self.setAutoFormatting(True)
-    
-    def write(self, fileNameOrDevice, agents):
-        """
-        Public method to write a user agent data file.
-        
-        @param fileNameOrDevice name of the file to write (string)
-            or device to write to (QIODevice)
-        @param agents dictionary with user agent data (host as key, agent
-            string as value)
-        @return flag indicating success (boolean)
-        """
-        if isinstance(fileNameOrDevice, QIODevice):
-            f = fileNameOrDevice
-        else:
-            f = QFile(fileNameOrDevice)
-            if not f.open(QFile.WriteOnly):
-                return False
-        
-        self.setDevice(f)
-        return self.__write(agents)
-    
-    def __write(self, agents):
-        """
-        Private method to write a user agent file.
-        
-        @param agents dictionary with user agent data (host as key, agent
-            string as value)
-        @return flag indicating success (boolean)
-        """
-        self.writeStartDocument()
-        self.writeDTD("<!DOCTYPE useragents>")
-        self.writeStartElement("UserAgents")
-        self.writeAttribute("version", "1.0")
-        
-        for host, agent in agents.items():
-            self.writeEmptyElement("UserAgent")
-            self.writeAttribute("host", host)
-            self.writeAttribute("agent", agent)
-        
-        self.writeEndDocument()
-        return True

eric ide

mercurial