• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python attr.getManager函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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)
开发者ID:fanzalika,项目名称:z3c.rml,代码行数:26,代码来源:canvas.py


示例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)
开发者ID:contracode,项目名称:z3c.rml,代码行数:7,代码来源:form.py


示例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"]
开发者ID:jacobwegner,项目名称:z3c.rml,代码行数:8,代码来源:pdfinclude.py


示例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']
开发者ID:zopefoundation,项目名称:z3c.rml,代码行数:8,代码来源:page.py


示例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)
开发者ID:nikunj1,项目名称:z3c.rml,代码行数:8,代码来源:flowable.py


示例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']
开发者ID:nikunj1,项目名称:z3c.rml,代码行数:8,代码来源:pdfinclude.py


示例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))
开发者ID:zopefoundation,项目名称:z3c.rml,代码行数:11,代码来源:page.py


示例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)
开发者ID:bisio,项目名称:z3c.rml,代码行数:11,代码来源:special.py


示例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
开发者ID:kylemacfarlane,项目名称:z3c.rml,代码行数:12,代码来源:stylesheet.py


示例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
开发者ID:sylex-team,项目名称:z3c-patched,代码行数:12,代码来源:stylesheet.py


示例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.')
开发者ID:contracode,项目名称:z3c.rml,代码行数:13,代码来源:document.py


示例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)
开发者ID:sylex-team,项目名称:z3c-patched,代码行数:13,代码来源:chart.py


示例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
开发者ID:fanzalika,项目名称:z3c.rml,代码行数:48,代码来源:directive.py



注:本文中的z3c.rml.attr.getManager函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python saconfig.named_scoped_session函数代码示例发布时间:2022-05-26
下一篇:
Python minjson.write函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap