10 import json |
10 import json |
11 import os |
11 import os |
12 |
12 |
13 from PyQt6.QtCore import QCoreApplication, QDate, Qt |
13 from PyQt6.QtCore import QCoreApplication, QDate, Qt |
14 |
14 |
15 from eric7 import Globals |
|
16 from eric7.EricGui import EricPixmapCache |
15 from eric7.EricGui import EricPixmapCache |
|
16 from eric7.SystemUtilities import OSUtilities |
17 |
17 |
18 from .BookmarksImporter import BookmarksImporter |
18 from .BookmarksImporter import BookmarksImporter |
19 |
19 |
20 |
20 |
21 def getImporterInfo(sourceId): |
21 def getImporterInfo(sourceId): |
31 """ |
31 """ |
32 if sourceId not in ("chrome", "chromium", "edge", "falkon", "opera", "vivaldi"): |
32 if sourceId not in ("chrome", "chromium", "edge", "falkon", "opera", "vivaldi"): |
33 raise ValueError("Unsupported browser ID given ({0}).".format(sourceId)) |
33 raise ValueError("Unsupported browser ID given ({0}).".format(sourceId)) |
34 |
34 |
35 if sourceId == "chrome": |
35 if sourceId == "chrome": |
36 if Globals.isWindowsPlatform(): |
36 if OSUtilities.isWindowsPlatform(): |
37 standardDir = os.path.expandvars( |
37 standardDir = os.path.expandvars( |
38 "%USERPROFILE%\\AppData\\Local\\Google\\Chrome\\User Data\\Default" |
38 "%USERPROFILE%\\AppData\\Local\\Google\\Chrome\\User Data\\Default" |
39 ) |
39 ) |
40 elif Globals.isMacPlatform(): |
40 elif OSUtilities.isMacPlatform(): |
41 standardDir = os.path.expanduser( |
41 standardDir = os.path.expanduser( |
42 "~/Library/Application Support/Google/Chrome/Default" |
42 "~/Library/Application Support/Google/Chrome/Default" |
43 ) |
43 ) |
44 else: |
44 else: |
45 standardDir = os.path.expanduser("~/.config/google-chrome/Default") |
45 standardDir = os.path.expanduser("~/.config/google-chrome/Default") |
59 ), |
59 ), |
60 standardDir, |
60 standardDir, |
61 ) |
61 ) |
62 |
62 |
63 elif sourceId == "chromium": |
63 elif sourceId == "chromium": |
64 if Globals.isWindowsPlatform(): |
64 if OSUtilities.isWindowsPlatform(): |
65 standardDir = os.path.expandvars( |
65 standardDir = os.path.expandvars( |
66 "%USERPROFILE%\\AppData\\Local\\Google\\Chrome\\User Data\\Default" |
66 "%USERPROFILE%\\AppData\\Local\\Google\\Chrome\\User Data\\Default" |
67 ) |
67 ) |
68 else: |
68 else: |
69 standardDir = os.path.expanduser("~/.config/chromium/Default") |
69 standardDir = os.path.expanduser("~/.config/chromium/Default") |
82 ), |
82 ), |
83 standardDir, |
83 standardDir, |
84 ) |
84 ) |
85 |
85 |
86 elif sourceId == "edge": |
86 elif sourceId == "edge": |
87 if Globals.isWindowsPlatform(): |
87 if OSUtilities.isWindowsPlatform(): |
88 standardDir = os.path.expandvars( |
88 standardDir = os.path.expandvars( |
89 "%USERPROFILE%\\AppData\\Local\\Microsoft\\Edge\\User Data\\Default" |
89 "%USERPROFILE%\\AppData\\Local\\Microsoft\\Edge\\User Data\\Default" |
90 ) |
90 ) |
91 else: |
91 else: |
92 standardDir = os.path.expanduser("~/.config/microsoft-edge/Default") |
92 standardDir = os.path.expanduser("~/.config/microsoft-edge/Default") |
106 ), |
106 ), |
107 standardDir, |
107 standardDir, |
108 ) |
108 ) |
109 |
109 |
110 elif sourceId == "falkon": |
110 elif sourceId == "falkon": |
111 if Globals.isWindowsPlatform(): |
111 if OSUtilities.isWindowsPlatform(): |
112 standardDir = os.path.expandvars( |
112 standardDir = os.path.expandvars( |
113 "%USERPROFILE%\\AppData\\Local\\falkon\\profiles\\default" |
113 "%USERPROFILE%\\AppData\\Local\\falkon\\profiles\\default" |
114 ) |
114 ) |
115 else: |
115 else: |
116 standardDir = os.path.expanduser("~/.config/falkon/profiles/default") |
116 standardDir = os.path.expanduser("~/.config/falkon/profiles/default") |
130 ), |
130 ), |
131 standardDir, |
131 standardDir, |
132 ) |
132 ) |
133 |
133 |
134 elif sourceId == "opera": |
134 elif sourceId == "opera": |
135 if Globals.isWindowsPlatform(): |
135 if OSUtilities.isWindowsPlatform(): |
136 standardDir = os.path.expandvars( |
136 standardDir = os.path.expandvars( |
137 "%USERPROFILE%\\AppData\\Roaming\\Opera Software\\Opera Stable" |
137 "%USERPROFILE%\\AppData\\Roaming\\Opera Software\\Opera Stable" |
138 ) |
138 ) |
139 else: |
139 else: |
140 standardDir = os.path.expanduser("~/.config/opera") |
140 standardDir = os.path.expanduser("~/.config/opera") |
154 ), |
154 ), |
155 standardDir, |
155 standardDir, |
156 ) |
156 ) |
157 |
157 |
158 elif sourceId == "vivaldi": |
158 elif sourceId == "vivaldi": |
159 if Globals.isWindowsPlatform(): |
159 if OSUtilities.isWindowsPlatform(): |
160 standardDir = os.path.expandvars( |
160 standardDir = os.path.expandvars( |
161 "%USERPROFILE%\\AppData\\Local\\Vivaldi\\User Data\\Default" |
161 "%USERPROFILE%\\AppData\\Local\\Vivaldi\\User Data\\Default" |
162 ) |
162 ) |
163 else: |
163 else: |
164 standardDir = os.path.expanduser("~/.config/vivaldi/Default") |
164 standardDir = os.path.expanduser("~/.config/vivaldi/Default") |
180 ) |
180 ) |
181 |
181 |
182 # entry if an unknown source is given |
182 # entry if an unknown source is given |
183 standardDir = ( |
183 standardDir = ( |
184 os.path.expandvars("%USERPROFILE%\\AppData") |
184 os.path.expandvars("%USERPROFILE%\\AppData") |
185 if Globals.isWindowsPlatform() |
185 if OSUtilities.isWindowsPlatform() |
186 else os.path.expanduser("~/.config") |
186 else os.path.expanduser("~/.config") |
187 ) |
187 ) |
188 return ( |
188 return ( |
189 EricPixmapCache.getPixmap("chrome_unknown"), |
189 EricPixmapCache.getPixmap("chrome_unknown"), |
190 "Unknown Chrome", |
190 "Unknown Chrome", |