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

EntryUtils.adjust_filename()   B

Complexity

Conditions 8

Size

Total Lines 15
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 8
eloc 14
nop 4
dl 0
loc 15
rs 7.3333
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 Set, Sequence, Optional, Union
3
4
from mandos import logger
5
from mandos.model.settings import MANDOS_SETTINGS
6
from mandos.model.apis.chembl_support.chembl_activity import DataValidityComment
7
from mandos.model.apis.chembl_support.chembl_targets import TargetType
8
from mandos.model.apis.pubchem_support.pubchem_models import ClinicalTrialsGovUtils
9
from mandos.model.taxonomy import Taxonomy
10
from mandos.model.taxonomy_caches import TaxonomyFactories
11
12
13
class EntryUtils:
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
14
    """ """
15
16
    @classmethod
17
    def adjust_filename(cls, to: Optional[Path], default: Union[str, Path], replace: bool) -> 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...
18
        if to is None:
19
            path = Path(default)
20
        elif str(to).startswith("."):
21
            path = Path(default).with_suffix(str(to))
22
        elif to.is_dir() or to.suffix == "":
23
            path = to / default
24
        else:
25
            path = Path(to)
26
        if path.exists() and not replace:
0 ignored issues
show
Unused Code introduced by
Unnecessary "elif" after "raise"
Loading history...
27
            raise FileExistsError(f"File {path} already exists")
28
        elif replace:
29
            logger.info(f"Overwriting existing file {path}.")
30
        return path
31
32
    @staticmethod
33
    def split(st: str) -> Set[str]:
0 ignored issues
show
Coding Style Naming introduced by
Argument name "st" 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...
34
        return {s.strip() for s in st.split(",")}
35
36
    @staticmethod
37
    def get_taxa(taxa: str) -> Sequence[Taxonomy]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
38
        factory = TaxonomyFactories.from_uniprot(MANDOS_SETTINGS.taxonomy_cache_path)
39
        return [factory.load(str(taxon).strip()) for taxon in taxa.split(",")]
40
41
    @staticmethod
42
    def get_trial_statuses(st: str) -> Set[str]:
0 ignored issues
show
Coding Style Naming introduced by
Argument name "st" 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...
43
        return ClinicalTrialsGovUtils.resolve_statuses(st)
44
45
    @staticmethod
46
    def get_target_types(st: str) -> Set[str]:
0 ignored issues
show
Coding Style Naming introduced by
Argument name "st" 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...
47
        return {s.name for s in TargetType.resolve(st)}
48
49
    @staticmethod
50
    def get_flags(st: str) -> Set[str]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
Coding Style Naming introduced by
Argument name "st" 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...
51
        return {s.name for s in DataValidityComment.resolve(st)}
52
53
54
__all__ = ["EntryUtils"]
55