lsst.base
13.0-6-g08b5043+2
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
# Define a class to configure debugging information
26
#
27
class
Info
(object):
28
"""An object cognisant of debugging parameters appropriate for module "name"; any request for a value
29
will return False unless that value has been set, either in the module or as an attribute of this object.
30
31
E.g.
32
import lsstDebug
33
34
display = lsstDebug.Info(__name__).display
35
will set display to False, unless display has been set with
36
lsstDebug.Info(__name__).display = True
37
38
Why is this interesting? Because you can replace lsstDebug.Info with your own version, e.g.
39
40
import lsstDebug
41
42
def DebugInfo(name):
43
di = lsstDebug.getInfo(name) # N.b. lsstDebug.Info(name) would call us recursively
44
if name == "foo":
45
di.display = dict(repair=1, background=2, calibrate=3)
46
47
return di
48
49
lsstDebug.Info = DebugInfo
50
"""
51
def
__init__
(self, modname):
52
import
sys
53
self.__dict__[
"_dict"
] = sys.modules[modname].__dict__
54
self.
_modname
= modname
55
56
def
__getattr__
(self, what):
57
"""Return the value of the variable "what" in self.__modname if set, else False"""
58
return
self._dict.get(what,
False
)
59
60
def
__setattr__
(self, what, value):
61
"""Set the value of the variable "what" in self.__modname to value"""
62
self._dict[what] = value
63
64
getInfo = Info
65
66
def
getDebugFrame
(debugDisplay, name):
67
"""
68
Attempt to extract a frame for displaying a product called `name` from the `debugDisplay` variable.
69
70
Per the above, an instance of `Info` can return an arbitrary object (or nothing) as its `display`
71
attribute. It is convenient -- though not required -- that it be a dictionary mapping data products
72
to frame numbers, as shown in the `lsstDebug.Info` example. Given such a dictionary, this function
73
extracts and returns the appropriate frame number. If `debugDisplay` is not a collection, or if
74
`name` is not found within it, we return `None`.
75
76
@param[in] debugDisplay The contents of lsstDebug.Info(__name__).display.
77
@param[in] name The name of the data product to be displayed.
78
@returns A frame number
79
"""
80
if
hasattr(debugDisplay,
"__contains__"
)
and
name
in
debugDisplay:
81
return
debugDisplay[name]
82
else
:
83
return
None
lsstDebug.Info.__setattr__
def __setattr__
Definition:
lsstDebug.py:60
lsstDebug.Info
Definition:
lsstDebug.py:27
lsstDebug.Info.__getattr__
def __getattr__
Definition:
lsstDebug.py:56
lsstDebug.Info._modname
_modname
Definition:
lsstDebug.py:54
lsstDebug.Info.__init__
def __init__
Definition:
lsstDebug.py:51
lsstDebug.getDebugFrame
def getDebugFrame
Definition:
lsstDebug.py:66
Generated on Sat Oct 7 2017 00:43:40 for lsst.base by
1.8.5