lsst.base
13.0-10-g692d0a9
LSST Data Management Base Package
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Friends
Macros
Pages
python
lsstDebug.py
Go to the documentation of this file.
1
from
builtins
import
object
2
#
3
# LSST Data Management System
4
# Copyright 2008, 2009, 2010 LSST Corporation.
5
#
6
# This product includes software developed by the
7
# LSST Project (http://www.lsst.org/).
8
#
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation, either version 3 of the License, or
12
# (at your option) any later version.
13
#
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU General Public License for more details.
18
#
19
# You should have received a copy of the LSST License Statement and
20
# the GNU General Public License along with this program. If not,
21
# see <http://www.lsstcorp.org/LegalNotices/>.
22
#
23
24
25
#
26
# Define a class to configure debugging information
27
#
28
class
Info
(object):
29
"""An object cognisant of debugging parameters appropriate for module "name"; any request for a value
30
will return False unless that value has been set, either in the module or as an attribute of this object.
31
32
E.g.
33
import lsstDebug
34
35
display = lsstDebug.Info(__name__).display
36
will set display to False, unless display has been set with
37
lsstDebug.Info(__name__).display = True
38
39
Why is this interesting? Because you can replace lsstDebug.Info with your own version, e.g.
40
41
import lsstDebug
42
43
def DebugInfo(name):
44
di = lsstDebug.getInfo(name) # N.b. lsstDebug.Info(name) would call us recursively
45
if name == "foo":
46
di.display = dict(repair=1, background=2, calibrate=3)
47
48
return di
49
50
lsstDebug.Info = DebugInfo
51
"""
52
def
__init__
(self, modname):
53
import
sys
54
self.__dict__[
"_dict"
] = sys.modules[modname].__dict__
55
self.
_modname
= modname
56
57
def
__getattr__
(self, what):
58
"""Return the value of the variable "what" in self.__modname if set, else False"""
59
return
self._dict.get(what,
False
)
60
61
def
__setattr__
(self, what, value):
62
"""Set the value of the variable "what" in self.__modname to value"""
63
self._dict[what] = value
64
65
66
getInfo = Info
67
68
69
def
getDebugFrame
(debugDisplay, name):
70
"""
71
Attempt to extract a frame for displaying a product called `name` from the `debugDisplay` variable.
72
73
Per the above, an instance of `Info` can return an arbitrary object (or nothing) as its `display`
74
attribute. It is convenient -- though not required -- that it be a dictionary mapping data products
75
to frame numbers, as shown in the `lsstDebug.Info` example. Given such a dictionary, this function
76
extracts and returns the appropriate frame number. If `debugDisplay` is not a collection, or if
77
`name` is not found within it, we return `None`.
78
79
@param[in] debugDisplay The contents of lsstDebug.Info(__name__).display.
80
@param[in] name The name of the data product to be displayed.
81
@returns A frame number
82
"""
83
if
hasattr(debugDisplay,
"__contains__"
)
and
name
in
debugDisplay:
84
return
debugDisplay[name]
85
else
:
86
return
None
lsstDebug.Info.__setattr__
def __setattr__
Definition:
lsstDebug.py:61
lsstDebug.Info
Definition:
lsstDebug.py:28
lsstDebug.Info.__getattr__
def __getattr__
Definition:
lsstDebug.py:57
lsstDebug.Info._modname
_modname
Definition:
lsstDebug.py:55
lsstDebug.Info.__init__
def __init__
Definition:
lsstDebug.py:52
lsstDebug.getDebugFrame
def getDebugFrame
Definition:
lsstDebug.py:69
Generated on Wed Sep 13 2017 07:57:06 for lsst.base by
1.8.5