Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _ensure_compat_errors(info, app_dir, logger):
"""Ensure that the app info has compat_errors field"""
handler = _AppHandler(app_dir, logger)
info['compat_errors'] = handler._get_extension_compat()
def uninstall_extension(name, app_dir=None, logger=None):
"""Uninstall an extension by name or path.
Returns `True` if a rebuild is recommended, `False` otherwise.
"""
logger = _ensure_logger(logger)
_node_check(logger)
handler = _AppHandler(app_dir, logger)
return handler.uninstall_extension(name)
def list_extensions(app_dir=None, logger=None):
"""List the extensions.
"""
handler = _AppHandler(app_dir, logger)
return handler.list_extensions()
def update_extension(name=None, all_=False, app_dir=None, logger=None):
"""Update an extension by name, or all extensions.
Either `name` must be given as a string, or `all_` must be `True`.
If `all_` is `True`, the value of `name` is ignored.
Returns `True` if a rebuild is recommended, `False` otherwise.
"""
logger = _ensure_logger(logger)
_node_check(logger)
handler = _AppHandler(app_dir, logger)
if all_ is True:
return handler.update_all_extensions()
return handler.update_extension(name)
def get_app_info(app_dir=None, logger=None):
"""Get a dictionary of information about the app.
"""
handler = _AppHandler(app_dir, logger)
return handler.info
def check_extension(extension, app_dir=None, installed=False, logger=None):
"""Check if a JupyterLab extension is enabled or disabled.
"""
handler = _AppHandler(app_dir, logger)
return handler.check_extension(extension, installed)
def get_app_version(app_dir=None):
"""Get the application version."""
app_dir = app_dir or get_app_dir()
handler = _AppHandler(app_dir)
return handler.info['version']
def _build_check_info(app_dir, logger):
"""Get info about packages scheduled for (un)install/update"""
handler = _AppHandler(app_dir, logger)
messages = handler.build_check(fast=True)
# Decode the messages into a dict:
status = {'install': [], 'uninstall': [], 'update': []}
for msg in messages:
for key, pattern in _message_map.items():
match = pattern.match(msg)
if match:
status[key].append(match.group('name'))
return status
"""Watch the application.
Parameters
----------
app_dir: string, optional
The application directory.
logger: :class:`~logger.Logger`, optional
The logger instance.
Returns
-------
A list of processes to run asynchronously.
"""
logger = _ensure_logger(logger)
_node_check(logger)
handler = _AppHandler(app_dir, logger)
return handler.watch()