Blame view

src/utils/celme/site.py 3.79 KB
4f8cc5f0   aklotz   Package CelMe Cel...
1
import doctest
946eb652   theopuhl   Change to help im...
2
3
4
from .home import Home
from .atmosphere import Atmosphere
from .horizon import Horizon
4f8cc5f0   aklotz   Package CelMe Cel...
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106

# ========================================================
# ========================================================
# === SITE = HOME + HORIZON + ATMOSPHERE
# ========================================================
# ========================================================

class Site(Home, Horizon, Atmosphere):
    """ Class to describe an Site
    """
# ========================================================
# === attributs
# ========================================================

    #_home = Home()
    #_atmosphere = Atmosphere()
    #_horizon = Horizon()
    
# ========================================================
# === internal methods : Generals
# ========================================================

    def _init_site(self, home):
        """ Object initialization        
        """
        # --- update self.home with input parameters
        if isinstance(home, Home) == True:
            self.home(home.gps)
        else:
            self.home(home)
        # --- instanciate a new home to feed atmosphere and horizon
        home_local = Home(self.gps)
        self.horizon(home_local)
        self.atmosphere_standard(home_local)
    
# ========================================================
# === internal methods : 
# ========================================================
 
# ========================================================
# === Site methods
# ========================================================
       
# ========================================================
# === get/set methods
# ========================================================
    
# ========================================================
# === debug methods
# ========================================================
    
    def infos(self, action) -> None:
        """ To get informations about this class
        
        :param action: A command to run a debug action (see examples).
        :type action: string
        
        :Example:
            
        Site('GPS 0 E 0 0').infos("doctest")
        Site('GPS 0 E 0 0').infos("doc_methods")
        Site('GPS 0 E 0 0').infos("internal_attributes")
        Site('GPS 0 E 0 0').infos("public_methods")        
        """
        if (action == "doc_methods"):
            publics = [x for x in dir(self) if x[0]!="_"]
            for public in publics:
                varname = "{}".format(public)
                if (callable(getattr(self,varname))==True):
                    print("\n{:=^40}".format(" method "+varname+" "))
                    t = "Site('GPS 0 E 0 0')."+varname+".__doc__"
                    tt =eval(t)
                    print(tt)
        if (action == "doctest"):
            if __name__ == "__main__":
                print("\n{:~^40}".format("doctest"))
                doctest.testmod(verbose=False)
        if (action == "internal_attributes"):
            internals = [x for x in dir(self) if x[0]=="_" and x[1]!="_"]
            for internal in internals:
                varname = "{}".format(internal)
                #if (hasattr(self,varname)==True):
                if (callable(getattr(self,varname))==False):
                    print(varname + "=" + str(getattr(self,varname)))
        if (action == "public_methods"):
            publics = [x for x in dir(Site('GPS 0 E 0 0')) if x[0]!="_"]
            for public in publics:
                varname = "{}".format(public)
                if (callable(getattr(self,varname))==True):
                    print(varname)

# ========================================================
# === special methods
# ========================================================
        
    def __init__(self, home):
        """ Object initialization
        """
        self._init_site(home)
		  # super().__init__()