27 |
27 |
28 def write(self, fileNameOrDevice, root): |
28 def write(self, fileNameOrDevice, root): |
29 """ |
29 """ |
30 Public method to write an XBEL bookmark file. |
30 Public method to write an XBEL bookmark file. |
31 |
31 |
32 @param fileNameOrDevice name of the file to write (string) |
32 @param fileNameOrDevice name of the file to write |
|
33 @type str |
33 or device to write to (QIODevice) |
34 or device to write to (QIODevice) |
34 @param root root node of the bookmark tree (BookmarkNode) |
35 @param root root node of the bookmark tree |
35 @return flag indicating success (boolean) |
36 @type BookmarkNode |
|
37 @return flag indicating success |
|
38 @rtype bool |
36 """ |
39 """ |
37 if isinstance(fileNameOrDevice, QIODevice): |
40 if isinstance(fileNameOrDevice, QIODevice): |
38 f = fileNameOrDevice |
41 f = fileNameOrDevice |
39 else: |
42 else: |
40 f = QFile(fileNameOrDevice) |
43 f = QFile(fileNameOrDevice) |
46 |
49 |
47 def __write(self, root): |
50 def __write(self, root): |
48 """ |
51 """ |
49 Private method to write an XBEL bookmark file. |
52 Private method to write an XBEL bookmark file. |
50 |
53 |
51 @param root root node of the bookmark tree (BookmarkNode) |
54 @param root root node of the bookmark tree |
52 @return flag indicating success (boolean) |
55 @type BookmarkNode |
|
56 @return flag indicating success |
|
57 @rtype bool |
53 """ |
58 """ |
54 self.writeStartDocument() |
59 self.writeStartDocument() |
55 self.writeDTD("<!DOCTYPE xbel>") |
60 self.writeDTD("<!DOCTYPE xbel>") |
56 self.writeStartElement("xbel") |
61 self.writeStartElement("xbel") |
57 self.writeAttribute("version", "1.0") |
62 self.writeAttribute("version", "1.0") |
66 |
71 |
67 def __writeItem(self, node): |
72 def __writeItem(self, node): |
68 """ |
73 """ |
69 Private method to write an entry for a node. |
74 Private method to write an entry for a node. |
70 |
75 |
71 @param node reference to the node to be written (BookmarkNode) |
76 @param node reference to the node to be written |
|
77 @type BookmarkNode |
72 """ |
78 """ |
73 if node.type() == BookmarkNode.Folder: |
79 if node.type() == BookmarkNode.Folder: |
74 self.writeStartElement("folder") |
80 self.writeStartElement("folder") |
75 if node.added.isValid(): |
81 if node.added.isValid(): |
76 self.writeAttribute("added", node.added.toString(Qt.DateFormat.ISODate)) |
82 self.writeAttribute("added", node.added.toString(Qt.DateFormat.ISODate)) |