Make Textual an optional dependency.

This commit is contained in:
Dan Helfman
2026-05-20 22:17:19 -07:00
parent 9be1698762
commit 8e91af6820
5 changed files with 30 additions and 22 deletions
+25
View File
@@ -0,0 +1,25 @@
import logging
def run_browse(
diff_arguments,
global_arguments,
configs,
):
'''
Run the "browse" action for the given repository.
'''
if not configs:
return
logging.getLogger('asyncio').setLevel(logging.WARNING)
try:
import textual
except ImportError: # pragma: no cover
raise ValueError('Unable to import the Textual library for the browse action; try installing "borgmatic[browse]"')
import borgmatic.actions.browse.view
app = borgmatic.actions.browse.view.Browse_app(configs)
app.run()
-17
View File
@@ -465,20 +465,3 @@ class Rich_color_formatter(logging.Formatter):
record.prefix = f'{self.prefix}: ' if self.prefix else ''
return f'[{color}]{super().format(record)}[/{color}]'
def run_browse(
diff_arguments,
global_arguments,
configs,
):
'''
Run the "browse" action for the given repository.
'''
if not configs:
return
logging.getLogger('asyncio').setLevel(logging.WARNING)
app = Browse_app(configs)
app.run()
+2 -2
View File
@@ -12,7 +12,7 @@ import ruamel.yaml
import borgmatic.actions.borg
import borgmatic.actions.break_lock
import borgmatic.actions.browse.view
import borgmatic.actions.browse.run
import borgmatic.actions.change_passphrase
import borgmatic.actions.check
import borgmatic.actions.compact
@@ -899,7 +899,7 @@ def collect_highlander_action_summary_logs(configs, arguments, configuration_par
return
if 'browse' in arguments:
borgmatic.actions.browse.view.run_browse(
borgmatic.actions.browse.run.run_browse(
arguments['browse'],
arguments['global'],
configs,
+1 -1
View File
@@ -44,7 +44,7 @@ def ping_monitor(hook_config, config, config_filename, state, monitoring_log_lev
import apprise # noqa: PLC0415
from apprise import NotifyFormat, NotifyType # noqa: PLC0415
except ImportError: # pragma: no cover
logger.warning('Unable to import Apprise in monitoring hook')
logger.warning('Unable to import Apprise in its monitoring hook; try installing "borgmatic[Apprise]"')
return
state_to_notify_type = {
+2 -2
View File
@@ -21,7 +21,6 @@ dependencies = [
"packaging",
"requests",
"ruamel.yaml>0.15.0",
"textual",
]
[project.scripts]
@@ -31,7 +30,8 @@ validate-borgmatic-config = "borgmatic.commands.validate_config:main"
[project.optional-dependencies]
Apprise = ["apprise"]
dev = ["textual-dev"]
browse = ["textual"]
browse-dev = ["textual-dev"]
[project.urls]
Homepage = "https://torsion.org/borgmatic"