/usr/share/pyshared/pyepl/calibration.py is in python-pyepl 1.1.0+git12-g365f8e3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 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 | # PyEPL: calibration.py
#
# Copyright (C) 2003-2005 Michael J. Kahana
# Authors: Ian Schleifer, Per Sederberg, Aaron Geller, Josh Jacobs
# URL: http://memory.psych.upenn.edu/programming/pyepl
#
# Distributed under the terms of the GNU Lesser General Public License
# (LGPL). See the license.txt that came with this file.
"""
This module provides a uniform way to calibrate devices which may
differ in performance across machines and over time.
"""
from repository import reposRoot
class Calibrator:
"""
This is a super-class for classes designed to calibrate a certain
type of device.
"""
def __init__(self, name):
"""
Initialize.
"""
self.name = name
def restoreCalibration(self):
"""
Restore correctly calibrated hardware and software settings.
"""
if self.isCalibrated():
self.restore(reposRoot["calibration"][self.name]())
def testCalibration(self):
"""
Verify that the current settings are correct.
"""
if not self.isCalibrated():
return False
return self.test(reposRoot["calibration"][self.name]())
def calibrate(self):
"""
Determine the correct calibration settings (perhaps
interactively).
"""
if not reposRoot.exists("calibration"):
reposRoot["calibration"] = Directory()
reposRoot["calibration"][self.name] = Wrap(self.cal())
def isCalibrated(self):
"""
Return True if a calibration has be stored for this device.
Otherwise return False.
"""
if not reposRoot.exists("calibration"):
reposRoot["calibration"] = Directory()
return False
return reposRoot["calibration"].exists(self.name)
# Methods to be overridden by inheritor:
def restore(self, cal):
"""
Restore calibration indicated by object cal.
"""
pass
def test(self, cal):
"""
Test calibration indicated by object cal.
"""
pass
def cal(self):
"""
Calibrate, return a picklable object that will be 'understood'
by the restore and test methods.
"""
pass
|