19 import Globals |
19 import Globals |
20 |
20 |
21 from Utilities import binplistlib |
21 from Utilities import binplistlib |
22 |
22 |
23 |
23 |
24 def getImporterInfo(id): |
24 def getImporterInfo(sourceId): |
25 """ |
25 """ |
26 Module function to get information for the given source id. |
26 Module function to get information for the given source id. |
27 |
27 |
28 @param id id of the browser ("chrome" or "chromium") |
28 @param sourceId id of the browser ("chrome" or "chromium") |
29 @return tuple with an icon (QPixmap), readable name (string), name of |
29 @return tuple with an icon (QPixmap), readable name (string), name of |
30 the default bookmarks file (string), an info text (string), |
30 the default bookmarks file (string), an info text (string), |
31 a prompt (string) and the default directory of the bookmarks file |
31 a prompt (string) and the default directory of the bookmarks file |
32 (string) |
32 (string) |
33 @exception ValueError raised to indicate an invalid browser ID |
33 @exception ValueError raised to indicate an invalid browser ID |
34 """ |
34 """ |
35 if id == "safari": |
35 if sourceId == "safari": |
36 if Globals.isWindowsPlatform(): |
36 if Globals.isWindowsPlatform(): |
37 standardDir = os.path.expandvars( |
37 standardDir = os.path.expandvars( |
38 "%APPDATA%\\Apple Computer\\Safari") |
38 "%APPDATA%\\Apple Computer\\Safari") |
39 elif Globals.isMacPlatform(): |
39 elif Globals.isMacPlatform(): |
40 standardDir = os.path.expanduser("~/Library/Safari") |
40 standardDir = os.path.expanduser("~/Library/Safari") |
53 "SafariImporter", |
53 "SafariImporter", |
54 """Please choose the file to begin importing bookmarks."""), |
54 """Please choose the file to begin importing bookmarks."""), |
55 standardDir, |
55 standardDir, |
56 ) |
56 ) |
57 else: |
57 else: |
58 raise ValueError("Unsupported browser ID given ({0}).".format(id)) |
58 raise ValueError( |
|
59 "Unsupported browser ID given ({0}).".format(sourceId)) |
59 |
60 |
60 |
61 |
61 class SafariImporter(BookmarksImporter): |
62 class SafariImporter(BookmarksImporter): |
62 """ |
63 """ |
63 Class implementing the Apple Safari bookmarks importer. |
64 Class implementing the Apple Safari bookmarks importer. |
64 """ |
65 """ |
65 def __init__(self, id="", parent=None): |
66 def __init__(self, sourceId="", parent=None): |
66 """ |
67 """ |
67 Constructor |
68 Constructor |
68 |
69 |
69 @param id source ID (string) |
70 @param sourceId source ID (string) |
70 @param parent reference to the parent object (QObject) |
71 @param parent reference to the parent object (QObject) |
71 """ |
72 """ |
72 super(SafariImporter, self).__init__(id, parent) |
73 super(SafariImporter, self).__init__(sourceId, parent) |
73 |
74 |
74 self.__fileName = "" |
75 self.__fileName = "" |
75 |
76 |
76 def setPath(self, path): |
77 def setPath(self, path): |
77 """ |
78 """ |