jrnl.output   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 5

2 Functions

Rating   Name   Duplication   Size   Complexity  
A deprecated_cmd() 0 17 2
A list_journals() 0 11 3
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