mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-19 04:28:31 +02:00
Add listing of active plugins to '--version' output
This commit is contained in:
parent
3795159767
commit
a55086191e
5 changed files with 56 additions and 8 deletions
|
@ -28,6 +28,12 @@ def preconfig_diagnostic(_):
|
||||||
def preconfig_version(_):
|
def preconfig_version(_):
|
||||||
from jrnl import __title__
|
from jrnl import __title__
|
||||||
from jrnl import __version__
|
from jrnl import __version__
|
||||||
|
from jrnl.plugins.meta import (
|
||||||
|
IMPORT_FORMATS,
|
||||||
|
EXPORT_FORMATS,
|
||||||
|
get_exporter,
|
||||||
|
get_importer,
|
||||||
|
)
|
||||||
|
|
||||||
version_str = f"""{__title__} version {__version__}
|
version_str = f"""{__title__} version {__version__}
|
||||||
|
|
||||||
|
@ -37,6 +43,22 @@ This is free software, and you are welcome to redistribute it under certain
|
||||||
conditions; for details, see: https://www.gnu.org/licenses/gpl-3.0.html"""
|
conditions; for details, see: https://www.gnu.org/licenses/gpl-3.0.html"""
|
||||||
|
|
||||||
print(version_str)
|
print(version_str)
|
||||||
|
print()
|
||||||
|
print("Active Plugins:")
|
||||||
|
print(" Importers:")
|
||||||
|
for importer in IMPORT_FORMATS:
|
||||||
|
importer_class = get_importer(importer)
|
||||||
|
print(
|
||||||
|
f" {importer} : {importer_class.version} from",
|
||||||
|
f"{importer_class().class_path()}",
|
||||||
|
)
|
||||||
|
print(" Exporters:")
|
||||||
|
for exporter in EXPORT_FORMATS:
|
||||||
|
exporter_class = get_exporter(exporter)
|
||||||
|
# print(f" {exporter} : {exporter_class.version} from {exporter_class().class_path()}")
|
||||||
|
print(f" {exporter} : ", end="")
|
||||||
|
print(f"{exporter_class.version} from ", end="")
|
||||||
|
print(f"{exporter_class().class_path()}")
|
||||||
|
|
||||||
|
|
||||||
def postconfig_list(config, **kwargs):
|
def postconfig_list(config, **kwargs):
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
|
||||||
from .text_exporter import TextExporter
|
from jrnl.plugins.exporter.text_exporter import Exporter as TextExporter
|
||||||
|
|
||||||
|
|
||||||
class DatesExporter(TextExporter):
|
class DatesExporter(TextExporter):
|
||||||
|
|
|
@ -7,6 +7,7 @@ import os
|
||||||
import re
|
import re
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
|
||||||
|
from jrnl import __version__
|
||||||
from jrnl.color import ERROR_COLOR
|
from jrnl.color import ERROR_COLOR
|
||||||
from jrnl.color import RESET_COLOR
|
from jrnl.color import RESET_COLOR
|
||||||
|
|
||||||
|
@ -16,6 +17,11 @@ class Exporter:
|
||||||
|
|
||||||
names = ["text", "txt"]
|
names = ["text", "txt"]
|
||||||
extension = "txt"
|
extension = "txt"
|
||||||
|
version = __version__
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def class_path(cls):
|
||||||
|
return cls.__module__
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def export_entry(cls, entry):
|
def export_entry(cls, entry):
|
||||||
|
|
|
@ -5,11 +5,17 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from jrnl import __version__
|
||||||
|
|
||||||
class Importer:
|
class Importer:
|
||||||
"""This plugin imports entries from other jrnl files."""
|
"""This plugin imports entries from other jrnl files."""
|
||||||
|
|
||||||
names = ["jrnl"]
|
names = ["jrnl"]
|
||||||
|
version = __version__
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def class_path(cls):
|
||||||
|
return cls.__module__
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def import_(journal, input=None):
|
def import_(journal, input=None):
|
||||||
|
|
|
@ -58,21 +58,35 @@ __exporter_types = {
|
||||||
**__exporter_types_builtin,
|
**__exporter_types_builtin,
|
||||||
**__exporter_types_contrib,
|
**__exporter_types_contrib,
|
||||||
}
|
}
|
||||||
__importer_types = {**__importer_types_builtin, **__importer_types_contrib}
|
__importer_types = {
|
||||||
|
**__importer_types_builtin,
|
||||||
|
**__importer_types_contrib,
|
||||||
|
}
|
||||||
|
|
||||||
EXPORT_FORMATS = sorted(__exporter_types.keys())
|
EXPORT_FORMATS = sorted(__exporter_types.keys())
|
||||||
IMPORT_FORMATS = sorted(__importer_types.keys())
|
IMPORT_FORMATS = sorted(__importer_types.keys())
|
||||||
|
|
||||||
|
|
||||||
def get_exporter(format):
|
def get_exporter(format):
|
||||||
for exporter in __exporters:
|
# print('get_exporter')
|
||||||
if hasattr(exporter, "names") and format in exporter.names:
|
# print(__exporter_types)
|
||||||
return exporter
|
for exporter_name, exporter_class in __exporter_types.items():
|
||||||
|
# print(exporter_class, exporter_class.Exporter.names)
|
||||||
|
if (
|
||||||
|
hasattr(exporter_class, "Exporter")
|
||||||
|
and hasattr(exporter_class.Exporter, "names")
|
||||||
|
and format in exporter_class.Exporter.names
|
||||||
|
):
|
||||||
|
return exporter_class.Exporter
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_importer(format):
|
def get_importer(format):
|
||||||
for importer in __importers:
|
for importer_name, importer_class in __importer_types.items():
|
||||||
if hasattr(importer, "names") and format in importer.names:
|
if (
|
||||||
return importer
|
hasattr(importer_class, "Importer")
|
||||||
|
and hasattr(importer_class.Importer, "names")
|
||||||
|
and format in importer_class.Importer.names
|
||||||
|
):
|
||||||
|
return importer_class.Importer
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Add table
Reference in a new issue