当前位置: 首页>>代码示例>>Python>>正文


Python utils.attr_get函数代码示例

本文整理汇总了Python中utils.attr_get函数的典型用法代码示例。如果您正苦于以下问题:Python attr_get函数的具体用法?Python attr_get怎么用?Python attr_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了attr_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, out, node, doc):
     if not node.hasAttribute('pageSize'):
         pageSize = (utils.unit_get('21cm'), utils.unit_get('29.7cm'))
     else:
         ps = map(lambda x:x.strip(), node.getAttribute('pageSize').replace(')', '').replace('(', '').split(','))
         pageSize = ( utils.unit_get(ps[0]),utils.unit_get(ps[1]) )
     cm = reportlab.lib.units.cm
     self.doc_tmpl = platypus.BaseDocTemplate(out, pagesize=pageSize, **utils.attr_get(node, ['leftMargin','rightMargin','topMargin','bottomMargin'], {'allowSplitting':'int','showBoundary':'bool','title':'str','author':'str'}))
     self.page_templates = []
     self.styles = doc.styles
     self.doc_tmpl.styles = doc.styles	# hack
     self.doc = doc
     pts = node.getElementsByTagName('pageTemplate')
     for pt in pts:
         frames = []
         for frame_el in pt.getElementsByTagName('frame'):
             frame = platypus.Frame( **(utils.attr_get(frame_el, ['x1','y1', 'width','height', 'leftPadding', 'rightPadding', 'bottomPadding', 'topPadding'], {'id':'text', 'showBoundary':'bool'})) )
             frames.append( frame )
         gr = pt.getElementsByTagName('pageGraphics')
         if len(gr):
             drw = _rml_draw(gr[0])
             self.page_templates.append( platypus.PageTemplate(frames=frames, onPage=drw.render, **utils.attr_get(pt, [], {'id':'str'}) ))
         else:
             self.page_templates.append( platypus.PageTemplate(frames=frames, **utils.attr_get(pt, [], {'id':'str'}) ))
     self.doc_tmpl.addPageTemplates(self.page_templates)
开发者ID:tieugene,项目名称:rml2pdf,代码行数:25,代码来源:trml2pdf.py

示例2: __init__

    def __init__(self, localcontext, out, node, doc, images={}, path='.', title=None):
        self.localcontext = localcontext
        self.images= images
        self.path = path
        self.title = title
        if not node.get('pageSize'):
            pageSize = (utils.unit_get('21cm'), utils.unit_get('29.7cm'))
        else:
            ps = map(lambda x:x.strip(), node.get('pageSize').replace(')', '').replace('(', '').split(','))
            pageSize = ( utils.unit_get(ps[0]),utils.unit_get(ps[1]) )

        self.doc_tmpl = TinyDocTemplate(out, pagesize=pageSize, **utils.attr_get(node, ['leftMargin','rightMargin','topMargin','bottomMargin'], {'allowSplitting':'int','showBoundary':'bool','title':'str','author':'str'}))
        self.page_templates = []
        self.styles = doc.styles
        self.doc = doc
        pts = node.findall('pageTemplate')
        for pt in pts:
            frames = []
            for frame_el in pt.findall('frame'):
                frame = platypus.Frame( **(utils.attr_get(frame_el, ['x1','y1', 'width','height', 'leftPadding', 'rightPadding', 'bottomPadding', 'topPadding'], {'id':'str', 'showBoundary':'bool'})) )
                if utils.attr_get(frame_el, ['last']):
                    frame.lastFrame = True
                frames.append( frame )
            try :
                gr = pt.findall('pageGraphics')\
                    or pt[1].findall('pageGraphics')
            except Exception: # FIXME: be even more specific, perhaps?
                gr=''
            if len(gr):
                drw = _rml_draw(self.localcontext,gr[0], self.doc, images=images, path=self.path, title=self.title)
                self.page_templates.append( platypus.PageTemplate(frames=frames, onPage=drw.render, **utils.attr_get(pt, [], {'id':'str'}) ))
            else:
                drw = _rml_draw(self.localcontext,node,self.doc,title=self.title)
                self.page_templates.append( platypus.PageTemplate(frames=frames,onPage=drw.render, **utils.attr_get(pt, [], {'id':'str'}) ))
        self.doc_tmpl.addPageTemplates(self.page_templates)
开发者ID:Buyanbat,项目名称:XacCRM,代码行数:35,代码来源:trml2pdf.py

示例3: _rect

 def _rect(self, node):
     if node.hasAttribute("round"):
         self.canvas.roundRect(
             radius=utils.unit_get(node.getAttribute("round")),
             **utils.attr_get(node, ["x", "y", "width", "height"], {"fill": "bool", "stroke": "bool"})
         )
     else:
         self.canvas.rect(**utils.attr_get(node, ["x", "y", "width", "height"], {"fill": "bool", "stroke": "bool"}))
开发者ID:jordotech,项目名称:trml2pdf,代码行数:8,代码来源:trml2pdf.py

示例4: _flowable

 def _flowable(self, node):
     # FIXME: speedup
     if node.localName=='para':
         style = self.styles.para_style_get(node)	# ERROR
         return platypus.Paragraph(self._textual(node), style, **(utils.attr_get(node, [], {'bulletText':'str'})))
     elif node.localName=='name':
         self.styles.names[ node.getAttribute('id')] = node.getAttribute('value')
         return None
     elif node.localName=='xpre':
         style = self.styles.para_style_get(node)
         return platypus.XPreformatted(self._textual(node), style, **(utils.attr_get(node, [], {'bulletText':'str','dedent':'int','frags':'int'})))
     elif node.localName=='pre':
         style = self.styles.para_style_get(node)
         return platypus.Preformatted(self._textual(node), style, **(utils.attr_get(node, [], {'bulletText':'str','dedent':'int'})))
     elif node.localName=='illustration':
         return  self._illustration(node)
     elif node.localName=='blockTable':
         return  self._table(node)
     elif node.localName=='title':
         styles = reportlab.lib.styles.getSampleStyleSheet()
         style = styles['Title']
         return platypus.Paragraph(self._textual(node), style, **(utils.attr_get(node, [], {'bulletText':'str'})))
     elif node.localName=='h1':
         styles = reportlab.lib.styles.getSampleStyleSheet()
         style = styles['Heading1']
         return platypus.Paragraph(self._textual(node), style, **(utils.attr_get(node, [], {'bulletText':'str'})))
     elif node.localName=='h2':
         styles = reportlab.lib.styles.getSampleStyleSheet()
         style = styles['Heading2']
         return platypus.Paragraph(self._textual(node), style, **(utils.attr_get(node, [], {'bulletText':'str'})))
     elif node.localName=='h3':
         styles = reportlab.lib.styles.getSampleStyleSheet()
         style = styles['Heading3']
         return platypus.Paragraph(self._textual(node), style, **(utils.attr_get(node, [], {'bulletText':'str'})))
     elif node.localName=='image':
         return platypus.Image(node.getAttribute('file'), mask=(250,255,250,255,250,255), **(utils.attr_get(node, ['width','height'])))
     elif node.localName=='spacer':
         if node.hasAttribute('width'):
             width = utils.unit_get(node.getAttribute('width'))
         else:
             width = utils.unit_get('1cm')
         length = utils.unit_get(node.getAttribute('length'))
         return platypus.Spacer(width=width, height=length)
     elif node.localName=='pageBreak':
         return platypus.PageBreak()
     elif node.localName=='condPageBreak':
         return platypus.CondPageBreak(**(utils.attr_get(node, ['height'])))
     elif node.localName=='setNextTemplate':
         return platypus.NextPageTemplate(str(node.getAttribute('name')))
     elif node.localName=='nextFrame':
         return platypus.CondPageBreak(1000)           # TODO: change the 1000 !
     elif barcode_codes and node.localName=='barCodeFlowable':
         code = barcode_codes.get(node.getAttribute('code'), Code128)
         return code(
                 self._textual(node),
                 **utils.attr_get(node, ['barWidth', 'barHeight'], {'fontName': 'str', 'humanReadable': 'bool'}))
     else:
         sys.stderr.write('Warning: flowable not yet implemented: %s !\n' % (node.localName,))
         return None
开发者ID:tieugene,项目名称:rml2pdf,代码行数:59,代码来源:trml2pdf.py

示例5: __init__

 def __init__(self, out, node, doc):
     if not node.hasAttribute("pageSize"):
         pageSize = (utils.unit_get("21cm"), utils.unit_get("29.7cm"))
     else:
         ps = map(lambda x: x.strip(), node.getAttribute("pageSize").replace(")", "").replace("(", "").split(","))
         pageSize = (utils.unit_get(ps[0]), utils.unit_get(ps[1]))
     cm = reportlab.lib.units.cm
     self.doc_tmpl = platypus.BaseDocTemplate(
         out,
         pagesize=pageSize,
         **utils.attr_get(
             node,
             ["leftMargin", "rightMargin", "topMargin", "bottomMargin"],
             {"allowSplitting": "int", "showBoundary": "bool", "title": "str", "author": "str"},
         )
     )
     self.page_templates = []
     self.styles = doc.styles
     self.doc = doc
     pts = node.getElementsByTagName("pageTemplate")
     for pt in pts:
         frames = []
         for frame_el in pt.getElementsByTagName("frame"):
             frame = platypus.Frame(
                 **(
                     utils.attr_get(
                         frame_el,
                         [
                             "x1",
                             "y1",
                             "width",
                             "height",
                             "leftPadding",
                             "rightPadding",
                             "bottomPadding",
                             "topPadding",
                         ],
                         {"id": "text", "showBoundary": "bool"},
                     )
                 )
             )
             frames.append(frame)
         gr = pt.getElementsByTagName("pageGraphics")
         if len(gr):
             drw = _rml_draw(gr[0], self.doc)
             self.page_templates.append(
                 platypus.PageTemplate(frames=frames, onPage=drw.render, **utils.attr_get(pt, [], {"id": "str"}))
             )
         else:
             self.page_templates.append(
                 platypus.PageTemplate(frames=frames, **utils.attr_get(pt, [], {"id": "str"}))
             )
     self.doc_tmpl.addPageTemplates(self.page_templates)
开发者ID:jordotech,项目名称:trml2pdf,代码行数:53,代码来源:trml2pdf.py

示例6: _ellipse

    def _ellipse(self, node):
        x1 = utils.unit_get(node.get("x"))
        x2 = utils.unit_get(node.get("width"))
        y1 = utils.unit_get(node.get("y"))
        y2 = utils.unit_get(node.get("height"))

        self.canvas.ellipse(x1, y1, x2, y2, **utils.attr_get(node, [], {"fill": "bool", "stroke": "bool"}))
开发者ID:guzzi235,项目名称:saas3,代码行数:7,代码来源:trml2pdf.py

示例7: _ellipse

    def _ellipse(self, node):
        x1 = utils.unit_get(node.get('x'))
        x2 = utils.unit_get(node.get('width'))
        y1 = utils.unit_get(node.get('y'))
        y2 = utils.unit_get(node.get('height'))

        self.canvas.ellipse(x1,y1,x2,y2, **utils.attr_get(node, [], {'fill':'bool','stroke':'bool'}))
开发者ID:AbdAllah-Ahmed,项目名称:openerp-env,代码行数:7,代码来源:trml2pdf.py

示例8: _circle

 def _circle(self, node):
     self.canvas.circle(
         x_cen=utils.unit_get(node.getAttribute("x")),
         y_cen=utils.unit_get(node.getAttribute("y")),
         r=utils.unit_get(node.getAttribute("radius")),
         **utils.attr_get(node, [], {"fill": "bool", "stroke": "bool"})
     )
开发者ID:jordotech,项目名称:trml2pdf,代码行数:7,代码来源:trml2pdf.py

示例9: _table

	def _table(self, node):
		length = 0
		colwidths = None
		rowheights = None
		data = []
		for tr in _child_get(node,'tr'):
			data2 = []
			for td in _child_get(tr, 'td'):
				flow = []
				for n in td.childNodes:
					if n.nodeType==node.ELEMENT_NODE:
						flow.append( self._flowable(n) )
				if not len(flow):
					flow = self._textual(td)
				data2.append( flow )
			if len(data2)>length:
				length=len(data2)
				for ab in data:
					while len(ab)<length:
						ab.append('')
			while len(data2)<length:
				data2.append('')
			data.append( data2 )
		if node.hasAttribute('colWidths'):
			assert length == len(node.getAttribute('colWidths').split(','))
			colwidths = [utils.unit_get(f.strip()) for f in node.getAttribute('colWidths').split(',')]
		if node.hasAttribute('rowHeights'):
			rowheights = [utils.unit_get(f.strip()) for f in node.getAttribute('rowHeights').split(',')]
		table = platypus.Table(data = data, colWidths=colwidths, rowHeights=rowheights, **(utils.attr_get(node, ['splitByRow'] ,{'repeatRows':'int','repeatCols':'int'})))
		if node.hasAttribute('style'):
			table.setStyle(self.styles.table_styles[node.getAttribute('style')])
		return table
开发者ID:GNOME,项目名称:libgda,代码行数:32,代码来源:trml2pdf.py

示例10: __init__

    def __init__(self, localcontext, out, node, doc, images=None, path='.', title=None):
        if images is None:
            images = {}
        if not localcontext:
            localcontext={'internal_header':True}
        self.localcontext = localcontext
        self.images= images
        self.path = path
        self.title = title

        pagesize_map = {'a4': A4,
                    'us_letter': letter
                    }
        pageSize = A4
        if self.localcontext.get('company'):
            pageSize = pagesize_map.get(self.localcontext.get('company').paper_format, A4)
        if node.get('pageSize'):
            ps = map(lambda x:x.strip(), node.get('pageSize').replace(')', '').replace('(', '').split(','))
            pageSize = ( utils.unit_get(ps[0]),utils.unit_get(ps[1]) )

        self.doc_tmpl = TinyDocTemplate(out, pagesize=pageSize, **utils.attr_get(node, ['leftMargin','rightMargin','topMargin','bottomMargin'], {'allowSplitting':'int','showBoundary':'bool','rotation':'int','title':'str','author':'str'}))
        self.page_templates = []
        self.styles = doc.styles
        self.doc = doc
        self.image=[]
        pts = node.findall('pageTemplate')
        for pt in pts:
            frames = []
            for frame_el in pt.findall('frame'):
                frame = platypus.Frame( **(utils.attr_get(frame_el, ['x1','y1', 'width','height', 'leftPadding', 'rightPadding', 'bottomPadding', 'topPadding'], {'id':'str', 'showBoundary':'bool'})) )
                if utils.attr_get(frame_el, ['last']):
                    frame.lastFrame = True
                frames.append( frame )
            try :
                gr = pt.findall('pageGraphics')\
                    or pt[1].findall('pageGraphics')
            except Exception: # FIXME: be even more specific, perhaps?
                gr=''
            if len(gr):
#                self.image=[ n for n in utils._child_get(gr[0], self) if n.tag=='image' or not self.localcontext]
                drw = _rml_draw(self.localcontext,gr[0], self.doc, images=images, path=self.path, title=self.title)
                self.page_templates.append( platypus.PageTemplate(frames=frames, onPage=drw.render, **utils.attr_get(pt, [], {'id':'str'}) ))
            else:
                drw = _rml_draw(self.localcontext,node,self.doc,title=self.title)
                self.page_templates.append( platypus.PageTemplate(frames=frames,onPage=drw.render, **utils.attr_get(pt, [], {'id':'str'}) ))
        self.doc_tmpl.addPageTemplates(self.page_templates)
开发者ID:AbdAllah-Ahmed,项目名称:openerp-env,代码行数:46,代码来源:trml2pdf.py

示例11: _drawString

 def _drawString(self, node):
     v = utils.attr_get(node, ['x','y'])
     text=self._textual(node, **v)
     text = utils.xml2str(text)
     try:
         self.canvas.drawString(text=text, **v)
     except TypeError as e:
         _logger.error("Bad RML: <drawString> tag requires attributes 'x' and 'y'!")
         raise e
开发者ID:hubercinux,项目名称:v7,代码行数:9,代码来源:trml2pdf.py

示例12: _place

    def _place(self, node):
        flows = _rml_flowable(self.doc, self.localcontext, images=self.images, path=self.path, title=self.title, canvas=self.canvas).render(node)
        infos = utils.attr_get(node, ['x','y','width','height'])

        infos['y']+=infos['height']
        for flow in flows:
            w,h = flow.wrap(infos['width'], infos['height'])
            if w<=infos['width'] and h<=infos['height']:
                infos['y']-=h
                flow.drawOn(self.canvas,infos['x'],infos['y'])
                infos['height']-=h
            else:
                raise ValueError("Not enough space")
开发者ID:AbdAllah-Ahmed,项目名称:openerp-env,代码行数:13,代码来源:trml2pdf.py

示例13: _place

    def _place(self, node):
        flows = _rml_flowable(self.doc).render(node)
        infos = utils.attr_get(node, ['x','y','width','height'])

        infos['y']+=infos['height']
        for flow in flows:
            w,h = flow.wrap(infos['width'], infos['height'])
            if w<=infos['width'] and h<=infos['height']:
                infos['y']-=h
                flow.drawOn(self.canvas,infos['x'],infos['y'])
                infos['height']-=h
            else:
                raise ValueError, "Not enough space"
开发者ID:FashtimeDotCom,项目名称:trml2pdf,代码行数:13,代码来源:trml2pdf.py

示例14: _place

    def _place(self, node):
        flows = _rml_flowable(self.doc).render(node)
        infos = utils.attr_get(node, ["x", "y", "width", "height"])

        infos["y"] += infos["height"]
        for flow in flows:
            w, h = flow.wrap(infos["width"], infos["height"])
            if w <= infos["width"] and h <= infos["height"]:
                infos["y"] -= h
                flow.drawOn(self.canvas, infos["x"], infos["y"])
                infos["height"] -= h
            else:
                raise ValueError, "Not enough space"
开发者ID:jordotech,项目名称:trml2pdf,代码行数:13,代码来源:trml2pdf.py

示例15: _flowable

 def _flowable(self, node, extra_style=None):
     if node.tag=='para':
         style = self.styles.para_style_get(node)
         if extra_style:
             style.__dict__.update(extra_style)
         result = []
         for i in self._textual(node).split('\n'):
             result.append(platypus.Paragraph(i, style, **(utils.attr_get(node, [], {'bulletText':'str'}))))
         return result
     elif node.tag=='barCode':
         try:
             from reportlab.graphics.barcode import code128
             from reportlab.graphics.barcode import code39
             from reportlab.graphics.barcode import code93
             from reportlab.graphics.barcode import common
             from reportlab.graphics.barcode import fourstate
             from reportlab.graphics.barcode import usps
         except Exception, e:
             return None
         args = utils.attr_get(node, [], {'ratio':'float','xdim':'unit','height':'unit','checksum':'int','quiet':'int','width':'unit','stop':'bool','bearers':'int','barWidth':'float','barHeight':'float'})
         codes = {
             'codabar': lambda x: common.Codabar(x, **args),
             'code11': lambda x: common.Code11(x, **args),
             'code128': lambda x: code128.Code128(x, **args),
             'standard39': lambda x: code39.Standard39(x, **args),
             'standard93': lambda x: code93.Standard93(x, **args),
             'i2of5': lambda x: common.I2of5(x, **args),
             'extended39': lambda x: code39.Extended39(x, **args),
             'extended93': lambda x: code93.Extended93(x, **args),
             'msi': lambda x: common.MSI(x, **args),
             'fim': lambda x: usps.FIM(x, **args),
             'postnet': lambda x: usps.POSTNET(x, **args),
         }
         code = 'code128'
         if node.get('code'):
             code = node.get('code').lower()
         return codes[code](self._textual(node))
开发者ID:Buyanbat,项目名称:XacCRM,代码行数:37,代码来源:trml2pdf.py


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