/usr/lib/python2.7/dist-packages/twisted/lore/default.py is in python-twisted-lore 13.2.0-1ubuntu1.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 | # Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
Default processing factory plugin.
"""
from xml.dom import minidom as dom
from twisted.lore import tree, latex, lint, process
from twisted.web import sux
htmlDefault = {'template': 'template.tpl', 'baseurl': '%s', 'ext': '.html'}
class ProcessingFunctionFactory:
def getDoFile(self):
return tree.doFile
def generate_html(self, options, filenameGenerator=tree.getOutputFileName):
n = htmlDefault.copy()
n.update(options)
options = n
try:
fp = open(options['template'])
templ = dom.parse(fp)
except IOError, e:
raise process.NoProcessorError(e.filename+": "+e.strerror)
except sux.ParseError, e:
raise process.NoProcessorError(str(e))
df = lambda file, linkrel: self.getDoFile()(file, linkrel, options['ext'],
options['baseurl'], templ, options, filenameGenerator)
return df
latexSpitters = {None: latex.LatexSpitter,
'section': latex.SectionLatexSpitter,
'chapter': latex.ChapterLatexSpitter,
'book': latex.BookLatexSpitter,
}
def generate_latex(self, options, filenameGenerator=None):
spitter = self.latexSpitters[None]
for (key, value) in self.latexSpitters.items():
if key and options.get(key):
spitter = value
df = lambda file, linkrel: latex.convertFile(file, spitter)
return df
def getLintChecker(self):
return lint.getDefaultChecker()
def generate_lint(self, options, filenameGenerator=None):
checker = self.getLintChecker()
return lambda file, linkrel: lint.doFile(file, checker)
factory = ProcessingFunctionFactory()
|