mojo.extensions

getExtensionDefault(key, fallback=None)

Get a default value for a key, with a fallback value if the key is not present in the defaults.

setExtensionDefault(key, value, validate=False)

Set a default value for a key.

Optionally validate the key and the value.

getExtensionDefaultColor(key, fallback=None)

Get a default color object for a key, with a fallback value if the key is not present in the defaults.

The fallback must be a NSColor object.

setExtensionDefaultColor(key, value, validate=False)

Set a default color for a key.

Optionally validate the key and the color.

registerExtensionDefaults(defaults, validate=False)

Register a default dictionary. This will not overwrite existing defaults.

removeExtensionDefault(key)

Remove a key from the extension’s defaults.

class ExtensionBundle()

An object to read, write and install extensions.

Extension Bundle Specification, version 4

.roboFontExt

    lib                                 folder
    lib.x.y                             folder         (not required, optional folder supporting a specific python version, fe lib.3.7, v3)
    html                                folder         (not required, unless html is True in the info.plist, must contain index.html or index.md, optionally style.css)
    resources                           folder         (not required)
    info.plist                          plist xml
        {
        name                            str
        developer                       str
        developerURL                    str
        html                            bool           (not required, if True html folder is required)
        documentationURL                str            (not required, if provided it must start with 'http(s)://' v4)
        launchAtStartUp                 bool
        mainScript                      str
        uninstallScript                 str            (not required, v2)
        addToMenu                       list of dicts
            [
                * {
                path                    str
                preferredName           str
                shortKey                str or tuple
                nestInSubmenus          bool           (not required, v2)
                }
            ]
        timeStamp                       float
        version                         str
        requiresVersionMajor            str            (not required)
        requiresVersionMinor            str            (not required)
        expireDate                      str            (not required, if set use the format YYYY-MM-DD)
        }
    license                             txt / html     (not required)
    requirements.txt                    txt            (not required)

icon

Get and set the extension icon.

resourcesNamesMap

Get a dictionary mapping resources file names to paths.

HTMLPath()

addScriptToMenu(path, preferredName, shortKey='')

Add a script to the extension menu.

  • path : path to a Python file
  • preferredName : name to be displayed in the menu
  • shortKey : shortcut key to access the menu item (optional)

deinstall(update=True)

Uninstall the extension.

extensionHash(passphrase='')

Generates the extension hash.

extractPathFromName()

getDeveloperNSURL()

Get the developer URL as a NSURL object.

getDocumentationNSURL()

Get the documentation URL as a NSURL object.

getInfo(key, fallback=None)

Get info with a key.

Optionally a fallback value can be provided.

getResourceFilePath(name, ext='*')

Get the path to a resource file by name.

Optionally an extension ext can be provided.

getResourceImage(imageName, ext='*')

Get an image resource by imageName.

Optionally an extension ext can be provided.

install(showMessages=True)

Install the extension.

Optionally, use showMessages to disable messages.

iterParseRequirements(requirements)

libPath()

loadBundle()

Load the extension.

loadRequirements(done, loadingErrors)

Load the extension requirements (dependencies) from the requirements file.

openHelp()

Open a help window for the extension.

resolveRequirements()

resourcesPath()

setInfo(key, value)

Set info with a key and value.

allExtensions()

Get a list of all installed extensions.

buildExtensionMenu(menu)

Build the menu for the extension.

currentBundle(filePath=None)

Return the current bundle.

Optionally provide a filePath inside the host extension bundle.

loadAllExtensions()

Loads all installed extensions. This is used by RoboFont during startup.

safeLoadBundle(bundleName)

updatePreferenceWindow()

Update the Preferences window.

updateScriptingMenu()

Update the scripting menu.

Inherits from subclass: roboFontExtensionBundle.bundle.ExtensionBundle

HTMLIndexPath

Path to the index.html HTML help file.

bundlePath

Path to the extension bundle.

developer

developerURL

documentationURL

expireDate

expireDateFormat

fileExtension

fileName

Extension filename.

hasDocumentation

Returns True if the extension has either local or online documentation.

hasHTML

Returns True if the extension has HTML documentation.

hashPath

Path to the hash file.

html

htmlFolder

Path to the html folder with the extension HTML documentation.

indexHTMLName

infoDictionary

Returns a dictionary matching the info.plist data structure.

infoPlistFilename

infoPlistPath

Path to the resources folder.

launchAtStartUp

libFolder

Path to the lib folder with the extension code.

license

licensePath

Path of the license file inside the bundle.

mainScript

mainScriptPath

Path of the main script.

name

path

requirements

requirementsPath

Path to the requirements.txt file inside the bundle.

requiresVersionMajor

requiresVersionMinor

resourcesFolder

Path to the resources folder.

timeStamp

uninstallScript

uninstallScriptPath

Path of the script that uninstalls the extension.

version

bundleExists()

Returns a bool indicating if the extension bundle exists.

convertMarkdown(htmlFolder: pathlib.Path)

Converts documentation sources from Markdown to HTML.

load(bundlePath: Union[str, pathlib.Path])

Loads data from an existing bundle

unpack(destFolder: Union[str, pathlib.Path])

Saves data on disk as unpacked source data Helpful for converting existing bundles into repositories

validate() -> bool

Validates extension data. The extension must be saved on disk for the validation to happen.

validationErrors()

Returns the validation errors as a string.

Last edited on 08/12/2024