WebBrowser/SafeBrowsing/SafeBrowsingCache.py

changeset 6229
72b40274a3b6
parent 6186
83451f10f3eb
child 6645
ad476851d7e0
diff -r 9c3fbf39ec9b -r 72b40274a3b6 WebBrowser/SafeBrowsing/SafeBrowsingCache.py
--- a/WebBrowser/SafeBrowsing/SafeBrowsingCache.py	Mon Apr 09 19:47:16 2018 +0200
+++ b/WebBrowser/SafeBrowsing/SafeBrowsingCache.py	Tue Apr 10 19:39:13 2018 +0200
@@ -23,97 +23,7 @@
 from PyQt5.QtSql import QSql, QSqlDatabase, QSqlQuery
 
 from .SafeBrowsingUtilities import toHex
-
-
-class ThreatList(object):
-    """
-    Class implementing the threat list info.
-    """
-    def __init__(self, threatType, platformType, threatEntryType):
-        """
-        Constructor
-        
-        @param threatType threat type
-        @type str
-        @param platformType platform type
-        @type str
-        @param threatEntryType threat entry type
-        @type str
-        """
-        self.threatType = threatType
-        self.platformType = platformType
-        self.threatEntryType = threatEntryType
-
-    @classmethod
-    def fromApiEntry(cls, entry):
-        """
-        Class method to instantiate a threat list given a threat list entry
-        dictionary.
-        
-        @param entry threat list entry dictionary
-        @type dict
-        @return instantiated object
-        @rtype ThreatList
-        """
-        return cls(entry['threatType'], entry['platformType'],
-                   entry['threatEntryType'])
-
-    def asTuple(self):
-        """
-        Public method to convert the object to a tuple.
-        
-        @return tuple containing the threat list info
-        @rtype tuple of (str, str, str)
-        """
-        return (self.threatType, self.platformType, self.threatEntryType)
-
-    def __repr__(self):
-        """
-        Special method to generate a printable representation.
-        
-        @return printable representation
-        @rtype str
-        """
-        return '/'.join(self.asTuple())
-
-
-class HashPrefixList(object):
-    """
-    Class implementing a container for threat list data.
-    """
-    def __init__(self, prefixLength, rawHashes):
-        """
-        Constructor
-        
-        @param prefixLength length of each hash prefix
-        @type int
-        @param rawHashes raw hash prefixes of given length concatenated and
-            sorted in lexicographical order
-        @type str
-        """
-        self.__prefixLength = prefixLength
-        self.__rawHashes = rawHashes
-    
-    def __len__(self):
-        """
-        Special method to calculate the number of entries.
-        
-        @return length
-        @rtype int
-        """
-        return len(self.__rawHashes) // self.__prefixLength
-    
-    def __iter__(self):
-        """
-        Special method to iterate over the raw hashes.
-        
-        @return iterator object
-        @rtype iterator
-        """
-        n = self.__prefixLength
-        return (self.__rawHashes[index:index + n]
-                for index in range(0, len(self.__rawHashes), n)
-                )
+from .SafeBrowsingThreatList import ThreatList
 
 
 class SafeBrowsingCache(QObject):

eric ide

mercurial