eric7.WebBrowser.Tools.WebBrowserTools

Module implementing tool functions for the web browser.

Global Attributes

WebBrowserDataDirectory

Classes

None

Functions

containsSpace Function to check, if a string contains whitespace characters.
ensureUniqueFilename Module function to generate an unique file name based on a pattern.
filterCharsFromFilename Module function to filter illegal characters.
getFileNameFromUrl Module function to generate a file name based on the given URL.
getHtmlPage Module function to load a HTML page.
getJavascript Module function to load a JavaScript source file.
getJquery Module function to load a JQuery source file.
getWebEngineVersions Module function to extract the web engine related versions from the default user agent string.
pixmapFileToDataUrl Module function to load a pixmap file and convert the pixmap to a data: URL.
pixmapFromByteArray Module function to convert a byte array to a pixmap.
pixmapToByteArray Module function to convert a pixmap to a byte array containing the pixmap as a PNG encoded as base64.
pixmapToDataUrl Module function to convert a pixmap to a data: URL.
readAllFileContents Function to read the string contents of the given file.


containsSpace

containsSpace(string)

Function to check, if a string contains whitespace characters.

string (str)
string to be checked
Return:
flag indicating the presence of at least one whitespace character
Return Type:
bool
Up


ensureUniqueFilename

ensureUniqueFilename(name, appendFormat="({0})")

Module function to generate an unique file name based on a pattern.

name (str)
desired file name
appendFormat (str)
format pattern to be used to make the unique name
Return:
unique file name
Return Type:
str
Up


filterCharsFromFilename

filterCharsFromFilename(name)

Module function to filter illegal characters.

name (str)
name to be sanitized
Return:
sanitized name
Return Type:
str
Up


getFileNameFromUrl

getFileNameFromUrl(url)

Module function to generate a file name based on the given URL.

url (QUrl)
URL
Return:
file name
Return Type:
str
Up


getHtmlPage

getHtmlPage(pageFileName)

Module function to load a HTML page.

Note: If the given HTML file path is not absolute, it is assumed to denote a HTML file in the html data directory.

pageFileName (str)
file name of the HTML file
Return:
HTML page
Return Type:
str
Up


getJavascript

getJavascript(jsFileName)

Module function to load a JavaScript source file.

Note: If the given JavaScript source file path is not absolute, it is assumed to denote a JavaScript source file in the javascript data directory.

jsFileName (str)
file name of the JavaScript source file
Return:
JavaScript source
Return Type:
str
Up


getJquery

getJquery(jqName)

Module function to load a JQuery source file.

Note: If the JQuery file is not found in the javascript data directory and the platform is Linux, it is assumed that it is installed system wide in the '/usr/share/javascript' directory (e.g. as packaged by Debian).

jqName (str)
name of the JQuery library to be loaded (one of 'jquery' or 'jquery-ui')
Return:
JQuery source
Return Type:
str
Up


getWebEngineVersions

getWebEngineVersions()

Module function to extract the web engine related versions from the default user agent string.

Note: For PyQt 6.3.1 or newer the data is extracted via some Qt functions.

Return:
tuple containing the Chromium version, the Chromium security patch version and the QtWebEngine version
Return Type:
tuple of (str, str, str)
Up


pixmapFileToDataUrl

pixmapFileToDataUrl(pixmapFile, asString=False)

Module function to load a pixmap file and convert the pixmap to a data: URL.

Note: If the given pixmap file path is not absolute, it is assumed to denote a pixmap file in the icons data directory.

pixmapFile (str)
file name of the pixmap file
asString (bool)
flag indicating a string representation is requested
Return:
data: URL
Return Type:
QUrl or str
Up


pixmapFromByteArray

pixmapFromByteArray(data)

Module function to convert a byte array to a pixmap.

data (bytes or QByteArray)
data for the pixmap
Return:
extracted pixmap
Return Type:
QPixmap
Up


pixmapToByteArray

pixmapToByteArray(pixmap)

Module function to convert a pixmap to a byte array containing the pixmap as a PNG encoded as base64.

pixmap (QPixmap)
pixmap to be converted
Return:
byte array containing the pixmap
Return Type:
QByteArray
Up


pixmapToDataUrl

pixmapToDataUrl(pixmap, mimetype="image/png")

Module function to convert a pixmap to a data: URL.

pixmap (QPixmap)
pixmap to be converted
mimetype (str)
MIME type to be used
Return:
data: URL
Return Type:
QUrl
Up


readAllFileContents

readAllFileContents(filename)

Function to read the string contents of the given file.

filename (str)
name of the file
Return:
contents of the file
Return Type:
str
Up