Sun, 29 Jul 2012 18:05:03 +0200
Fixed some PEP-8 related issues.
--- a/Helpviewer/AdBlock/AdBlockPage.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Helpviewer/AdBlock/AdBlockPage.py Sun Jul 29 18:05:03 2012 +0200 @@ -61,7 +61,7 @@ elementHiding += "{display: none !important;}\n</style>" bodyElement = docElement.findFirst("body") - bodyElement.appendInside('<style type="text/css">\n/* AdBlock for eric */\n' + + bodyElement.appendInside('<style type="text/css">\n/* AdBlock for eric */\n' + elementHiding)
--- a/Helpviewer/Bookmarks/BookmarksImportDialog.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Helpviewer/Bookmarks/BookmarksImportDialog.py Sun Jul 29 18:05:03 2012 +0200 @@ -95,7 +95,7 @@ path = E5FileDialog.getOpenFileName( self, self.trUtf8("Choose File ..."), - self.__sourceDir, + self.__sourceDir, filter) if path:
--- a/Helpviewer/Bookmarks/BookmarksImporters/BookmarksImporter.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Helpviewer/Bookmarks/BookmarksImporters/BookmarksImporter.py Sun Jul 29 18:05:03 2012 +0200 @@ -9,6 +9,7 @@ from PyQt4.QtCore import QObject + class BookmarksImporter(QObject): """ Class implementing the base class for the bookmarks importers.
--- a/Helpviewer/Bookmarks/BookmarksImporters/HtmlImporter.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Helpviewer/Bookmarks/BookmarksImporters/HtmlImporter.py Sun Jul 29 18:05:03 2012 +0200 @@ -35,7 +35,7 @@ "HTML Netscape Bookmarks") + " (*.htm *.html)", QCoreApplication.translate("HtmlImporter", """You can import bookmarks from any browser that supports HTML """ - """exporting. This file has usually the extension .htm or .html.""" ), + """exporting. This file has usually the extension .htm or .html."""), QCoreApplication.translate("HtmlImporter", """Please choose the file to begin importing bookmarks."""), "",
--- a/Helpviewer/Bookmarks/BookmarksImporters/XbelImporter.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Helpviewer/Bookmarks/BookmarksImporters/XbelImporter.py Sun Jul 29 18:05:03 2012 +0200 @@ -68,7 +68,7 @@ " (*.xbel *.xml)", QCoreApplication.translate("XbelImporter", """You can import bookmarks from any browser that supports XBEL """ - """exporting. This file has usually the extension .xbel or .xml.""" ), + """exporting. This file has usually the extension .xbel or .xml."""), QCoreApplication.translate("XbelImporter", """Please choose the file to begin importing bookmarks."""), "",
--- a/Helpviewer/Bookmarks/BookmarksImporters/__init__.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Helpviewer/Bookmarks/BookmarksImporters/__init__.py Sun Jul 29 18:05:03 2012 +0200 @@ -83,6 +83,7 @@ else: raise ValueError("Invalid importer ID given ({0}).".format(id)) + def getImporter(id, parent=None): """ Module function to get an importer for the given source id.
--- a/Helpviewer/HelpTabWidget.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Helpviewer/HelpTabWidget.py Sun Jul 29 18:05:03 2012 +0200 @@ -868,7 +868,7 @@ act = self.sender() tab = self.__closedTabsManager.getClosedTabAt(act.data()) - self.newBrowser(tab.url.toString(), position = tab.position) + self.newBrowser(tab.url.toString(), position=tab.position) def canRestoreClosedTab(self): """ @@ -886,7 +886,7 @@ return for tab in self.__closedTabsManager.allClosedTabs(): - self.newBrowser(tab.url.toString(), position = tab.position) + self.newBrowser(tab.url.toString(), position=tab.position) self.__closedTabsManager.clearList() def clearClosedTabsList(self): @@ -906,7 +906,7 @@ index = 0 for tab in self.__closedTabsManager.allClosedTabs(): title = fm.elidedText(tab.title, Qt.ElideRight, maxWidth) - self.__closedTabsMenu.addAction(self.__mainWindow.icon(tab.url), title, + self.__closedTabsMenu.addAction(self.__mainWindow.icon(tab.url), title, self.restoreClosedTab).setData(index) index += 1 self.__closedTabsMenu.addSeparator()
--- a/Helpviewer/HelpUtilities.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Helpviewer/HelpUtilities.py Sun Jul 29 18:05:03 2012 +0200 @@ -19,7 +19,7 @@ @param url URL (QUrl) @return file name (string) """ - fileName = url.toString(QUrl.RemoveFragment | QUrl.RemoveQuery | + fileName = url.toString(QUrl.RemoveFragment | QUrl.RemoveQuery | QUrl.RemoveScheme | QUrl.RemovePort) if fileName.find("/") != -1: pos = fileName.rfind("/")
--- a/Helpviewer/HelpWindow.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Helpviewer/HelpWindow.py Sun Jul 29 18:05:03 2012 +0200 @@ -367,7 +367,7 @@ settings.setAttribute(QWebSettings.SiteSpecificQuirksEnabled, Preferences.getHelp("SiteSpecificQuirksEnabled")) - QWebSecurityOrigin.addLocalScheme("eric"); + QWebSecurityOrigin.addLocalScheme("eric") def __initActions(self): """
--- a/Helpviewer/History/HistoryMenu.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Helpviewer/History/HistoryMenu.py Sun Jul 29 18:05:03 2012 +0200 @@ -383,7 +383,7 @@ for tab in self.__tabWidget.closedTabsManager().allClosedTabs(): title = fm.elidedText(tab.title, Qt.ElideRight, maxWidth) self.__closedTabsMenu.addAction( - Helpviewer.HelpWindow.HelpWindow.icon(tab.url), title, + Helpviewer.HelpWindow.HelpWindow.icon(tab.url), title, self.__tabWidget.restoreClosedTab).setData(index) index += 1 self.__closedTabsMenu.addSeparator()
--- a/Helpviewer/SpeedDial/SpeedDial.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Helpviewer/SpeedDial/SpeedDial.py Sun Jul 29 18:05:03 2012 +0200 @@ -105,7 +105,7 @@ @param url URL to generate the file name from (string) @return name of the image file (string) """ - return os.path.join(self.__thumbnailsDirectory, + return os.path.join(self.__thumbnailsDirectory, str(QCryptographicHash.hash(QByteArray(url.encode("utf-8")), QCryptographicHash.Md5).toHex(), encoding="utf-8") + ".png")
--- a/Helpviewer/Sync/DirectorySyncHandler.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Helpviewer/Sync/DirectorySyncHandler.py Sun Jul 29 18:05:03 2012 +0200 @@ -88,7 +88,7 @@ data = f.read() f.close() except IOError as err: - self.syncStatus.emit(type_, + self.syncStatus.emit(type_, self.trUtf8("Cannot read remote file.\n{0}").format(str(err))) self.syncFinished(type_, False, True) return
--- a/Helpviewer/Sync/SyncEncryptionPage.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Helpviewer/Sync/SyncEncryptionPage.py Sun Jul 29 18:05:03 2012 +0200 @@ -70,7 +70,7 @@ complete = False else: if self.reencryptCheckBox.isChecked(): - complete = (self.encryptionKeyEdit.text() == + complete = (self.encryptionKeyEdit.text() == self.encryptionKeyAgainEdit.text()) else: complete = True
--- a/Helpviewer/WebPlugins/ClickToFlash/ClickToFlash.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Helpviewer/WebPlugins/ClickToFlash/ClickToFlash.py Sun Jul 29 18:05:03 2012 +0200 @@ -147,9 +147,9 @@ substitute.setAttribute("type", self.__mimeType) self.__element.replace(substitute) - ClickToFlash._acceptedUrl = self.__url; - ClickToFlash._acceptedArgNames = self.__argumentNames; - ClickToFlash._acceptedArgValues = self.__argumentValues; + ClickToFlash._acceptedUrl = self.__url + ClickToFlash._acceptedArgNames = self.__argumentNames + ClickToFlash._acceptedArgValues = self.__argumentValues def __findElement(self): """
--- a/Helpviewer/WebPlugins/ClickToFlash/ClickToFlashPlugin.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Helpviewer/WebPlugins/ClickToFlash/ClickToFlashPlugin.py Sun Jul 29 18:05:03 2012 +0200 @@ -23,47 +23,47 @@ Class implementing the flash blocker plug-in. """ ClickToFlashData = { - "application/x-shockwave-flash" : { + "application/x-shockwave-flash": { "extensions": ["swf"], "icon": "flashBlock-flash.png" }, - "application/futuresplash" : { + "application/futuresplash": { "extensions": ["spl"], "icon": "flashBlock-flash.png" }, - "application/x-director" : { + "application/x-director": { "extensions": ["dir", "dcr", "dxr"], "icon": "flashBlock-director.png" }, - "application/x-authorware-map" : { + "application/x-authorware-map": { "extensions": ["aam"], "icon": "flashBlock-authorware.png" }, - "application/x-authorware-seg" : { + "application/x-authorware-seg": { "extensions": ["aas"], "icon": "flashBlock-authorware.png" }, - "application/x-authorware-bin" : { + "application/x-authorware-bin": { "extensions": ["aab", "x32", "u32", "vox"], "icon": "flashBlock-authorware.png" }, - "image/x-freehand" : { + "image/x-freehand": { "extensions": ["fh4", "fh7", "fh5", "fhc", "fh"], "icon": "flashBlock-freehand.png" }, - "application/x-silverlight-app" : { + "application/x-silverlight-app": { "extensions": ["xap"], "icon": "flashBlock-silverlight.png" }, - "application/xaml+xml" : { + "application/xaml+xml": { "extensions": ["xaml"], "icon": "flashBlock-silverlight.png" }, - "application/x-ms-xbap" : { + "application/x-ms-xbap": { "extensions": ["xbap"], "icon": "flashBlock-silverlight.png" }, - "application/x-java-applet" : { + "application/x-java-applet": { "extensions": [], "icon": "flashBlock-java.png" },
--- a/Helpviewer/WebPlugins/WebPluginInterface.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Helpviewer/WebPlugins/WebPluginInterface.py Sun Jul 29 18:05:03 2012 +0200 @@ -7,6 +7,7 @@ Module implementing the web plug-in interface. """ + class WebPluginInterface(object): """ Class implementing the web plug-in interface.
--- a/Plugins/VcsPlugins/vcsMercurial/HgRemoveSubrepositoriesDialog.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/HgRemoveSubrepositoriesDialog.py Sun Jul 29 18:05:03 2012 +0200 @@ -57,7 +57,7 @@ list of strings, boolean) """ return ( - [self.subrepositories.item(row).text() + [self.subrepositories.item(row).text() for row in range(self.subrepositories.count())], self.__removed, self.deleteCheckBox.isChecked()
--- a/Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardCharactersDialog.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Plugins/WizardPlugins/QRegExpWizard/QRegExpWizardCharactersDialog.py Sun Jul 29 18:05:03 2012 +0200 @@ -155,21 +155,21 @@ """ self.__characterCategories = ( # display name code - (self.trUtf8("Letter, Any"), "L" ), + (self.trUtf8("Letter, Any"), "L"), (self.trUtf8("Letter, Uppercase"), "Lu"), (self.trUtf8("Letter, Lowercase"), "Ll"), (self.trUtf8("Letter, Titlecase"), "Lt"), (self.trUtf8("Letter, Modifier"), "Lm"), (self.trUtf8("Letter, Other"), "Lo"), - (self.trUtf8("Mark, Any"), "M" ), + (self.trUtf8("Mark, Any"), "M"), (self.trUtf8("Mark, Nonspacing"), "Mn"), (self.trUtf8("Mark, Spacing Combining"), "Mc"), (self.trUtf8("Mark, Enclosing"), "Me"), - (self.trUtf8("Number, Any"), "N" ), + (self.trUtf8("Number, Any"), "N"), (self.trUtf8("Number, Decimal Digit"), "Nd"), (self.trUtf8("Number, Letter"), "Nl"), (self.trUtf8("Number, Other"), "No"), - (self.trUtf8("Punctuation, Any"), "P" ), + (self.trUtf8("Punctuation, Any"), "P"), (self.trUtf8("Punctuation, Connector"), "Pc"), (self.trUtf8("Punctuation, Dash"), "Pd"), (self.trUtf8("Punctuation, Open"), "Ps"), @@ -177,16 +177,16 @@ (self.trUtf8("Punctuation, Initial Quote"), "Pi"), (self.trUtf8("Punctuation, Final Quote"), "Pf"), (self.trUtf8("Punctuation, Other"), "Po"), - (self.trUtf8("Symbol, Any"), "S" ), + (self.trUtf8("Symbol, Any"), "S"), (self.trUtf8("Symbol, Math"), "Sm"), (self.trUtf8("Symbol, Currency"), "Sc"), (self.trUtf8("Symbol, Modifier"), "Sk"), (self.trUtf8("Symbol, Other"), "So"), - (self.trUtf8("Separator, Any"), "Z" ), + (self.trUtf8("Separator, Any"), "Z"), (self.trUtf8("Separator, Space"), "Zs"), (self.trUtf8("Separator, Line"), "Zl"), (self.trUtf8("Separator, Paragraph"), "Zp"), - (self.trUtf8("Other, Any"), "C" ), + (self.trUtf8("Other, Any"), "C"), (self.trUtf8("Other, Control"), "Cc"), (self.trUtf8("Other, Format"), "Cf"), (self.trUtf8("Other, Private Use"), "Co"),
--- a/Preferences/__init__.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Preferences/__init__.py Sun Jul 29 18:05:03 2012 +0200 @@ -87,7 +87,7 @@ "PathTranslationRemote": "", "PathTranslationLocal": "", "NetworkInterface": "127.0.0.1", - "AutoViewSourceCode" : False, + "AutoViewSourceCode": False, } debuggerDefaults["AllowedHosts"] = ["127.0.0.1", "::1%0"] @@ -654,7 +654,7 @@ "SearchLanguage": QLocale().language(), "DoNotTrack": False, "SendReferer": True, - "SendRefererWhitelist": ["qt-apps.org", "kde-apps.org"], + "SendRefererWhitelist": ["qt-apps.org", "kde-apps.org"], "RssFeeds": [], "SyncEnabled": False, "SyncBookmarks": True,
--- a/QScintilla/Shell.py Sun Jul 29 17:26:28 2012 +0200 +++ b/QScintilla/Shell.py Sun Jul 29 18:05:03 2012 +0200 @@ -1597,7 +1597,7 @@ @param txt text to search for (string) @param caseSensitive flag indicating to perform a case sensitive search (boolean) - @param wholeWord flag indicating to search for whole words + @param wholeWord flag indicating to search for whole words only (boolean) """ self.__lastSearch = (txt, caseSensitive, wholeWord) @@ -1618,7 +1618,7 @@ @param txt text to search for (string) @param caseSensitive flag indicating to perform a case sensitive search (boolean) - @param wholeWord flag indicating to search for whole words + @param wholeWord flag indicating to search for whole words only (boolean) """ self.__lastSearch = (txt, caseSensitive, wholeWord)
--- a/QScintilla/Terminal.py Sun Jul 29 17:26:28 2012 +0200 +++ b/QScintilla/Terminal.py Sun Jul 29 18:05:03 2012 +0200 @@ -1094,7 +1094,7 @@ @param txt text to search for (string) @param caseSensitive flag indicating to perform a case sensitive search (boolean) - @param wholeWord flag indicating to search for whole words + @param wholeWord flag indicating to search for whole words only (boolean) """ self.__lastSearch = (txt, caseSensitive, wholeWord) @@ -1115,7 +1115,7 @@ @param txt text to search for (string) @param caseSensitive flag indicating to perform a case sensitive search (boolean) - @param wholeWord flag indicating to search for whole words + @param wholeWord flag indicating to search for whole words only (boolean) """ self.__lastSearch = (txt, caseSensitive, wholeWord)
--- a/Snapshot/SnapWidget.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Snapshot/SnapWidget.py Sun Jul 29 18:05:03 2012 +0200 @@ -72,10 +72,10 @@ index = 0 self.modeCombo.setCurrentIndex(index) - self.__delay = int(Preferences.Prefs.settings.value( "Snapshot/Delay", 0)) + self.__delay = int(Preferences.Prefs.settings.value("Snapshot/Delay", 0)) self.delaySpin.setValue(self.__delay) - self.__filename = Preferences.Prefs.settings.value( "Snapshot/Filename", + self.__filename = Preferences.Prefs.settings.value("Snapshot/Filename", os.path.join( QDesktopServices.storageLocation(QDesktopServices.PicturesLocation), self.trUtf8("snapshot") + "1.png")) @@ -87,7 +87,7 @@ self.__grabberWidget = QWidget(None, Qt.X11BypassWindowManagerHint) self.__grabberWidget.move(-10000, -10000) - self.__grabberWidget.installEventFilter(self); + self.__grabberWidget.installEventFilter(self) self.__initFileFilters() @@ -259,13 +259,13 @@ start = numSearch.pos(2) # Only the second group is of interest. numAsStr = numSearch.capturedTexts()[2] number = "{0:0{width}d}".format(int(numAsStr) + 1, width=len(numAsStr)) - name = name[:start] + number + name[start+len(numAsStr):] + name = name[:start] + number + name[start + len(numAsStr):] else: # no number start = name.rfind('.') if start != -1: # has a '.' somewhere, e.g. it has an extension - name = name [:start] + '1' + name[start:] + name = name[:start] + '1' + name[start:] else: # no extension, just tack it on to the end name += '1'
--- a/Snapshot/SnapshotFreehandGrabber.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Snapshot/SnapshotFreehandGrabber.py Sun Jul 29 18:05:03 2012 +0200 @@ -49,7 +49,7 @@ Constructor """ super().__init__(None, - Qt.X11BypassWindowManagerHint | Qt.WindowStaysOnTopHint | + Qt.X11BypassWindowManagerHint | Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | Qt.Tool) self.__selection = QPolygon()
--- a/Snapshot/SnapshotRegionGrabber.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Snapshot/SnapshotRegionGrabber.py Sun Jul 29 18:05:03 2012 +0200 @@ -58,7 +58,7 @@ SnapshotRegionGrabber.Ellipse) """ super().__init__(None, - Qt.X11BypassWindowManagerHint | Qt.WindowStaysOnTopHint | + Qt.X11BypassWindowManagerHint | Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | Qt.Tool) assert mode in [SnapshotRegionGrabber.Rectangle, @@ -88,7 +88,7 @@ self.__RHandle = QRect(0, 0, self.__handleSize, self.__handleSize) self.__BHandle = QRect(0, 0, self.__handleSize, self.__handleSize) self.__handles = [self.__TLHandle, self.__TRHandle, self.__BLHandle, - self.__BRHandle, self.__LHandle, self.__THandle, + self.__BRHandle, self.__LHandle, self.__THandle, self.__RHandle, self.__BHandle] self.__helpTextRect = QRect() self.__helpText = self.trUtf8( @@ -441,7 +441,7 @@ if r.width() <= 0: l = r.left() w = r.width() - r.setLeft(l + w -1) + r.setLeft(l + w - 1) r.setRight(l) if r.height() <= 0: t = r.top()
--- a/Snapshot/SnapshotTimer.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Snapshot/SnapshotTimer.py Sun Jul 29 18:05:03 2012 +0200 @@ -25,7 +25,7 @@ """ super().__init__(None) - self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | + self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | Qt.X11BypassWindowManagerHint) self.__timer = QTimer()
--- a/Tasks/TaskViewer.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Tasks/TaskViewer.py Sun Jul 29 18:05:03 2012 +0200 @@ -354,7 +354,7 @@ task.setCompleted(data[2]) task.setProjectTask(data[3]) task.setLongText(data[4]) - self.__projectTasksSaveTimer.changeOccurred() + self.__projectTasksSaveTimer.changeOccurred() def __newTask(self): """
--- a/Utilities/binplistlib.py Sun Jul 29 17:26:28 2012 +0200 +++ b/Utilities/binplistlib.py Sun Jul 29 18:05:03 2012 +0200 @@ -21,7 +21,7 @@ Date values can only be datetime.datetime objects. -The exceptions InvalidPlistException and NotBinaryPlistException may be +The exceptions InvalidPlistException and NotBinaryPlistException may be thrown to indicate that the data cannot be serialized or deserialized as a binary plist. @@ -68,7 +68,7 @@ # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of biplist nor the names of its contributors may be -# used to endorse or promote products derived from this software without +# used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" @@ -156,6 +156,7 @@ pathOrFile.close() return result + def writePlist(rootObject, pathOrFile, binary=True): """ Module function to write a plist file. @@ -178,6 +179,7 @@ pathOrFile.close() return + def readPlistFromBytes(data): """ Module function to read from a plist bytes object. @@ -188,6 +190,7 @@ """ return readPlist(BytesIO(data)) + def writePlistToBytes(rootObject, binary=True): """ Module function to write a plist bytes object. @@ -203,6 +206,7 @@ writer.writeRoot(rootObject) return io.getvalue() + def is_stream_binary_plist(stream): """ Module function to check, if the stream is a binary plist. @@ -223,6 +227,7 @@ 'nullBytes, boolBytes, intBytes, realBytes, dateBytes, dataBytes, stringBytes, ' 'uidBytes, arrayBytes, setBytes, dictBytes') + class PlistReader(object): """ Class implementing the plist reader. @@ -279,11 +284,11 @@ self.trailer = PlistTrailer._make(unpack("!xxxxxxBBQQQ", trailerContents)) offset_size = self.trailer.offsetSize * self.trailer.offsetCount offset = self.trailer.offsetTableOffset - offset_contents = self.contents[offset:offset+offset_size] + offset_contents = self.contents[offset:offset + offset_size] offset_i = 0 while offset_i < self.trailer.offsetCount: - begin = self.trailer.offsetSize*offset_i - tmp_contents = offset_contents[begin:begin+self.trailer.offsetSize] + begin = self.trailer.offsetSize * offset_i + tmp_contents = offset_contents[begin:begin + self.trailer.offsetSize] tmp_sized = self.getSizedInteger(tmp_contents, self.trailer.offsetSize) self.offsets.append(tmp_sized) offset_i += 1 @@ -308,7 +313,7 @@ @return unpickled object """ result = None - tmp_byte = self.contents[self.currentOffset:self.currentOffset+1] + tmp_byte = self.contents[self.currentOffset:self.currentOffset + 1] marker_byte = unpack("!B", tmp_byte)[0] format = (marker_byte >> 4) & 0x0f extra = marker_byte & 0x0f @@ -329,7 +334,7 @@ elif extra == 0b1001: result = True elif extra == 0b1111: - pass # fill byte + pass # fill byte else: raise InvalidPlistException( "Invalid object found at offset: {0}".format(self.currentOffset - 1)) @@ -371,7 +376,7 @@ elif format == 0b1101: extra = proc_extra(extra) result = self.readDict(extra) - else: + else: raise InvalidPlistException( "Invalid object found: {{format: {0}, extra: {1}}}".format( bin(format), bin(extra))) @@ -386,7 +391,7 @@ """ result = 0 original_offset = self.currentOffset - data = self.contents[self.currentOffset:self.currentOffset+bytes] + data = self.contents[self.currentOffset:self.currentOffset + bytes] result = self.getSizedInteger(data, bytes) self.currentOffset = original_offset + bytes return result @@ -400,17 +405,17 @@ """ result = 0.0 to_read = pow(2, length) - data = self.contents[self.currentOffset:self.currentOffset+to_read] - if length == 2: # 4 bytes + data = self.contents[self.currentOffset:self.currentOffset + to_read] + if length == 2: # 4 bytes result = unpack('>f', data)[0] - elif length == 3: # 8 bytes + elif length == 3: # 8 bytes result = unpack('>d', data)[0] else: raise InvalidPlistException( "Unknown real of length {0} bytes".format(to_read)) return result - def readRefs(self, count): + def readRefs(self, count): """ Private method to read References. @@ -421,7 +426,7 @@ i = 0 while i < count: fragment = self.contents[ - self.currentOffset:self.currentOffset+self.trailer.objectRefSize] + self.currentOffset:self.currentOffset + self.trailer.objectRefSize] ref = self.getSizedInteger(fragment, len(fragment)) refs.append(ref) self.currentOffset += self.trailer.objectRefSize @@ -473,7 +478,7 @@ @return ASCII encoded string """ result = str(unpack("!{0}s".format(length), - self.contents[self.currentOffset:self.currentOffset+length])[0], + self.contents[self.currentOffset:self.currentOffset + length])[0], encoding="ascii") self.currentOffset += length return result @@ -485,8 +490,8 @@ @param length length of the string (integer) @return unicode encoded string """ - actual_length = length*2 - data = self.contents[self.currentOffset:self.currentOffset+actual_length] + actual_length = length * 2 + data = self.contents[self.currentOffset:self.currentOffset + actual_length] # unpack not needed?!! data = unpack(">%ds" % (actual_length), data)[0] self.currentOffset += actual_length return data.decode('utf_16_be') @@ -498,7 +503,7 @@ @return date object (datetime.datetime) """ global apple_reference_date_offset - result = unpack(">d", self.contents[self.currentOffset:self.currentOffset+8])[0] + result = unpack(">d", self.contents[self.currentOffset:self.currentOffset + 8])[0] result = datetime.datetime.utcfromtimestamp(result + apple_reference_date_offset) self.currentOffset += 8 return result @@ -510,7 +515,7 @@ @param length number of bytes to read (integer) @return Data object """ - result = self.contents[self.currentOffset:self.currentOffset+length] + result = self.contents[self.currentOffset:self.currentOffset + length] self.currentOffset += length return Data(result) @@ -521,7 +526,7 @@ @param length length of the UID (integer) @return Uid object """ - return Uid(self.readInteger(length+1)) + return Uid(self.readInteger(length + 1)) def getSizedInteger(self, data, bytes): """ @@ -544,24 +549,29 @@ raise InvalidPlistException("Encountered integer longer than 8 bytes.") return result + class HashableWrapper(object): """ Class wrapping a hashable value. """ def __init__(self, value): self.value = value + def __repr__(self): return "<HashableWrapper: %s>" % [self.value] + class BoolWrapper(object): """ Class wrapping a boolean value. """ def __init__(self, value): self.value = value + def __repr__(self): return "<BoolWrapper: %s>" % self.value + class PlistWriter(object): """ Class implementing the plist writer. @@ -640,20 +650,20 @@ """ output = self.header wrapped_root = self.wrapRoot(root) - should_reference_root = True#not isinstance(wrapped_root, HashableWrapper) + should_reference_root = True # not isinstance(wrapped_root, HashableWrapper) self.computeOffsets(wrapped_root, asReference=should_reference_root, isRoot=True) self.trailer = self.trailer._replace( - **{'objectRefSize':self.intSize(len(self.computedUniques))}) + **{'objectRefSize': self.intSize(len(self.computedUniques))}) (_, output) = self.writeObjectReference(wrapped_root, output) output = self.writeObject(wrapped_root, output, setReferencePosition=True) # output size at this point is an upper bound on how big the # object reference offsets need to be. self.trailer = self.trailer._replace(**{ - 'offsetSize':self.intSize(len(output)), - 'offsetCount':len(self.computedUniques), - 'offsetTableOffset':len(output), - 'topLevelObjectNumber':0 + 'offsetSize': self.intSize(len(output)), + 'offsetCount': len(self.computedUniques), + 'offsetTableOffset': len(output), + 'topLevelObjectNumber': 0 }) output = self.writeOffsetTable(output) @@ -695,7 +705,7 @@ def incrementByteCount(self, field, incr=1): self.byteCounts = self.byteCounts._replace( - **{field:self.byteCounts.__getattribute__(field) + incr}) + **{field: self.byteCounts.__getattribute__(field) + incr}) def computeOffsets(self, obj, asReference=False, isRoot=False): def check_key(key): @@ -724,36 +734,36 @@ self.incrementByteCount('boolBytes') elif isinstance(obj, Uid): size = self.intSize(obj) - self.incrementByteCount('uidBytes', incr=1+size) + self.incrementByteCount('uidBytes', incr=1 + size) elif isinstance(obj, int): size = self.intSize(obj) - self.incrementByteCount('intBytes', incr=1+size) + self.incrementByteCount('intBytes', incr=1 + size) elif isinstance(obj, (float)): size = self.realSize(obj) - self.incrementByteCount('realBytes', incr=1+size) - elif isinstance(obj, datetime.datetime): + self.incrementByteCount('realBytes', incr=1 + size) + elif isinstance(obj, datetime.datetime): self.incrementByteCount('dateBytes', incr=2) elif isinstance(obj, Data): size = proc_size(len(obj)) - self.incrementByteCount('dataBytes', incr=1+size) + self.incrementByteCount('dataBytes', incr=1 + size) elif isinstance(obj, str): size = proc_size(len(obj)) - self.incrementByteCount('stringBytes', incr=1+size) + self.incrementByteCount('stringBytes', incr=1 + size) elif isinstance(obj, HashableWrapper): obj = obj.value if isinstance(obj, set): size = proc_size(len(obj)) - self.incrementByteCount('setBytes', incr=1+size) + self.incrementByteCount('setBytes', incr=1 + size) for value in obj: self.computeOffsets(value, asReference=True) elif isinstance(obj, (list, tuple)): size = proc_size(len(obj)) - self.incrementByteCount('arrayBytes', incr=1+size) + self.incrementByteCount('arrayBytes', incr=1 + size) for value in obj: self.computeOffsets(value, asReference=True) elif isinstance(obj, dict): size = proc_size(len(obj)) - self.incrementByteCount('dictBytes', incr=1+size) + self.incrementByteCount('dictBytes', incr=1 + size) for key, value in obj.items(): check_key(key) self.computeOffsets(key, asReference=True) @@ -838,7 +848,7 @@ elif isinstance(obj, str): # Python 3 uses unicode strings only bytes = obj.encode('utf_16_be') - output += proc_variable_length(0b0110, len(bytes)/2) + output += proc_variable_length(0b0110, len(bytes) / 2) output += bytes elif isinstance(obj, HashableWrapper): obj = obj.value @@ -885,7 +895,7 @@ all_positions = [] writtenReferences = list(self.writtenReferences.items()) writtenReferences.sort(key=lambda x: x[1]) - for obj,order in writtenReferences: + for obj, order in writtenReferences: position = self.referencePositions.get(obj) if position is None: raise InvalidPlistException( @@ -939,18 +949,18 @@ @return number of bytes required (integer) """ # SIGNED - if obj < 0: # Signed integer, always 8 bytes + if obj < 0: # Signed integer, always 8 bytes return 8 # UNSIGNED - elif obj <= 0xFF: # 1 byte + elif obj <= 0xFF: # 1 byte return 1 - elif obj <= 0xFFFF: # 2 bytes + elif obj <= 0xFFFF: # 2 bytes return 2 - elif obj <= 0xFFFFFFFF: # 4 bytes + elif obj <= 0xFFFFFFFF: # 4 bytes return 4 # SIGNED # 0x7FFFFFFFFFFFFFFF is the max. - elif obj <= 0x7FFFFFFFFFFFFFFF: # 8 bytes + elif obj <= 0x7FFFFFFFFFFFFFFF: # 8 bytes return 8 else: raise InvalidPlistException(
--- a/eric5.e4p Sun Jul 29 17:26:28 2012 +0200 +++ b/eric5.e4p Sun Jul 29 18:05:03 2012 +0200 @@ -1793,7 +1793,7 @@ <string>ExcludeFiles</string> </key> <value> - <string>*/ThirdParty/*, */coverage/*, */Ui_*.py, */Examples/*</string> + <string>*/ThirdParty/*, */coverage/*, */Ui_*.py, */Examples/*, */*_rc.py</string> </value> <key> <string>ExcludeMessages</string>