/
usr
/
lib64
/
python2.6
/
site-packages
/
Cheetah
/
/usr/lib64/python2.6/site-packages/Cheetah
mkdir
upload
Name
Size
Mode
Actions
Macros/
-
0755
rm
Templates/
-
0755
rm
Tests/
-
0755
rm
Tools/
-
0755
rm
Utils/
-
0755
rm
CacheRegion.py
4421
0644
edit
dl
rm
CacheRegion.pyc
6636
0644
edit
dl
rm
CacheRegion.pyo
6593
0644
edit
dl
rm
CacheStore.py
3047
0644
edit
dl
rm
CacheStore.pyc
5875
0644
edit
dl
rm
CacheStore.pyo
5875
0644
edit
dl
rm
CheetahWrapper.py
23885
0644
edit
dl
rm
CheetahWrapper.pyc
22958
0644
edit
dl
rm
CheetahWrapper.pyo
22895
0644
edit
dl
rm
Compiler.py
80284
0644
edit
dl
rm
Compiler.pyc
76754
0644
edit
dl
rm
Compiler.pyo
76680
0644
edit
dl
rm
convertTmplPathToModuleName.py
496
0644
edit
dl
rm
convertTmplPathToModuleName.pyc
706
0644
edit
dl
rm
convertTmplPathToModuleName.pyo
706
0644
edit
dl
rm
DirectiveAnalyzer.py
2445
0644
edit
dl
rm
DirectiveAnalyzer.pyc
4043
0644
edit
dl
rm
DirectiveAnalyzer.pyo
4043
0644
edit
dl
rm
Django.py
592
0644
edit
dl
rm
Django.pyc
945
0644
edit
dl
rm
Django.pyo
945
0644
edit
dl
rm
DummyTransaction.py
3277
0644
edit
dl
rm
DummyTransaction.pyc
5672
0644
edit
dl
rm
DummyTransaction.pyo
5672
0644
edit
dl
rm
ErrorCatchers.py
1755
0644
edit
dl
rm
ErrorCatchers.pyc
3610
0644
edit
dl
rm
ErrorCatchers.pyo
3610
0644
edit
dl
rm
FileUtils.py
10664
0644
edit
dl
rm
FileUtils.pyc
13455
0644
edit
dl
rm
FileUtils.pyo
13455
0644
edit
dl
rm
Filters.py
7639
0644
edit
dl
rm
Filters.pyc
8675
0644
edit
dl
rm
Filters.pyo
8675
0644
edit
dl
rm
ImportHooks.py
4476
0644
edit
dl
rm
ImportHooks.pyc
4368
0644
edit
dl
rm
ImportHooks.pyo
4368
0644
edit
dl
rm
ImportManager.py
17547
0644
edit
dl
rm
ImportManager.pyc
17284
0644
edit
dl
rm
ImportManager.pyo
17284
0644
edit
dl
rm
NameMapper.py
13093
0644
edit
dl
rm
NameMapper.pyc
14161
0644
edit
dl
rm
NameMapper.pyo
14161
0644
edit
dl
rm
Parser.py
103599
0644
edit
dl
rm
Parser.pyc
81466
0644
edit
dl
rm
Parser.pyo
81277
0644
edit
dl
rm
Servlet.py
3406
0644
edit
dl
rm
Servlet.pyc
3884
0644
edit
dl
rm
Servlet.pyo
3884
0644
edit
dl
rm
SettingsManager.py
10361
0644
edit
dl
rm
SettingsManager.pyc
11811
0644
edit
dl
rm
SettingsManager.pyo
11811
0644
edit
dl
rm
SourceReader.py
9059
0644
edit
dl
rm
SourceReader.pyc
11964
0644
edit
dl
rm
SourceReader.pyo
11964
0644
edit
dl
rm
Template.py
84747
0644
edit
dl
rm
Template.pyc
68404
0644
edit
dl
rm
Template.pyo
68320
0644
edit
dl
rm
TemplateCmdLineIface.py
3311
0644
edit
dl
rm
TemplateCmdLineIface.pyc
3986
0644
edit
dl
rm
TemplateCmdLineIface.pyo
3986
0644
edit
dl
rm
Unspecified.py
258
0644
edit
dl
rm
Unspecified.pyc
809
0644
edit
dl
rm
Unspecified.pyo
809
0644
edit
dl
rm
Version.py
1540
0644
edit
dl
rm
Version.pyc
1867
0644
edit
dl
rm
Version.pyo
1299
0644
edit
dl
rm
_namemapper.so
13576
0644
edit
dl
rm
__init__.py
582
0644
edit
dl
rm
__init__.pyc
756
0644
edit
dl
rm
__init__.pyo
756
0644
edit
dl
rm
Edit:
/usr/lib64/python2.6/site-packages/Cheetah/DirectiveAnalyzer.py
(2445B)
import os import pprint try: from functools import reduce except ImportError: # Assume we have reduce pass from Cheetah import Parser from Cheetah import Compiler from Cheetah import Template class Analyzer(Parser.Parser): def __init__(self, *args, **kwargs): self.calls = {} super(Analyzer, self).__init__(*args, **kwargs) def eatDirective(self): directive = self.matchDirective() try: self.calls[directive] += 1 except KeyError: self.calls[directive] = 1 super(Analyzer, self).eatDirective() class AnalysisCompiler(Compiler.ModuleCompiler): parserClass = Analyzer def analyze(source): klass = Template.Template.compile(source, compilerClass=AnalysisCompiler) return klass._CHEETAH_compilerInstance._parser.calls def main_file(f): fd = open(f, 'r') try: print u'>>> Analyzing %s' % f calls = analyze(fd.read()) return calls finally: fd.close() def _find_templates(directory, suffix): for root, dirs, files in os.walk(directory): for f in files: if not f.endswith(suffix): continue yield root + os.path.sep + f def _analyze_templates(iterable): for template in iterable: yield main_file(template) def main_dir(opts): results = _analyze_templates(_find_templates(opts.dir, opts.suffix)) totals = {} for series in results: if not series: continue for k, v in series.iteritems(): try: totals[k] += v except KeyError: totals[k] = v return totals def main(): from optparse import OptionParser op = OptionParser() op.add_option('-f', '--file', dest='file', default=None, help='Specify a single file to analyze') op.add_option('-d', '--dir', dest='dir', default=None, help='Specify a directory of templates to analyze') op.add_option('--suffix', default='tmpl', dest='suffix', help='Specify a custom template file suffix for the -d option (default: "tmpl")') opts, args = op.parse_args() if not opts.file and not opts.dir: op.print_help() return results = None if opts.file: results = main_file(opts.file) if opts.dir: results = main_dir(opts) pprint.pprint(results) if __name__ == '__main__': main()
Save
cmd:
run