Passed
Push — main ( 2e1b6b...3a0c28 )
by Douglas
02:06
created

mandos.entry.api_singletons   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 70
dl 0
loc 83
rs 10
c 0
b 0
f 0
wmc 8

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Apis.set() 0 19 1
B Apis.set_default() 0 27 7
1
import decorateme
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
introduced by
Unable to import 'decorateme'
Loading history...
2
3
from mandos.model.apis.caching_pubchem_api import CachingPubchemApi
4
from mandos.model.apis.chembl_api import ChemblApi
5
from mandos.model.apis.chembl_scrape_api import (
6
    CachingChemblScrapeApi,
7
    ChemblScrapeApi,
8
    QueryingChemblScrapeApi,
9
)
10
from mandos.model.apis.g2p_api import CachingG2pApi, G2pApi
11
from mandos.model.apis.hmdb_api import CachingHmdbApi, HmdbApi, QueryingHmdbApi
12
from mandos.model.apis.pubchem_api import PubchemApi
13
from mandos.model.apis.pubchem_similarity_api import (
14
    CachingPubchemSimilarityApi,
15
    QueryingPubchemSimilarityApi,
16
)
17
from mandos.model.apis.querying_pubchem_api import QueryingPubchemApi
18
from mandos.model.apis.similarity_api import SimilarityApi
19
from mandos.model.settings import SETTINGS
20
from mandos.model.utils.setup import logger
21
22
23
@decorateme.auto_repr_str()
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
24
class Apis:
25
26
    Pubchem: PubchemApi = None
27
    Chembl: ChemblApi = None
28
    ChemblScrape: ChemblScrapeApi = None
29
    G2p: G2pApi = None
30
    Hmdb: HmdbApi = None
31
    Similarity: SimilarityApi = None
32
33
    @classmethod
34
    def set(
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
35
        cls,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
36
        *,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
37
        chembl: ChemblApi,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
38
        pubchem: PubchemApi,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
39
        g2p: G2pApi,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
40
        hmdb: HmdbApi,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
41
        chembl_scrape: ChemblScrapeApi,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
42
        similarity: SimilarityApi,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
43
    ) -> None:
44
        cls.Chembl = chembl
45
        cls.Pubchem = pubchem
46
        cls.G2p = g2p
47
        cls.Hmdb = hmdb
48
        cls.ChemblScrape = chembl_scrape
49
        cls.Similarity = similarity
50
        SETTINGS.configure()
51
        logger.debug("Set custom API singletons")
52
53
    @classmethod
54
    def set_default(
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
55
        cls,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
56
        *,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
57
        pubchem: bool = True,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
58
        chembl: bool = True,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
59
        hmdb: bool = True,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
60
        g2p: bool = True,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
61
        scrape: bool = True,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
62
        similarity: bool = True,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
63
    ) -> None:
64
        if chembl:
65
            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...
66
67
            cls.Chembl = ChemblApi.wrap(_Chembl)
68
        if pubchem:
69
            cls.Pubchem = CachingPubchemApi(QueryingPubchemApi())
70
        if hmdb:
71
            cls.Hmdb = CachingHmdbApi(QueryingHmdbApi())
72
        if g2p:
73
            cls.G2p = CachingG2pApi()
74
        if scrape:
75
            cls.ChemblScrape = CachingChemblScrapeApi(QueryingChemblScrapeApi())
76
        if similarity:
77
            cls.Similarity = CachingPubchemSimilarityApi(QueryingPubchemSimilarityApi())
78
        SETTINGS.configure()
79
        logger.debug("Set default singletons")
80
81
82
__all__ = ["Apis"]
83