Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_set_value(self):
a = self.A()
b = self.B(20, 30)
c = self.C()
set_value(a, ["attr", "attr1"], 8)
set_value(b, ["attr", "attr1"], 8)
set_value(c, ["attr", "attr1"], 8)
self.assertEqual(a.attr, 8)
self.assertEqual(a.attr1, 8)
self.assertEqual(b.attr, 8)
self.assertEqual(b.attr1, 8)
self.assertEqual(c.attr, 8)
self.assertEqual(c.attr1, 8)
def test_set_value(self):
a = self.A()
b = self.B(20, 30)
c = self.C()
set_value(a, ["attr", "attr1"], 8)
set_value(b, ["attr", "attr1"], 8)
set_value(c, ["attr", "attr1"], 8)
self.assertEqual(a.attr, 8)
self.assertEqual(a.attr1, 8)
self.assertEqual(b.attr, 8)
self.assertEqual(b.attr1, 8)
self.assertEqual(c.attr, 8)
self.assertEqual(c.attr1, 8)
def getParaFrag(style):
frag = ParaFrag()
set_value(frag,
('sub', 'super', 'rise', 'underline', 'strike', 'greek',
'leading', 'leadingSpace', 'spaceBefore',
'spaceAfter', 'leftIndent', 'rightIndent', 'firstLineIndent',
'borderPadding', 'paddingLeft', 'paddingRight',
'paddingTop', 'paddingBottom', 'bulletIndent',
'insideStaticFrame', 'outlineLevel'
),
0)
set_value(frag,
('backColor', 'vAlign', 'link', 'borderStyle',
'borderColor', 'listStyleType', 'listStyleImage',
'wordWrap', 'height', 'width', 'bulletText'
),
None
)
def set_borders(self, frag, attrs):
set_value(frag,
('borderLeftColor', 'borderRightColor', 'borderTopColor',
'borderBottomColor'), attrs.bordercolor)
set_value(frag,
('borderLeftWidth', 'borderRightWidth', 'borderTopWidth',
'borderBottomWidth'),
attrs.border)
set_value(frag,
('borderBottomStyle', 'borderLeftStyle', 'borderTopStyle',
'borderRightStyle'),
"solid"
)
tdata.add_style(('LEADING', begin, end, 1.0))
# Vertical align
valign = self.attr.valign or c.frag.vAlign
if valign is not None:
tdata.add_style(('VALIGN', begin, end, valign.upper()))
# Reset border, otherwise the paragraph block will have borders too
frag = c.frag
set_value(frag,
('borderLeftWidth', 'borderRightWidth',
'borderTopWidth', 'borderBottomWidth'),
0)
set_value(frag,
('borderLeftColor', 'borderLeftStyle', 'borderRightColor',
'borderRightStyle', 'borderTopColor', 'borderTopStyle',
'borderBottomColor', 'borderBottomStyle'),
None
)
def __init__(self, path, debug=0, capacity=-1):
self.fontList = copy.copy(xhtml2pdf.default.DEFAULT_FONT)
set_value(self,
('path', 'story', 'text', 'log', 'frameStaticList',
'pisaBackgroundList', 'frameList', 'anchorFrag',
'anchorName', 'fragList', 'fragAnchor', 'fragStack'
), [], _copy=True)
set_value(self, ('node', 'indexing_story',
'template', 'keepInFrameIndex',
'tableData', 'image'),
None)
set_value(self, ('err', 'warn', 'uidctr', 'listCounter'), 0)
set_value(self, ('text', 'cssText', 'cssDefaultText'), "")
set_value(self, ('templateList', 'frameStatic', 'imageData'),
{}, _copy=True)
self.capacity = capacity
self.toc = PmlTableOfContents()
self.multiBuild = False
self.pageSize = A4
self.baseFontSize = getSize("12pt")
self.frag = self.fragBlock = getParaFrag(
ParagraphStyle('default%d' % self.UID()))
self.fragStrip = True
self.force = False
# External callback function for path calculations
self.pathCallback = None
'leading', 'leadingSpace', 'spaceBefore',
'spaceAfter', 'leftIndent', 'rightIndent', 'firstLineIndent',
'borderPadding', 'paddingLeft', 'paddingRight',
'paddingTop', 'paddingBottom', 'bulletIndent',
'insideStaticFrame', 'outlineLevel'
),
0)
set_value(frag,
('backColor', 'vAlign', 'link', 'borderStyle',
'borderColor', 'listStyleType', 'listStyleImage',
'wordWrap', 'height', 'width', 'bulletText'
),
None
)
set_value(frag,
('pageNumber', 'pageCount', 'outline',
'outlineOpen', 'keepWithNext'),
False)
frag.text = ""
frag.fontName = "Times-Roman"
frag.fontName, frag.bold, frag.italic = ps2tt(style.fontName)
frag.fontSize = style.fontSize
frag.textColor = style.textColor
# Extras
frag.letterSpacing = "normal"
frag.leadingSource = "150%"
frag.alignment = TA_LEFT
frag.borderWidth = 1
def set_borders(self, frag, attrs):
set_value(frag,
('borderLeftColor', 'borderRightColor', 'borderTopColor',
'borderBottomColor'), attrs.bordercolor)
set_value(frag,
('borderLeftWidth', 'borderRightWidth', 'borderTopWidth',
'borderBottomWidth'),
attrs.border)
set_value(frag,
('borderBottomStyle', 'borderLeftStyle', 'borderTopStyle',
'borderRightStyle'),
"solid"
)