Passed
Push — main ( 6c03a0...9ee5db )
by Douglas
01:53
created

mandos.entry.api_singletons.Apis.describe()   A

Complexity

Conditions 2

Size

Total Lines 8
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
import inspect
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
3
import decorateme
0 ignored issues
show
introduced by
Unable to import 'decorateme'
Loading history...
4
5
from mandos.model.apis.caching_pubchem_api import CachingPubchemApi
6
from mandos.model.apis.chembl_api import ChemblApi
7
from mandos.model.apis.chembl_scrape_api import (
8
    CachingChemblScrapeApi,
9
    ChemblScrapeApi,
10
    QueryingChemblScrapeApi,
11
)
12
from mandos.model.apis.g2p_api import CachingG2pApi, G2pApi
13
from mandos.model.apis.hmdb_api import CachingHmdbApi, HmdbApi, QueryingHmdbApi
14
from mandos.model.apis.pubchem_api import PubchemApi
15
from mandos.model.apis.pubchem_similarity_api import (
16
    CachingPubchemSimilarityApi,
17
    QueryingPubchemSimilarityApi,
18
)
19
from mandos.model.apis.querying_pubchem_api import QueryingPubchemApi
20
from mandos.model.apis.similarity_api import SimilarityApi
21
from mandos.model.utils.setup import logger
22
23
24
@decorateme.auto_utils()
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
25
class Apis:
26
27
    Pubchem: PubchemApi = None
28
    Chembl: ChemblApi = None
29
    ChemblScrape: ChemblScrapeApi = None
30
    G2p: G2pApi = None
31
    Hmdb: HmdbApi = None
32
    Similarity: SimilarityApi = None
33
34
    @classmethod
35
    def set(
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
36
        cls,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
37
        *,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
38
        chembl: ChemblApi,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
39
        pubchem: PubchemApi,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
40
        g2p: G2pApi,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
41
        hmdb: HmdbApi,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
42
        chembl_scrape: ChemblScrapeApi,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
43
        similarity: SimilarityApi,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
44
    ) -> None:
45
        cls.Chembl = chembl
46
        cls.Pubchem = pubchem
47
        cls.G2p = g2p
48
        cls.Hmdb = hmdb
49
        cls.ChemblScrape = chembl_scrape
50
        cls.Similarity = similarity
51
        logger.debug("Set custom API singletons")
52
        cls.describe()
53
54
    @classmethod
55
    def set_default(
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
56
        cls,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
57
        *,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
58
        pubchem: bool = True,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
59
        chembl: bool = True,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
60
        hmdb: bool = True,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
61
        g2p: bool = True,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
62
        scrape: bool = True,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
63
        similarity: bool = True,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
64
    ) -> None:
65
        if chembl:
66
            from chembl_webresource_client.new_client import new_client as _Chembl
0 ignored issues
show
introduced by
Unable to import 'chembl_webresource_client.new_client'
Loading history...
introduced by
Import outside toplevel (chembl_webresource_client.new_client.new_client)
Loading history...
67
68
            cls.Chembl = ChemblApi.wrap(_Chembl)
69
        if pubchem:
70
            cls.Pubchem = CachingPubchemApi(QueryingPubchemApi())
71
        if hmdb:
72
            cls.Hmdb = CachingHmdbApi(QueryingHmdbApi())
73
        if g2p:
74
            cls.G2p = CachingG2pApi()
75
        if scrape:
76
            cls.ChemblScrape = CachingChemblScrapeApi(QueryingChemblScrapeApi())
77
        if similarity:
78
            cls.Similarity = CachingPubchemSimilarityApi(QueryingPubchemSimilarityApi())
79
        logger.debug("Set default singletons")
80
        cls.describe()
81
82
    @classmethod
83
    def describe(cls) -> None:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
84
        for v in [
0 ignored issues
show
Coding Style Naming introduced by
Variable name "v" 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...
85
            f"    {m} = {getattr(cls, m)}"
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
86
            for m in dir(cls)
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
87
            if m[0].isupper() and not inspect.ismethod(m)
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
88
        ]:
89
            logger.debug(v)
90
91
92
__all__ = ["Apis"]
93