mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-18 12:08:31 +02:00
Don't display full plugin module paths for built in and "regular" contributed plugins
This commit is contained in:
parent
fe32e0bc07
commit
2f51e4b2cd
1 changed files with 41 additions and 4 deletions
|
@ -13,14 +13,25 @@ avoid any possible overhead for these standalone commands.
|
||||||
"""
|
"""
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
import platform
|
import platform
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def remove_prefix(main_string, prefix):
|
||||||
|
# replace with built-in string function in Python 3.9+
|
||||||
|
pattern = rf"^{prefix}"
|
||||||
|
return re.sub(pattern, "", main_string)
|
||||||
|
|
||||||
|
|
||||||
def preconfig_diagnostic(_):
|
def preconfig_diagnostic(_):
|
||||||
from jrnl import __version__
|
from jrnl import __version__
|
||||||
from jrnl.plugins.collector import (
|
from jrnl.plugins.collector import (
|
||||||
IMPORT_FORMATS,
|
IMPORT_FORMATS,
|
||||||
EXPORT_FORMATS,
|
EXPORT_FORMATS,
|
||||||
|
INTERNAL_EXPORTER_CLASS_PATH,
|
||||||
|
INTERNAL_IMPORTER_CLASS_PATH,
|
||||||
|
EXTERNAL_EXPORTER_CLASS_PATH,
|
||||||
|
EXTERNAL_IMPORTER_CLASS_PATH,
|
||||||
get_exporter,
|
get_exporter,
|
||||||
get_importer,
|
get_importer,
|
||||||
)
|
)
|
||||||
|
@ -41,14 +52,40 @@ def preconfig_diagnostic(_):
|
||||||
for importer in IMPORT_FORMATS:
|
for importer in IMPORT_FORMATS:
|
||||||
importer_class = get_importer(importer)
|
importer_class = get_importer(importer)
|
||||||
print(f" {importer:{plugin_name_length}} : ", end="")
|
print(f" {importer:{plugin_name_length}} : ", end="")
|
||||||
print(f"{importer_class.version} from ", end="")
|
if importer_class().class_path().startswith(INTERNAL_IMPORTER_CLASS_PATH):
|
||||||
print(f"{importer_class().class_path()}")
|
version_str = remove_prefix(
|
||||||
|
importer_class().class_path(), INTERNAL_IMPORTER_CLASS_PATH
|
||||||
|
)
|
||||||
|
version_str = remove_prefix(version_str, ".")
|
||||||
|
print(f"{version_str} (internal)")
|
||||||
|
elif importer_class().class_path().startswith(EXTERNAL_IMPORTER_CLASS_PATH):
|
||||||
|
version_str = remove_prefix(
|
||||||
|
importer_class().class_path(), EXTERNAL_IMPORTER_CLASS_PATH
|
||||||
|
)
|
||||||
|
version_str = remove_prefix(version_str, ".")
|
||||||
|
print(f"{version_str} {importer_class.version}")
|
||||||
|
else:
|
||||||
|
print(f"{importer_class.version} from ", end="")
|
||||||
|
print(f"{importer_class().class_path()}")
|
||||||
print(" Exporters:")
|
print(" Exporters:")
|
||||||
for exporter in EXPORT_FORMATS:
|
for exporter in EXPORT_FORMATS:
|
||||||
exporter_class = get_exporter(exporter)
|
exporter_class = get_exporter(exporter)
|
||||||
print(f" {exporter:{plugin_name_length}} : ", end="")
|
print(f" {exporter:{plugin_name_length}} : ", end="")
|
||||||
print(f"{exporter_class.version} from ", end="")
|
if exporter_class().class_path().startswith(INTERNAL_EXPORTER_CLASS_PATH):
|
||||||
print(f"{exporter_class().class_path()}")
|
version_str = remove_prefix(
|
||||||
|
exporter_class().class_path(), INTERNAL_EXPORTER_CLASS_PATH
|
||||||
|
)
|
||||||
|
version_str = remove_prefix(version_str, ".")
|
||||||
|
print(f"{version_str} (internal)")
|
||||||
|
elif exporter_class().class_path().startswith(EXTERNAL_EXPORTER_CLASS_PATH):
|
||||||
|
version_str = remove_prefix(
|
||||||
|
exporter_class().class_path(), EXTERNAL_EXPORTER_CLASS_PATH
|
||||||
|
)
|
||||||
|
version_str = remove_prefix(version_str, ".")
|
||||||
|
print(f"{version_str} {exporter_class.version}")
|
||||||
|
else:
|
||||||
|
print(f"{exporter_class.version} from ", end="")
|
||||||
|
print(f"{exporter_class().class_path()}")
|
||||||
|
|
||||||
|
|
||||||
def preconfig_version(_):
|
def preconfig_version(_):
|
||||||
|
|
Loading…
Add table
Reference in a new issue