eric6/WebBrowser/Bookmarks/BookmarksImporters/IExplorerImporter.py

Wed, 25 Sep 2019 18:48:22 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 25 Sep 2019 18:48:22 +0200
changeset 7268
a28338eaf694
parent 7229
53054eb5b15a
child 7360
9190402e4505
permissions
-rw-r--r--

Continued to resolve code style issue M841.

1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
3 # Copyright (c) 2012 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing an importer for Internet Explorer bookmarks.
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2403
diff changeset
10
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import os
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
13 from PyQt5.QtCore import QCoreApplication, QDate, Qt
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from .BookmarksImporter import BookmarksImporter
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import UI.PixmapCache
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 import Globals
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
21 def getImporterInfo(sourceId):
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 Module function to get information for the given source id.
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
25 @param sourceId id of the browser ("chrome" or "chromium")
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @return tuple with an icon (QPixmap), readable name (string), name of
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 the default bookmarks file (string), an info text (string),
3002
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
28 a prompt (string) and the default directory of the bookmarks file
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
29 (string)
2954
bf0215fe12d1 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
30 @exception ValueError raised to indicate an invalid browser ID
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
32 if sourceId == "ie":
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 if Globals.isWindowsPlatform():
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 standardDir = os.path.expandvars(
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 "%USERPROFILE%\\Favorites")
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 else:
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 standardDir = ""
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 return (
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 UI.PixmapCache.getPixmap("internet_explorer.png"),
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 "Internet Explorer",
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 "",
3002
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
42 QCoreApplication.translate(
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
43 "IExplorerImporter",
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
44 """Internet Explorer stores its bookmarks in the"""
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
45 """ <b>Favorites</b> folder This folder is usually"""
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
46 """ located in"""),
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
47 QCoreApplication.translate(
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
48 "IExplorerImporter",
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """Please choose the folder to begin importing bookmarks."""),
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 standardDir,
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 )
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 else:
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
53 raise ValueError(
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
54 "Unsupported browser ID given ({0}).".format(sourceId))
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 class IExplorerImporter(BookmarksImporter):
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 """
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 Class implementing the Chrome bookmarks importer.
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 """
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
61 def __init__(self, sourceId="", parent=None):
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 """
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 Constructor
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
65 @param sourceId source ID (string)
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 @param parent reference to the parent object (QObject)
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 """
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
68 super(IExplorerImporter, self).__init__(sourceId, parent)
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 self.__fileName = ""
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 def setPath(self, path):
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 """
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 Public method to set the path of the bookmarks file or directory.
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 @param path bookmarks file or directory (string)
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 """
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.__fileName = path
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 def open(self):
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 """
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 Public method to open the bookmarks file.
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 @return flag indicating success (boolean)
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 if not os.path.exists(self.__fileName):
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self._error = True
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
88 self._errorString = self.tr(
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
89 "Folder '{0}' does not exist."
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
90 ).format(self.__fileName)
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 return False
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 if not os.path.isdir(self.__fileName):
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self._error = True
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
94 self._errorString = self.tr(
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
95 "'{0}' is not a folder."
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
96 ).format(self.__fileName)
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 return True
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 def importedBookmarks(self):
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 """
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 Public method to get the imported bookmarks.
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 @return imported bookmarks (BookmarkNode)
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 """
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
105 from ..BookmarkNode import BookmarkNode
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
106
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 folders = {}
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 importRootNode = BookmarkNode(BookmarkNode.Folder)
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 folders[self.__fileName] = importRootNode
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
112 for directory, subdirs, files in os.walk(self.__fileName):
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 for subdir in subdirs:
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
114 path = os.path.join(directory, subdir)
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
115 if directory in folders:
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
116 folder = BookmarkNode(BookmarkNode.Folder,
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
117 folders[directory])
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 else:
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 folder = BookmarkNode(BookmarkNode.Folder, importRootNode)
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 folder.title = subdir.replace("&", "&&")
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 folders[path] = folder
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 for file in files:
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 name, ext = os.path.splitext(file)
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 if ext.lower() == ".url":
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
126 path = os.path.join(directory, file)
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 try:
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 f = open(path, "r")
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 contents = f.read()
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 f.close()
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 except IOError:
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 continue
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 url = ""
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 for line in contents.splitlines():
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 if line.startswith("URL="):
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 url = line.replace("URL=", "")
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 break
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 if url:
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
139 if directory in folders:
3002
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
140 bookmark = BookmarkNode(BookmarkNode.Bookmark,
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
141 folders[directory])
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 else:
3002
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
143 bookmark = BookmarkNode(BookmarkNode.Bookmark,
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
144 importRootNode)
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 bookmark.url = url
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 bookmark.title = name.replace("&", "&&")
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 if self._id == "ie":
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
149 importRootNode.title = self.tr("Internet Explorer Import")
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 else:
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
151 importRootNode.title = self.tr(
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
152 "Imported {0}"
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
153 ).format(QDate.currentDate().toString(Qt.SystemLocaleShortDate))
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 return importRootNode

eric ide

mercurial