root/galaxy-central/eggs/Cheetah-2.2.2-py2.6-macosx-10.6-universal-ucs2.egg/Cheetah/ErrorCatchers.py

リビジョン 3, 1.7 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1# $Id: ErrorCatchers.py,v 1.7 2005/01/03 19:59:07 tavis_rudd Exp $
2"""ErrorCatcher class for Cheetah Templates
3
4Meta-Data
5================================================================================
6Author: Tavis Rudd <tavis@damnsimple.com>
7Version: $Revision: 1.7 $
8Start Date: 2001/08/01
9Last Revision Date: $Date: 2005/01/03 19:59:07 $
10"""
11__author__ = "Tavis Rudd <tavis@damnsimple.com>"
12__revision__ = "$Revision: 1.7 $"[11:-2]
13
14import time
15from Cheetah.NameMapper import NotFound
16
17class Error(Exception):
18    pass
19
20class ErrorCatcher:
21    _exceptionsToCatch = (NotFound,)
22   
23    def __init__(self, templateObj):
24        pass
25   
26    def exceptions(self):
27        return self._exceptionsToCatch
28   
29    def warn(self, exc_val, code, rawCode, lineCol):
30        return rawCode
31## make an alias
32Echo = ErrorCatcher
33
34class BigEcho(ErrorCatcher):
35    def warn(self, exc_val, code, rawCode, lineCol):
36        return "="*15 + "&lt;" + rawCode + " could not be found&gt;" + "="*15
37
38class KeyError(ErrorCatcher):
39    def warn(self, exc_val, code, rawCode, lineCol):
40        raise KeyError("no '%s' in this Template Object's Search List" % rawCode)
41
42class ListErrors(ErrorCatcher):
43    """Accumulate a list of errors."""
44    _timeFormat = "%c"
45   
46    def __init__(self, templateObj):
47        ErrorCatcher.__init__(self, templateObj)
48        self._errors = []
49
50    def warn(self, exc_val, code, rawCode, lineCol):
51        dict = locals().copy()
52        del dict['self']
53        dict['time'] = time.strftime(self._timeFormat,
54                                     time.localtime(time.time()))
55        self._errors.append(dict)
56        return rawCode
57   
58    def listErrors(self):
59        """Return the list of errors."""
60        return self._errors
61
62
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。