def __init__(self, filename): """\ filename: a string """ self._filename = filename self._specfile = Specfile(filename)
class ChessSpecfile(object): """A thin wrapper of the ESRF's Specfile class""" def __init__(self, filename): """\ filename: a string """ self._filename = filename self._specfile = Specfile(filename) def __getitem__(self, index): try: scan = self._specfile[index] except IndexError: logger.error('index %d out of bounds', index) raise IndexError, 'index %d out of bounds'% index return ChessScandata(scan, self) def get_date(self): """return a string, the date the file was created""" return self._specfile.date() def get_epoch_offset(self): """return the epoch offset""" return self._specfile.epoch() def get_esrf_specfile(self): """return the ESRF Specfile instance, primarily for debugging""" return self._specfile def get_filename(self): """return a string, the filename""" return self._filename def get_motor_names(self): """return a list of motornames""" return self._specfile.allmotors() def get_scan(self, scan_number, scan_order=1): """return a ChessScandata instance scan_number: the number of the scan scan_order: an index indicating whether to return the first, second, etc. occurance of a scan labeled as scan_number. scan_order is necessary because it is possible to have more than one scan labeled as scan X in a single spec datafile """ try: scan = self._specfile.select('%d.%d'%(scan_number, scan_order)) except specfile.error: logger.error('scan %d:%d not found', scan_order, scan_number) raise specfile.error, 'scan %d:%d not found'% \ (scan_order, scan_number) return scan def get_scan_list(self): """return a list of scans in the spec datafile""" return self._specfile.list() def get_title(self): """return a string, the title of the spec geometry code""" return self._specfile.title() def get_user(self): """return a string, the user ID""" return self._specfile.user() def update(self): return self._specfile.update()