本文整理汇总了Python中z3c.rml.attr.getManager函数的典型用法代码示例。如果您正苦于以下问题:Python getManager函数的具体用法?Python getManager怎么用?Python getManager使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getManager函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process
def process(self):
kwargs = dict(self.getAttributeValues(attrMapping=self.attrMapping))
preserve = kwargs.pop('preserveAspectRatio')
show = kwargs.pop('showBoundary')
if preserve:
imgX, imgY = kwargs['image'].getSize()
# Scale image correctly, if width and/or height were specified
if 'width' in kwargs and 'height' not in kwargs:
kwargs['height'] = imgY * kwargs['width'] / imgX
elif 'height' in kwargs and 'width' not in kwargs:
kwargs['width'] = imgX * kwargs['height'] / imgY
elif 'width' in kwargs and 'height' in kwargs:
if float(kwargs['width'])/kwargs['height'] > float(imgX)/imgY:
kwargs['width'] = imgX * kwargs['height'] / imgY
else:
kwargs['height'] = imgY * kwargs['width'] / imgX
canvas = attr.getManager(self, interfaces.ICanvasManager).canvas
getattr(canvas, self.callable)(**kwargs)
if show:
width = kwargs.get('width', kwargs['image'].getSize()[0])
height = kwargs.get('height', kwargs['image'].getSize()[1])
canvas.rect(kwargs['x'], kwargs['y'], width, height)
示例2: process
def process(self):
self.options = []
self.processSubDirectives()
kwargs = dict(self.getAttributeValues(attrMapping=self.attrMapping))
kwargs['options'] = self.options
canvas = attr.getManager(self, interfaces.ICanvasManager).canvas
getattr(reportlab.pdfbase.pdfform, self.callable)(canvas, **kwargs)
示例3: getProcessor
def getProcessor(self):
manager = attr.getManager(self, interfaces.IPostProcessorManager)
procs = dict(manager.postProcessors)
if "MERGE" not in procs:
proc = page.MergePostProcessor()
manager.postProcessors.append(("MERGE", proc))
return proc
return procs["MERGE"]
示例4: getProcessor
def getProcessor(self):
manager = attr.getManager(self, interfaces.IPostProcessorManager)
procs = dict(manager.postProcessors)
if 'MERGE' not in procs:
proc = MergePostProcessor()
manager.postProcessors.append(('MERGE', proc))
return proc
return procs['MERGE']
示例5: process
def process(self):
args = dict(self.getAttributeValues())
manager = attr.getManager(self)
index = manager.indexes[args["name"]]
args["format"] = index.formatFunc.__name__[8:]
args["offset"] = index.offset
index.setup(**args)
self.parent.flow.append(index)
示例6: getProcessor
def getProcessor(self):
manager = attr.getManager(self, interfaces.IPostProcessorManager)
procs = dict(manager.postProcessors)
if 'CONCAT' not in procs:
proc = ConcatenationPostProcessor()
manager.postProcessors.append(('CONCAT', proc))
return proc
return procs['CONCAT']
示例7: process
def process(self):
if PyPDF2 is None:
raise Exception(
'pyPdf is not installed, so this feature is not available.')
inputFile, inPage = self.getAttributeValues(valuesOnly=True)
manager = attr.getManager(self, interfaces.ICanvasManager)
outPage = manager.canvas.getPageNumber()-1
proc = self.getProcessor()
pageOperations = proc.operations.setdefault(outPage, [])
pageOperations.append((inputFile, inPage))
示例8: process
def process(self):
id = dict(self.getAttributeValues()).pop('id')
manager = attr.getManager(self)
text = manager.names[id] + (self.element.tail or u'')
# Now replace the element with the text
parent = self.element.getparent()
if parent.text is None:
parent.text = text
else:
parent.text += text
parent.remove(self.element)
示例9: process
def process(self):
kwargs = dict(self.getAttributeValues())
parent = kwargs.pop('parent', paraparser.SpanStyle('DefaultSpan'))
name = kwargs.pop('name')
style = copy.deepcopy(parent)
style.name = name[6:] if name.startswith('style.') else name
for name, value in kwargs.items():
setattr(style, name, value)
manager = attr.getManager(self)
manager.styles[style.name] = style
示例10: process
def process(self):
kwargs = dict(self.getAttributeValues())
parent = kwargs.pop(
'parent', reportlab.lib.styles.getSampleStyleSheet()['Normal'])
style = copy.deepcopy(parent)
for name, value in kwargs.items():
setattr(style, name, value)
manager = attr.getManager(self)
manager.styles[style.name] = style
示例11: process
def process(self):
kwargs = dict(self.getAttributeValues())
id = kwargs.pop('id')
for attrName in ('RGB', 'CMYK', 'value'):
color = kwargs.pop(attrName, None)
if color is not None:
# CMYK has additional attributes.
for name, value in kwargs.items():
setattr(color, name, value)
manager = attr.getManager(self)
manager.colors[id] = color
return
raise ValueError('At least one color definition must be specified.')
示例12: process
def process(self):
attrs = dict(self.getAttributeValues(attrMapping=self.attrMapping))
angle = attrs.pop('angle', 0)
x, y = attrs.pop('dx'), attrs.pop('dy')
self.drawing = shapes.Drawing(attrs.pop('dwidth'), attrs.pop('dheight'))
self.context = chart = self.createChart(attrs)
self.processSubDirectives()
group = shapes.Group(chart)
group.translate(0,0)
group.rotate(angle)
self.drawing.add(group)
manager = attr.getManager(self, interfaces.ICanvasManager)
self.drawing.drawOn(manager.canvas, x, y)
示例13: getAttributeValues
def getAttributeValues(self, ignore=None, select=None, attrMapping=None,
includeMissing=False, valuesOnly=False):
"""See interfaces.IRMLDirective"""
manager = getManager(self)
cache = '%s.%s' % (self.signature.__module__, self.signature.__name__)
if cache in manager.attributesCache:
fields = manager.attributesCache[cache]
else:
fields = []
for name, attr in zope.schema.getFieldsInOrder(self.signature):
fields.append((name, attr))
manager.attributesCache[cache] = fields
items = []
for name, attr in fields:
# Only add the attribute to the list, if it is supposed there
if ((ignore is None or name not in ignore) and
(select is None or name in select)):
# Get the value.
value = attr.bind(self).get()
# If no value was found for a required field, raise a value
# error
if attr.required and value is attr.missing_value:
raise ValueError(
'No value for required attribute "%s" '
'in directive "%s" %s.' % (
name, self.element.tag, getFileInfo(self)))
# Only add the entry if the value is not the missing value or
# missing values are requested to be included.
if value is not attr.missing_value or includeMissing:
items.append((name, value))
# Sort the items based on the section
if select is not None:
select = list(select)
items = sorted(items, key=lambda n: select.index(n[0]))
# If the attribute name does not match the internal API
# name, then convert the name to the internal one
if attrMapping:
items = [(attrMapping.get(name, name), value)
for name, value in items]
# Sometimes we only want the values without the names
if valuesOnly:
return [value for name, value in items]
return items