Skip to content

Commit

Permalink
Some whitespace fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
regebro committed Oct 14, 2017
1 parent 8387446 commit fd0a796
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 36 deletions.
10 changes: 5 additions & 5 deletions src/z3c/rml/pagetemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import zope.pagetemplate.pagetemplatefile
except ImportError as err:
raise
# zope.pagetemplate package has not been installed
import types
zope.pagetemplate = types.ModuleType('pagetemplate')
zope.pagetemplate.pagetemplatefile = types.ModuleType('pagetemplatefile')
zope.pagetemplate.pagetemplatefile.PageTemplateFile = object
## zope.pagetemplate package has not been installed, uncomment this to mock
# import types
# zope.pagetemplate = types.ModuleType('pagetemplate')
# zope.pagetemplate.pagetemplatefile = types.ModuleType('pagetemplatefile')
# zope.pagetemplate.pagetemplatefile.PageTemplateFile = object


class RMLPageTemplateFile(zope.pagetemplate.pagetemplatefile.PageTemplateFile):
Expand Down
1 change: 0 additions & 1 deletion src/z3c/rml/rml2pdfscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,3 @@ def goSubProcess(xmlInputName, outputFileName, testing=False):
canvas = excecuteSubProcess(sys.argv[2], sys.argv[3], sys.argv[4])
else:
canvas = excecuteSubProcess(sys.argv[2], sys.argv[3])

5 changes: 3 additions & 2 deletions src/z3c/rml/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class PageGraphics(directive.RMLDirective):

def process(self):
onPage = self.parent.pt.onPage

def drawOnCanvas(canv, doc):
onPage(canv, doc)
canv.saveState()
Expand Down Expand Up @@ -173,7 +174,6 @@ class IPageTemplate(interfaces.IRMLDirectiveSignature):
required=False)



class PageTemplate(directive.RMLDirective):
signature = IPageTemplate
attrMapping = {'autoNextTemplate': 'autoNextPageTemplate'}
Expand Down Expand Up @@ -259,6 +259,7 @@ class ITemplate(interfaces.IRMLDirectiveSignature):
description=u'The author of the PDF document.',
required=False)


class Template(directive.RMLDirective):
signature = ITemplate
factories = {
Expand All @@ -270,7 +271,7 @@ def process(self):
args += self.parent.getAttributeValues(
select=('debug', 'compression', 'invariant'),
attrMapping={'debug': '_debug', 'compression': 'pageCompression'})
args += (('cropMarks', self.parent.cropMarks),)
args += (('cropMarks', self.parent.cropMarks),)

self.parent.doc = platypus.BaseDocTemplate(
self.parent.outputFile, **dict(args))
Expand Down
4 changes: 4 additions & 0 deletions src/z3c/rml/tests/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from reportlab.lib import colors
from z3c.rml import attr, interfaces, SampleStyleSheet


def myPreformatted(params):
return reportlab.platypus.Preformatted('''
Hey, this is a long text from a plugin. Hey, this is a long text from
Expand All @@ -34,6 +35,7 @@ def myPreformatted(params):
is a long text from a plugin.''',
SampleStyleSheet['Normal'])


class LinkURL(reportlab.platypus.flowables.Flowable):
def __init__(self, link):
self.link = link
Expand All @@ -52,6 +54,7 @@ def linkURL(params):
params[0], SampleStyleSheet['Normal']),
LinkURL(*params))


class IMarker(interfaces.IRMLDirectiveSignature):
x = attr.Measurement()
y = attr.Measurement()
Expand All @@ -64,6 +67,7 @@ class IMarker(interfaces.IRMLDirectiveSignature):
arrowBarDx = attr.Measurement(required=False)
arrowHeight = attr.Measurement(required=False)


def symbols(canvas, params):
args = eval('dict(%s)' %params)
name = args.pop('name')
Expand Down
3 changes: 2 additions & 1 deletion src/z3c/rml/tests/test_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
</document>
'''


def test_abort_on_invalid_tag():
"""
Expand All @@ -46,7 +47,7 @@ def test_abort_on_invalid_tag():
"""


def test_suite():
return doctest.DocTestSuite(
optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS)

3 changes: 2 additions & 1 deletion src/z3c/rml/tests/test_dtd.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import unittest
from z3c.rml import dtd


class DTDTestCase(unittest.TestCase):

level = 2
Expand All @@ -28,4 +29,4 @@ def runTest(self):


def test_suite():
return unittest.TestSuite([DTDTestCase()])
return unittest.TestSuite([DTDTestCase()])
1 change: 0 additions & 1 deletion src/z3c/rml/tests/test_pagetemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ def test_suite():
return doctest.DocFileSuite(
'../pagetemplate.txt',
optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS)

3 changes: 2 additions & 1 deletion src/z3c/rml/tests/test_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import unittest
from z3c.rml import reference


class ReferenceTestCase(unittest.TestCase):

level = 3
Expand All @@ -28,4 +29,4 @@ def runTest(self):


def test_suite():
return unittest.TestSuite([ReferenceTestCase()])
return unittest.TestSuite([ReferenceTestCase()])
1 change: 1 addition & 0 deletions src/z3c/rml/tests/test_rml.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

LOG_FILE = os.path.join(os.path.dirname(__file__), 'render.log')


def gs_command(path):
return ('gs', '-q', '-sNOPAUSE', '-sDEVICE=png256',
'-sOutputFile=%s[Page-%%d].png' % path[:-4],
Expand Down
48 changes: 24 additions & 24 deletions src/z3c/rml/tests/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,30 @@ def runTest(self):


def test_suite():
suite = unittest.TestSuite()
return suite
inputDir = os.path.join(os.path.dirname(z3c.rml.tests.__file__), 'input')
outputDir = os.path.join(os.path.dirname(z3c.rml.tests.__file__), 'output')
expectDir = os.path.join(os.path.dirname(z3c.rml.tests.__file__), 'expected')
for filename in os.listdir(inputDir):
if not filename.endswith(".rml"):
continue
inPath = os.path.join(inputDir, filename)
outPath = os.path.join(outputDir, filename[:-4] + '.pdf')
expectPath = os.path.join(expectDir, filename[:-4] + '.pdf')

# ** Test RML to PDF rendering **
# Create new type, so that we can get test matching
TestCase = type(filename[:-4], (RMLRenderingTestCase,), {})
case = TestCase(inPath, outPath)
suite.addTest(case)

# ** Test PDF rendering correctness **
TestCase = type('compare-'+filename[:-4], (ComparePDFTestCase,), {})
case = TestCase(expectPath, outPath)
suite.addTest(case)

return suite
suite = unittest.TestSuite()
if False:
inputDir = os.path.join(os.path.dirname(z3c.rml.tests.__file__), 'input')
outputDir = os.path.join(os.path.dirname(z3c.rml.tests.__file__), 'output')
expectDir = os.path.join(os.path.dirname(z3c.rml.tests.__file__), 'expected')
for filename in os.listdir(inputDir):
if not filename.endswith(".rml"):
continue
inPath = os.path.join(inputDir, filename)
outPath = os.path.join(outputDir, filename[:-4] + '.pdf')
expectPath = os.path.join(expectDir, filename[:-4] + '.pdf')

# ** Test RML to PDF rendering **
# Create new type, so that we can get test matching
TestCase = type(filename[:-4], (RMLRenderingTestCase,), {})
case = TestCase(inPath, outPath)
suite.addTest(case)

# ** Test PDF rendering correctness **
TestCase = type('compare-'+filename[:-4], (ComparePDFTestCase,), {})
case = TestCase(expectPath, outPath)
suite.addTest(case)

return suite

if __name__ == '__main__':
unittest.main(defaultTest='test_suite')

0 comments on commit fd0a796

Please sign in to comment.