Passed
Push — main ( 9cce85...686e96 )
by Douglas
02:52
created

EntryUtils.adjust_filename()   C

Complexity

Conditions 9

Size

Total Lines 17
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 16
nop 4
dl 0
loc 17
rs 6.6666
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.model.utils.setup 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 str(to).startswith("*."):
23
            path = Path(default).with_suffix(str(to)[1:])
24
        elif to.is_dir() or to.suffix == "":
25
            path = to / default
26
        else:
27
            path = Path(to)
28
        if path.exists() and not replace:
0 ignored issues
show
Unused Code introduced by
Unnecessary "elif" after "raise"
Loading history...
29
            raise FileExistsError(f"File {path} already exists")
30
        elif replace:
31
            logger.info(f"Overwriting existing file {path}.")
32
        return path
33
34
    @staticmethod
35
    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...
36
        return {s.strip() for s in st.split(",")}
37
38
    @staticmethod
39
    def get_taxa(taxa: str) -> Sequence[Taxonomy]:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
40
        factory = TaxonomyFactories.from_uniprot(MANDOS_SETTINGS.taxonomy_cache_path)
41
        return [factory.load(str(taxon).strip()) for taxon in taxa.split(",")]
42
43
    @staticmethod
44
    def get_trial_statuses(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...
45
        return ClinicalTrialsGovUtils.resolve_statuses(st)
46
47
    @staticmethod
48
    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...
49
        return {s.name for s in TargetType.resolve(st)}
50
51
    @staticmethod
52
    def get_flags(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...
53
        return {s.name for s in DataValidityComment.resolve(st)}
54
55
56
__all__ = ["EntryUtils"]
57