eric6/WebBrowser/Bookmarks/BookmarksImporters/IExplorerImporter.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7836
2f0d208b8137
child 8143
2c730d5fd177
permissions
-rw-r--r--

Updated copyright for 2021.

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
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7836
diff changeset
3 # Copyright (c) 2012 - 2021 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
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
12 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
13
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from .BookmarksImporter import BookmarksImporter
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 import UI.PixmapCache
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import Globals
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
20 def getImporterInfo(sourceId):
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 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
23
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
24 @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
25 @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
26 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
27 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
28 (string)
2954
bf0215fe12d1 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
29 @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
30 """
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
31 if sourceId == "ie":
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 if Globals.isWindowsPlatform():
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 standardDir = os.path.expandvars(
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 "%USERPROFILE%\\Favorites")
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 else:
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 standardDir = ""
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 return (
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
38 UI.PixmapCache.getPixmap("internet_explorer"),
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 "Internet Explorer",
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 "",
3002
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
41 QCoreApplication.translate(
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
42 "IExplorerImporter",
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
43 """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
44 """ <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
45 """ located in"""),
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
46 QCoreApplication.translate(
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
47 "IExplorerImporter",
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """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
49 standardDir,
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 )
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 else:
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
52 raise ValueError(
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
53 "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
54
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 class IExplorerImporter(BookmarksImporter):
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 """
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 Class implementing the Chrome bookmarks importer.
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 """
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
60 def __init__(self, sourceId="", parent=None):
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 """
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 Constructor
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
64 @param sourceId source ID (string)
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 @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
66 """
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
67 super(IExplorerImporter, self).__init__(sourceId, parent)
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.__fileName = ""
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 def setPath(self, path):
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 """
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 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
74
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 @param path bookmarks file or directory (string)
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 """
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.__fileName = path
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 def open(self):
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 """
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 Public method to open the bookmarks file.
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 @return flag indicating success (boolean)
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 """
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 if not os.path.exists(self.__fileName):
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self._error = True
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
87 self._errorString = self.tr(
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
88 "Folder '{0}' does not exist."
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
89 ).format(self.__fileName)
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 return False
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 if not os.path.isdir(self.__fileName):
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self._error = True
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
93 self._errorString = self.tr(
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
94 "'{0}' is not a folder."
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
95 ).format(self.__fileName)
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 return True
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 def importedBookmarks(self):
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 """
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 Public method to get the imported bookmarks.
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 @return imported bookmarks (BookmarkNode)
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 """
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
104 from ..BookmarkNode import BookmarkNode
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
105
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 folders = {}
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 importRootNode = BookmarkNode(BookmarkNode.Folder)
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 folders[self.__fileName] = importRootNode
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
111 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
112 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
113 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
114 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
115 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
116 folders[directory])
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 else:
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 folder = BookmarkNode(BookmarkNode.Folder, importRootNode)
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 folder.title = subdir.replace("&", "&&")
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 folders[path] = folder
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 for file in files:
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 name, ext = os.path.splitext(file)
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 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
125 path = os.path.join(directory, file)
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 try:
7785
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
127 with open(path, "r") as f:
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
128 contents = f.read()
7836
2f0d208b8137 Changed code to not use the OSError aliases (IOError, EnvironmentError, socket.error and select.error) anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7785
diff changeset
129 except OSError:
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 continue
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 url = ""
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 for line in contents.splitlines():
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 if line.startswith("URL="):
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 url = line.replace("URL=", "")
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 break
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 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
137 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
138 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
139 folders[directory])
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 else:
3002
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
141 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
142 importRootNode)
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 bookmark.url = url
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 bookmark.title = name.replace("&", "&&")
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 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
147 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
148 else:
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
149 importRootNode.title = self.tr(
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
150 "Imported {0}"
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
151 ).format(QDate.currentDate().toString(Qt.SystemLocaleShortDate))
1717
ba85828cd357 Added a bookmarks importer for Internet Explorer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 return importRootNode

eric ide

mercurial