|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2012 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a base class for the bookmarks importers. |
|
8 """ |
|
9 |
|
10 from PyQt6.QtCore import QObject |
|
11 |
|
12 |
|
13 class BookmarksImporter(QObject): |
|
14 """ |
|
15 Class implementing the base class for the bookmarks importers. |
|
16 """ |
|
17 def __init__(self, sourceId="", parent=None): |
|
18 """ |
|
19 Constructor |
|
20 |
|
21 @param sourceId source ID (string) |
|
22 @param parent reference to the parent object (QObject) |
|
23 """ |
|
24 super().__init__(parent) |
|
25 |
|
26 self._path = "" |
|
27 self._file = "" |
|
28 self._error = False |
|
29 self._errorString = "" |
|
30 self._id = sourceId |
|
31 |
|
32 def setPath(self, path): |
|
33 """ |
|
34 Public method to set the path of the bookmarks file or directory. |
|
35 |
|
36 @param path bookmarks file or directory (string) |
|
37 @exception NotImplementedError raised to indicate this method must |
|
38 be implemented by a subclass |
|
39 """ |
|
40 raise NotImplementedError |
|
41 |
|
42 def open(self): |
|
43 """ |
|
44 Public method to open the bookmarks file. |
|
45 |
|
46 It must return a flag indicating success (boolean). |
|
47 |
|
48 @exception NotImplementedError raised to indicate this method must |
|
49 be implemented by a subclass |
|
50 """ |
|
51 raise NotImplementedError |
|
52 |
|
53 def importedBookmarks(self): |
|
54 """ |
|
55 Public method to get the imported bookmarks. |
|
56 |
|
57 It must return the imported bookmarks (BookmarkNode). |
|
58 |
|
59 @exception NotImplementedError raised to indicate this method must |
|
60 be implemented by a subclass |
|
61 """ |
|
62 raise NotImplementedError |
|
63 |
|
64 def error(self): |
|
65 """ |
|
66 Public method to check for an error. |
|
67 |
|
68 @return flag indicating an error (boolean) |
|
69 """ |
|
70 return self._error |
|
71 |
|
72 def errorString(self): |
|
73 """ |
|
74 Public method to get the error description. |
|
75 |
|
76 @return error description (string) |
|
77 """ |
|
78 return self._errorString |