Passed
Push — main ( cdf0f7...3de8e8 )
by Douglas
01:40
created

mandos.entries.paths.EntryPaths.default_path_of()   A

Complexity

Conditions 2

Size

Total Lines 9
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nop 3
dl 0
loc 9
rs 9.95
c 0
b 0
f 0
1
from pathlib import Path
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
from typing import Optional
3
4
from loguru import logger
0 ignored issues
show
introduced by
Unable to import 'loguru'
Loading history...
5
from pocketutils.tools.path_tools import PathTools
0 ignored issues
show
introduced by
Unable to import 'pocketutils.tools.path_tools'
Loading history...
6
7
from mandos.model.searches import Search
8
9
10
class EntryPaths:
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
11
    @classmethod
12
    def output_path_of(cls, what: Search, input_path: Path, to: Optional[Path]) -> Path:
0 ignored issues
show
Coding Style Naming introduced by
Argument name "to" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
introduced by
Missing function or method docstring
Loading history...
13
        if to is None:
0 ignored issues
show
unused-code introduced by
Unnecessary "elif" after "return"
Loading history...
14
            return cls.default_path_of(what, input_path)
15
        elif str(to).startswith("."):
16
            return cls.default_path_of(what, input_path).with_suffix(str(to))
17
        else:
18
            return to
19
20
    @classmethod
21
    def default_path_of(cls, what: Search, input_path: Path) -> Path:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
22
        parent = input_path.parent / (input_path.stem + "-output")
23
        parent.mkdir(exist_ok=True)
24
        child = what.key + ".csv"
25
        node = PathTools.sanitize_path_node(child)
26
        if (parent / node).resolve() != (parent / child).resolve():
27
            logger.debug(f"Path {child} sanitized to {node}")
28
        return parent / node
29
30
31
__all__ = ["EntryPaths"]
32