Passed
Push — main ( cee75c...37036d )
by Douglas
02:08
created

mandos.entry.paths   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A EntryPaths.default_path_of() 0 9 2
A EntryPaths.output_path_of() 0 8 3
1
from pathlib import Path
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
from typing import Optional
3
4
from mandos import logger
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
0 ignored issues
show
introduced by
Imports from package mandos are not grouped
Loading history...
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
introduced by
Missing function or method docstring
Loading history...
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...
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