extpackages
Base module to handle processing extensions as packages.
Attributes
mlogger = get_logger(__name__)
module-attribute
PLUGIN_EXT_DEF_MANIFEST_NAME = 'extensions'
module-attribute
PLUGIN_EXT_DEF_FILE = PLUGIN_EXT_DEF_MANIFEST_NAME + exts.JSON_FILE_FORMAT
module-attribute
EXTENSION_POSTFIXES = [x.POSTFIX for x in exts.ExtensionTypes.get_ext_types()]
module-attribute
Classes
PyRevitPluginAlreadyInstalledException(extpkg)
Bases: PyRevitException
Exception raised when extension is already installed.
Source code in pyrevitlib/pyrevit/extensions/extpackages.py
Attributes
msg
property
Return exception message.
extpkg = extpkg
instance-attribute
PyRevitPluginNoInstallLinkException
Bases: PyRevitException
Exception raised when extension does not have an install link.
Attributes
msg
property
Return exception message.
PyRevitPluginRemoveException
Bases: PyRevitException
Exception raised when removing an extension.
Attributes
msg
property
Return exception message.
DependencyGraph(extpkg_list)
Extension packages dependency graph.
Source code in pyrevitlib/pyrevit/extensions/extpackages.py
Attributes
dep_dict = defaultdict(list)
instance-attribute
extpkgs = extpkg_list
instance-attribute
Functions
ExtensionPackage(info_dict, def_file_path=None)
Extension package class.
This class contains the extension information and also manages installation,
user configuration, and removal of the extension.
See the __init__
class documentation for the required and
optional extension information.
Attributes:
Name | Type | Description |
---|---|---|
type |
ExtensionTypes
|
Extension type |
name |
str
|
Extension name |
description |
str
|
Extension description |
url |
str
|
Url of online git repository |
website |
str
|
Url of extension website |
image |
str
|
Url of extension icon image (.png file) |
author |
str
|
Name of extension author |
author_profile |
str
|
Url of author profile |
Initialized the extension class based on provide information.
Required info (Dictionary keys): type, name, description, url
Optional info
website, image, author, author-url, authusers
Parameters:
Name | Type | Description | Default |
---|---|---|---|
info_dict |
dict
|
A dictionary containing the required information for initializing the extension. |
required |
def_file_path |
str
|
The file path of the extension definition file |
None
|
Source code in pyrevitlib/pyrevit/extensions/extpackages.py
Attributes
type = exts.ExtensionTypes.UI_EXTENSION
instance-attribute
builtin = False
instance-attribute
default_enabled = True
instance-attribute
name = None
instance-attribute
description = None
instance-attribute
url = None
instance-attribute
def_file_path = set()
instance-attribute
authusers = set()
instance-attribute
authgroups = set()
instance-attribute
rocket_mode_compatible = False
instance-attribute
website = None
instance-attribute
image = None
instance-attribute
author = None
instance-attribute
author_profile = None
instance-attribute
dependencies = set()
instance-attribute
ext_dirname
property
Installation directory name to use.
Returns:
Type | Description |
---|---|
str
|
The name that should be used for the installation directory (based on the extension type). |
is_installed
property
Installation directory.
Returns:
Type | Description |
---|---|
str
|
Installed directory path or empty string if not installed. |
installed_dir
property
Installation directory.
Returns:
Type | Description |
---|---|
str
|
Installed directory path or empty string if not installed. |
is_removable
property
Whether the extension is safe to remove.
Checks whether it is safe to remove this extension by confirming if a git url is provided for this extension for later re-install.
Returns:
Type | Description |
---|---|
bool
|
True if removable, False if not |
version
property
Extension version.
Returns:
Type | Description |
---|---|
str
|
Last commit hash of the extension git repo. |
config
property
Returns a valid config manager for this extension.
All config parameters will be saved in user config file.
Returns:
Type | Description |
---|---|
PyRevitConfigSectionParser
|
Config section handler |
is_enabled
property
Checks the default and user configured load state of the extension.
Returns:
Type | Description |
---|---|
bool
|
True if package should be loaded |
user_has_access
property
Checks whether current user has access to this extension.
Returns:
Type | Description |
---|---|
bool
|
True is current user has access |
Functions
update_info(info_dict, def_file_path=None)
Source code in pyrevitlib/pyrevit/extensions/extpackages.py
is_valid()
remove_pkg_config()
disable_package()
Disables package in pyRevit configuration.
It won't be loaded in the next session.
toggle_package()
Disables/Enables package in pyRevit configuration.
A disabled package won't be loaded in the next session.
Source code in pyrevitlib/pyrevit/extensions/extpackages.py
Functions
get_ext_packages(authorized_only=True)
Returns the registered plugin extensions packages.
Reads the list of registered plug-in extensions and returns a list of ExtensionPackage classes which contain information on the plug-in extension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
authorized_only |
bool
|
Only return authorized extensions |
True
|
Returns:
Type | Description |
---|---|
list[ExtensionPackage]
|
list of registered plugin extensions |
Source code in pyrevitlib/pyrevit/extensions/extpackages.py
get_ext_package_by_name(extpkg_name)
get_dependency_graph()
install(extpkg, install_dir, install_dependencies=True)
Install the extension in the given parent directory.
This method uses .installed_dir property of extension object as installation directory name for this extension. This method also handles installation of extension dependencies.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extpkg |
ExtensionPackage
|
Extension package to be installed |
required |
install_dir |
str
|
Parent directory to install extension in. |
required |
install_dependencies |
bool
|
Install the dependencies as well |
True
|
Raises:
Type | Description |
---|---|
PyRevitException
|
on install error with error message |
Source code in pyrevitlib/pyrevit/extensions/extpackages.py
remove(extpkg, remove_dependencies=True)
Removes the extension.
Removes the extension from its installed directory and clears its configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extpkg |
ExtensionPackage
|
Extension package to be removed |
required |
remove_dependencies |
bool
|
Remove the dependencies as well |
True
|
Raises:
Type | Description |
---|---|
PyRevitException
|
on remove error with error message |