Total Complexity | 5 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import logging |
||
2 | |||
3 | |||
4 | def deprecated_cmd(old_cmd, new_cmd, callback=None, **kwargs): |
||
5 | import sys |
||
6 | import textwrap |
||
7 | |||
8 | from .color import RESET_COLOR |
||
9 | from .color import WARNING_COLOR |
||
10 | |||
11 | warning_msg = f""" |
||
12 | The command {old_cmd} is deprecated and will be removed from jrnl soon. |
||
13 | Please use {new_cmd} instead. |
||
14 | """ |
||
15 | warning_msg = textwrap.dedent(warning_msg) |
||
16 | logging.warning(warning_msg) |
||
17 | print(f"{WARNING_COLOR}{warning_msg}{RESET_COLOR}", file=sys.stderr) |
||
18 | |||
19 | if callback is not None: |
||
20 | callback(**kwargs) |
||
21 | |||
22 | |||
23 | def list_journals(config): |
||
24 | from . import install |
||
25 | |||
26 | """List the journals specified in the configuration file""" |
||
27 | result = f"Journals defined in {install.CONFIG_FILE_PATH}\n" |
||
28 | ml = min(max(len(k) for k in config["journals"]), 20) |
||
29 | for journal, cfg in config["journals"].items(): |
||
30 | result += " * {:{}} -> {}\n".format( |
||
31 | journal, ml, cfg["journal"] if isinstance(cfg, dict) else cfg |
||
32 | ) |
||
33 | return result |
||
34 |