~ubuntu-branches/ubuntu/utopic/prewikka/utopic

« back to all changes in this revision

Viewing changes to prewikka/templates/IDMEFBrowser.py

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2009-07-06 08:39:07 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090706083907-59qlpova8dvyvm8a
Tags: 0.9.16-1ubuntu1
* Merge from debian unstable, Ubuntu remaining changes:
  - Append --install-layout=deb to setup.py install arguments.
* debian/control:
  - Bump python-all-dev, python-central, debhelper build dependencies as
    per Debian Python New Policy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
 
 
4
 
 
5
 
 
6
##################################################
 
7
## DEPENDENCIES
 
8
import sys
 
9
import os
 
10
import os.path
 
11
from os.path import getmtime, exists
 
12
import time
 
13
import types
 
14
import __builtin__
 
15
from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
 
16
from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
 
17
from Cheetah.Template import Template
 
18
from Cheetah.DummyTransaction import DummyTransaction
 
19
from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
 
20
from Cheetah.CacheRegion import CacheRegion
 
21
import Cheetah.Filters as Filters
 
22
import Cheetah.ErrorCatchers as ErrorCatchers
 
23
from prewikka import IDMEFTree
 
24
 
 
25
##################################################
 
26
## MODULE CONSTANTS
 
27
try:
 
28
    True, False
 
29
except NameError:
 
30
    True, False = (1==1), (1==0)
 
31
VFFSL=valueFromFrameOrSearchList
 
32
VFSL=valueFromSearchList
 
33
VFN=valueForName
 
34
currentTime=time.time
 
35
__CHEETAH_version__ = '2.0.1'
 
36
__CHEETAH_versionTuple__ = (2, 0, 1, 'final', 0)
 
37
__CHEETAH_genTime__ = 1244809080.6162069
 
38
__CHEETAH_genTimestamp__ = 'Fri Jun 12 14:18:00 2009'
 
39
__CHEETAH_src__ = 'prewikka/templates/IDMEFBrowser.tmpl'
 
40
__CHEETAH_srcLastModified__ = 'Fri Jun 12 14:17:59 2009'
 
41
__CHEETAH_docstring__ = 'Autogenerated by CHEETAH: The Python-Powered Template Engine'
 
42
 
 
43
if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
 
44
    raise AssertionError(
 
45
      'This template was compiled with Cheetah version'
 
46
      ' %s. Templates compiled before version %s must be recompiled.'%(
 
47
         __CHEETAH_version__, RequiredCheetahVersion))
 
48
 
 
49
##################################################
 
50
## CLASSES
 
51
 
 
52
class IDMEFBrowser(Template):
 
53
 
 
54
    ##################################################
 
55
    ## CHEETAH GENERATED METHODS
 
56
 
 
57
 
 
58
    def __init__(self, *args, **KWs):
 
59
 
 
60
        Template.__init__(self, *args, **KWs)
 
61
        if not self._CHEETAH__instanceInitialized:
 
62
            cheetahKWArgs = {}
 
63
            allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
 
64
            for k,v in KWs.items():
 
65
                if k in allowedKWs: cheetahKWArgs[k] = v
 
66
            self._initCheetahInstance(**cheetahKWArgs)
 
67
        
 
68
 
 
69
    def browser(self, root, **KWS):
 
70
 
 
71
 
 
72
 
 
73
        ## CHEETAH: generated from #def browser(root) at line 3, col 1.
 
74
        trans = KWS.get("trans")
 
75
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
 
76
            trans = self.transaction # is None unless self.awake() was called
 
77
        if not trans:
 
78
            trans = DummyTransaction()
 
79
            _dummyTrans = True
 
80
        else: _dummyTrans = False
 
81
        write = trans.response().write
 
82
        SL = self._CHEETAH__searchList
 
83
        _filter = self._CHEETAH__currentFilter
 
84
        
 
85
        ########################################
 
86
        ## START - generated method body
 
87
        
 
88
        if VFFSL(SL,"root",True) is not None: # generated from line 4, col 2
 
89
            idmef = VFFSL(SL,"root",True)
 
90
        else: # generated from line 6, col 2
 
91
            idmef = VFN(VFFSL(SL,"IDMEFTree",True),"IDMEFTree",False)();
 
92
        write('''
 
93
''')
 
94
        for k in VFN(VFFSL(SL,"idmef",True),"keys",False)(): # generated from line 10, col 2
 
95
            if VFFSL(SL,"idmef",True)[VFFSL(SL,"k",True)]: # generated from line 11, col 9
 
96
                write('''                browser(''')
 
97
                _v = VFFSL(SL,"idmef",True)[VFFSL(SL,"k",True)] # '$idmef[$k]' on line 12, col 25
 
98
                if _v is not None: write(_filter(_v, rawExpr='$idmef[$k]')) # from line 12, col 25.
 
99
                write(''')
 
100
''')
 
101
            write('''
 
102
        tree["''')
 
103
            _v = VFFSL(SL,"k",True) # '$k' on line 15, col 15
 
104
            if _v is not None: write(_filter(_v, rawExpr='$k')) # from line 15, col 15.
 
105
            write('''"] = ''')
 
106
            _v = VFFSL(SL,"k",True) # '$k' on line 15, col 22
 
107
            if _v is not None: write(_filter(_v, rawExpr='$k')) # from line 15, col 22.
 
108
            write('''
 
109
''')
 
110
        write('''
 
111
 
 
112
''')
 
113
        
 
114
        ########################################
 
115
        ## END - generated method body
 
116
        
 
117
        return _dummyTrans and trans.response().getvalue() or ""
 
118
        
 
119
 
 
120
    def respond(self, trans=None):
 
121
 
 
122
 
 
123
 
 
124
        ## CHEETAH: main method generated for this template
 
125
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
 
126
            trans = self.transaction # is None unless self.awake() was called
 
127
        if not trans:
 
128
            trans = DummyTransaction()
 
129
            _dummyTrans = True
 
130
        else: _dummyTrans = False
 
131
        write = trans.response().write
 
132
        SL = self._CHEETAH__searchList
 
133
        _filter = self._CHEETAH__currentFilter
 
134
        
 
135
        ########################################
 
136
        ## START - generated method body
 
137
        
 
138
        write('''
 
139
''')
 
140
        
 
141
        ########################################
 
142
        ## END - generated method body
 
143
        
 
144
        return _dummyTrans and trans.response().getvalue() or ""
 
145
        
 
146
    ##################################################
 
147
    ## CHEETAH GENERATED ATTRIBUTES
 
148
 
 
149
 
 
150
    _CHEETAH__instanceInitialized = False
 
151
 
 
152
    _CHEETAH_version = __CHEETAH_version__
 
153
 
 
154
    _CHEETAH_versionTuple = __CHEETAH_versionTuple__
 
155
 
 
156
    _CHEETAH_genTime = __CHEETAH_genTime__
 
157
 
 
158
    _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__
 
159
 
 
160
    _CHEETAH_src = __CHEETAH_src__
 
161
 
 
162
    _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__
 
163
 
 
164
    _mainCheetahMethod_for_IDMEFBrowser= 'respond'
 
165
 
 
166
## END CLASS DEFINITION
 
167
 
 
168
if not hasattr(IDMEFBrowser, '_initCheetahAttributes'):
 
169
    templateAPIClass = getattr(IDMEFBrowser, '_CHEETAH_templateClass', Template)
 
170
    templateAPIClass._addCheetahPlumbingCodeToClass(IDMEFBrowser)
 
171
 
 
172
 
 
173
# CHEETAH was developed by Tavis Rudd and Mike Orr
 
174
# with code, advice and input from many other volunteers.
 
175
# For more information visit http://www.CheetahTemplate.org/
 
176
 
 
177
##################################################
 
178
## if run from command line:
 
179
if __name__ == '__main__':
 
180
    from Cheetah.TemplateCmdLineIface import CmdLineIface
 
181
    CmdLineIface(templateObj=IDMEFBrowser()).run()
 
182
 
 
183