25 |
25 |
26 def write(self, fileNameOrDevice, agents): |
26 def write(self, fileNameOrDevice, agents): |
27 """ |
27 """ |
28 Public method to write a user agent data file. |
28 Public method to write a user agent data file. |
29 |
29 |
30 @param fileNameOrDevice name of the file to write (string) |
30 @param fileNameOrDevice name of the file to write or device to write to |
31 or device to write to (QIODevice) |
31 @type str or QIODevice |
32 @param agents dictionary with user agent data (host as key, agent |
32 @param agents dictionary with user agent data (host as key, agent |
33 string as value) |
33 string as value) |
34 @return flag indicating success (boolean) |
34 @type dict |
|
35 @return flag indicating success |
|
36 @rtype bool |
35 """ |
37 """ |
36 if isinstance(fileNameOrDevice, QIODevice): |
38 if isinstance(fileNameOrDevice, QIODevice): |
37 f = fileNameOrDevice |
39 f = fileNameOrDevice |
38 else: |
40 else: |
39 f = QFile(fileNameOrDevice) |
41 f = QFile(fileNameOrDevice) |
47 """ |
49 """ |
48 Private method to write a user agent file. |
50 Private method to write a user agent file. |
49 |
51 |
50 @param agents dictionary with user agent data (host as key, agent |
52 @param agents dictionary with user agent data (host as key, agent |
51 string as value) |
53 string as value) |
52 @return flag indicating success (boolean) |
54 @type dict |
|
55 @return flag indicating success |
|
56 @rtype bool |
53 """ |
57 """ |
54 self.writeStartDocument() |
58 self.writeStartDocument() |
55 self.writeDTD("<!DOCTYPE useragents>") |
59 self.writeDTD("<!DOCTYPE useragents>") |
56 self.writeStartElement("UserAgents") |
60 self.writeStartElement("UserAgents") |
57 self.writeAttribute("version", "1.0") |
61 self.writeAttribute("version", "1.0") |