本文整理汇总了Python中reportlab.lib.utils.isSeqType函数的典型用法代码示例。如果您正苦于以下问题:Python isSeqType函数的具体用法?Python isSeqType怎么用?Python isSeqType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isSeqType函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _getStr
def _getStr(s):
if isSeqType(s):
return map(_getStr,s)
elif isinstance(s,(unicode,str)):
return s
else:
return str(s)
开发者ID:alexissmirnov,项目名称:donomo,代码行数:7,代码来源:legends.py
示例2: __init__
def __init__(self,action=()):
#must call super init to ensure it has a width and height (of zero),
#as in some cases the packer might get called on it...
Flowable.__init__(self)
if not isSeqType(action):
action = (action,)
self.action = tuple(action)
开发者ID:jeffery9,项目名称:reportlab,代码行数:7,代码来源:doctemplate.py
示例3: _expandWidths
def _expandWidths(self, compactWidthArray):
"""Expands Adobe nested list structure to get a dictionary of widths.
Here is an example of such a structure.::
(
# starting at character ID 1, next n characters have the widths given.
1, (277,305,500,668,668,906,727,305,445,445,508,668,305,379,305,539),
# all Characters from ID 17 to 26 are 668 em units wide
17, 26, 668,
27, (305, 305, 668, 668, 668, 566, 871, 727, 637, 652, 699, 574, 555,
676, 687, 242, 492, 664, 582, 789, 707, 734, 582, 734, 605, 605,
641, 668, 727, 945, 609, 609, 574, 445, 668, 445, 668, 668, 590,
555, 609, 547, 602, 574, 391, 609, 582, 234, 277, 539, 234, 895,
582, 605, 602, 602, 387, 508, 441, 582, 562, 781, 531, 570, 555,
449, 246, 449, 668),
# these must be half width katakana and the like.
231, 632, 500
)
"""
data = compactWidthArray[:]
widths = {}
while data:
start, data = data[0], data[1:]
if isSeqType(data[0]):
items, data = data[0], data[1:]
for offset in range(len(items)):
widths[start + offset] = items[offset]
else:
end, width, data = data[0], data[1], data[2:]
for idx in range(start, end+1):
widths[idx] = width
return widths
开发者ID:jeffery9,项目名称:reportlab,代码行数:34,代码来源:cidfonts.py
示例4: addPageTemplates
def addPageTemplates(self,pageTemplates):
'add one or a sequence of pageTemplates'
if not isSeqType(pageTemplates):
pageTemplates = [pageTemplates]
#this test below fails due to inconsistent imports!
#assert filter(lambda x: not isinstance(x,PageTemplate), pageTemplates)==[], "pageTemplates argument error"
for t in pageTemplates:
self.pageTemplates.append(t)
开发者ID:jeffery9,项目名称:reportlab,代码行数:8,代码来源:doctemplate.py
示例5: setDash
def setDash(self, array=[], phase=0):
"""Two notations. Pass two numbers, or an array and phase."""
if isinstance(array,(float,int)):
self.style['stroke-dasharray'] = ', '.join(map(str, ([array, phase])))
elif isSeqType(array) and len(array) > 0:
assert phase >= 0, "phase is a length in user space"
self.style['stroke-dasharray'] = ', '.join(map(str, (array+[phase])))
开发者ID:jeffery9,项目名称:reportlab,代码行数:8,代码来源:renderSVG.py
示例6: _getWidth
def _getWidth(s,fontName, fontSize, sepSpace=0):
if isSeqType(s):
sum = 0
for t in s:
m = [stringWidth(x, fontName, fontSize) for x in t.split('\n')]
sum += m and max(m) or 0
sum += (len(s)-1)*sepSpace
return sum
m = [stringWidth(x, fontName, fontSize) for x in s.split('\n')]
return m and max(m) or 0
开发者ID:alexissmirnov,项目名称:donomo,代码行数:10,代码来源:legends.py
示例7: structToPDF
def structToPDF(structure):
"Converts deeply nested structure to PDFdoc dictionary/array objects"
if type(structure) is dict:
newDict = {}
for k, v in structure.items():
newDict[k] = structToPDF(v)
return pdfdoc.PDFDictionary(newDict)
elif isSeqType(structure):
newList = []
for elem in structure:
newList.append(structToPDF(elem))
return pdfdoc.PDFArray(newList)
else:
return structure
开发者ID:jeffery9,项目名称:reportlab,代码行数:14,代码来源:cidfonts.py
示例8: _getWidths
def _getWidths(i,s, fontName, fontSize, subCols):
S = []
aS = S.append
if isSeqType(s):
for j,t in enumerate(s):
sc = subCols[j,i]
fN = getattr(sc,'fontName',fontName)
fS = getattr(sc,'fontSize',fontSize)
m = [stringWidth(x, fN, fS) for x in t.split('\n')]
m = max(sc.minWidth,m and max(m) or 0)
aS(m)
aS(sc.rpad)
del S[-1]
else:
sc = subCols[0,i]
fN = getattr(sc,'fontName',fontName)
fS = getattr(sc,'fontSize',fontSize)
m = [stringWidth(x, fN, fS) for x in s.split('\n')]
aS(max(sc.minWidth,m and max(m) or 0))
return S
开发者ID:7o9,项目名称:stdm-plugin,代码行数:20,代码来源:legends.py
示例9: start_stylesheet
def start_stylesheet(self, args):
#makes it the current style sheet.
path = self._arg('stylesheet',args,'path')
if path=='None': path = []
if not isSeqType(path): path = [path]
path.append('styles')
path.append(os.getcwd())
modulename = self._arg('stylesheet', args, 'module')
funcname = self._arg('stylesheet', args, 'function')
try:
found = imp.find_module(modulename, path)
(file, pathname, description) = found
mod = imp.load_module(modulename, file, pathname, description)
except ImportError:
#last gasp
mod = getModule(modulename)
#now get the function
func = getattr(mod, funcname)
pythonpoint.setStyles(func())
开发者ID:B-Rich,项目名称:M2M,代码行数:20,代码来源:stdparser.py
示例10: __init__
def __init__(self, name, base=None):
self.name = name
self.frozen = 0
if name in standardEncodings:
assert base is None, "Can't have a base encoding for a standard encoding"
self.baseEncodingName = name
self.vector = _fontdata.encodings[name]
elif base == None:
# assume based on the usual one
self.baseEncodingName = defaultEncoding
self.vector = _fontdata.encodings[defaultEncoding]
elif isStrType(base):
baseEnc = getEncoding(base)
self.baseEncodingName = baseEnc.name
self.vector = baseEnc.vector[:]
elif isSeqType(base):
self.baseEncodingName = defaultEncoding
self.vector = base[:]
elif isinstance(base, Encoding):
# accept a vector
self.baseEncodingName = base.name
self.vector = base.vector[:]
开发者ID:jeffery9,项目名称:reportlab,代码行数:22,代码来源:pdfmetrics.py
示例11: handle_nextPageTemplate
def handle_nextPageTemplate(self,pt):
'''On endPage change to the page template with name or index pt'''
if isStrType(pt):
if hasattr(self, '_nextPageTemplateCycle'): del self._nextPageTemplateCycle
for t in self.pageTemplates:
if t.id == pt:
self._nextPageTemplateIndex = self.pageTemplates.index(t)
return
raise ValueError("can't find template('%s')"%pt)
elif type(pt) is int:
if hasattr(self, '_nextPageTemplateCycle'): del self._nextPageTemplateCycle
self._nextPageTemplateIndex = pt
elif isSeqType(pt):
#used for alternating left/right pages
#collect the refs to the template objects, complain if any are bad
c = PTCycle()
for ptn in pt:
found = 0
if ptn=='*': #special case name used to short circuit the iteration
c._restart = len(c)
continue
for t in self.pageTemplates:
if t.id == ptn:
c.append(t)
found = 1
if not found:
raise ValueError("Cannot find page template called %s" % ptn)
if not c:
raise ValueError("No valid page templates in cycle")
elif c._restart>len(c):
raise ValueError("Invalid cycle restart position")
#ensure we start on the first one
self._nextPageTemplateCycle = c.cyclicIterator()
else:
raise TypeError("argument pt should be string or integer or list")
开发者ID:jeffery9,项目名称:reportlab,代码行数:36,代码来源:doctemplate.py
示例12: _getLineCount
def _getLineCount(s):
T = _getLines(s)
if isSeqType(s):
return max([len(x) for x in T])
else:
return len(T)
开发者ID:7o9,项目名称:stdm-plugin,代码行数:6,代码来源:legends.py
示例13: _getLines
def _getLines(s):
if isSeqType(s):
return tuple([(x or '').split('\n') for x in s])
else:
return (s or '').split('\n')
开发者ID:7o9,项目名称:stdm-plugin,代码行数:5,代码来源:legends.py
示例14: _getStr
def _getStr(s):
if isSeqType(s):
return map(_getStr,s)
else:
return _objStr(s)
开发者ID:7o9,项目名称:stdm-plugin,代码行数:5,代码来源:legends.py
示例15: draw
#.........这里部分代码省略.........
dividerOffsX = self.dividerOffsX
dividerOffsY = self.dividerOffsY
for i in xrange(n):
if autoCP:
col = autoCP
col.index = i
name = chartTexts[i]
else:
col, name = colorNamePairs[i]
if isAuto(swatchMarker):
col = swatchMarker
col.index = i
if isAuto(name):
name = getattr(swatchMarker,'chart',getattr(swatchMarker,'obj',None)).getSeriesName(i,'series %d' % i)
T = _getLines(name)
S = []
aS = S.append
j = int(i/(columnMaximum*1.0))
jOffs = maxWidth[j]
# thisy+dy/2 = y+leading/2
y = y0 = thisy+(dy-ascent)*0.5
if callout: callout(self,g,thisx,y,(col,name))
if alignment == "left":
x = thisx
xn = thisx+jOffs[-1]+dxTextSpace
elif alignment == "right":
x = thisx+dx+dxTextSpace
xn = thisx
else:
raise ValueError, "bad alignment"
if not isSeqType(name):
T = [T]
yd = y
for k,lines in enumerate(T):
y = y0
kk = k*2
x1 = x+jOffs[kk]
x2 = x+jOffs[kk+1]
sc = subCols[k,i]
anchor = sc.align
scdx = sc.dx
scdy = sc.dy
fN = getattr(sc,'fontName',fontName)
fS = getattr(sc,'fontSize',fontSize)
fC = getattr(sc,'fillColor',fillColor)
fL = getattr(sc,'leading',1.2*fontSize)
if fN==fontName:
fA = (ascent*fS)/fontSize
else:
fA = getFont(fontName).face.ascent/1000.
if fA==0: fA=0.718
fA *= fS
if anchor=='left':
anchor = 'start'
xoffs = x1
elif anchor=='right':
anchor = 'end'
xoffs = x2
elif anchor=='numeric':
xoffs = x2
else:
anchor = 'middle'
xoffs = 0.5*(x1+x2)
开发者ID:7o9,项目名称:stdm-plugin,代码行数:67,代码来源:legends.py
示例16: breakLines
def breakLines(self, width):
"""
Returns a broken line structure. There are two cases
A) For the simple case of a single formatting input fragment the output is
A fragment specifier with
- kind = 0
- fontName, fontSize, leading, textColor
- lines= A list of lines
Each line has two items:
1. unused width in points
2. a list of words
B) When there is more than one input formatting fragment the out put is
A fragment specifier with
- kind = 1
- lines = A list of fragments each having fields:
- extraspace (needed for justified)
- fontSize
- words=word list
- each word is itself a fragment with
- various settings
This structure can be used to easily draw paragraphs with the various alignments.
You can supply either a single width or a list of widths; the latter will have its
last item repeated until necessary. A 2-element list is useful when there is a
different first line indent; a longer list could be created to facilitate custom wraps
around irregular objects."""
if not isSeqType(width): maxWidths = [width]
else: maxWidths = width
lines = []
lineno = 0
maxWidth = maxWidths[lineno]
style = self.style
fFontSize = float(style.fontSize)
requiredWidth = 0
#for bullets, work out width and ensure we wrap the right amount onto line one
_handleBulletWidth(self.bulletText,style,maxWidths)
self.height = 0
autoLeading = getattr(self,'autoLeading',getattr(style,'autoLeading',''))
calcBounds = autoLeading not in ('','off')
frags = self.frags
nFrags= len(frags)
if nFrags==1:
f = frags[0]
if hasattr(f,'text'):
fontSize = f.fontSize
fontName = f.fontName
ascent, descent = getAscentDescent(fontName,fontSize)
kind = 0
L=f.text.split('\n')
for l in L:
currentWidth = stringWidth(l,fontName,fontSize)
requiredWidth = max(currentWidth,requiredWidth)
extraSpace = maxWidth-currentWidth
lines.append((extraSpace,l.split(' '),currentWidth))
lineno = lineno+1
maxWidth = lineno<len(maxWidths) and maxWidths[lineno] or maxWidths[-1]
blPara = f.clone(kind=kind, lines=lines,ascent=ascent,descent=descent,fontSize=fontSize)
else:
kind = f.kind
lines = f.lines
for L in lines:
if kind==0:
currentWidth = L[2]
else:
currentWidth = L.currentWidth
requiredWidth = max(currentWidth,requiredWidth)
blPara = f.clone(kind=kind, lines=lines)
self.width = max(self.width,requiredWidth)
return blPara
elif nFrags<=0:
return ParaLines(kind=0, fontSize=style.fontSize, fontName=style.fontName,
textColor=style.textColor, ascent=style.fontSize,descent=-0.2*style.fontSize,
lines=[])
else:
for L in _getFragLines(frags):
currentWidth, n, w = _getFragWord(L,maxWidth)
f = w[0][0]
maxSize = f.fontSize
maxAscent, minDescent = getAscentDescent(f.fontName,maxSize)
words = [f.clone()]
words[-1].text = w[0][1]
for i in w[1:]:
f = i[0].clone()
f.text=i[1]
words.append(f)
fontSize = f.fontSize
fontName = f.fontName
if calcBounds:
cbDefn = getattr(f,'cbDefn',None)
if getattr(cbDefn,'width',0):
descent,ascent = imgVRange(imgNormV(cbDefn.height,fontSize),cbDefn.valign,fontSize)
#.........这里部分代码省略.........
开发者ID:jeffery9,项目名称:reportlab,代码行数:101,代码来源:xpreformatted.py
示例17: draw
#.........这里部分代码省略.........
ascent *= fontSize # normalize
lim = columnMaximum - 1
callout = getattr(self,'callout',None)
dividerLines = self.dividerLines
if dividerLines:
dividerWidth = self.dividerWidth
dividerColor = self.dividerColor
dividerDashArray = self.dividerDashArray
dividerOffsX = self.dividerOffsX
dividerOffsY = self.dividerOffsY
for i in xrange(n):
if autoCP:
col = autoCP
col.index = i
name = chartTexts[i]
else:
col, name = colorNamePairs[i]
if isAuto(swatchMarker):
col = swatchMarker
col.index = i
if isAuto(name):
name = getattr(swatchMarker,'chart',getattr(swatchMarker,'obj',None)).getSeriesName(i,'series %d' % i)
T = _getLines(name)
S = []
j = int(i/columnMaximum)
# thisy+dy/2 = y+leading/2
y = y0 = thisy+(dy-ascent)*0.5
if callout: callout(self,g,thisx,y,(col,name))
if alignment == "left":
if isSeqType(name):
for t in T[0]:
S.append(String(thisx,y,t,fontName=fontName,fontSize=fontSize,fillColor=fillColor,
textAnchor = "start"))
y -= leading
yd = y
y = y0
for t in T[1]:
S.append(String(thisx+maxWidth[j],y,t,fontName=fontName,fontSize=fontSize,fillColor=fillColor,
textAnchor = "end"))
y -= leading
y = min(yd,y)
else:
for t in T:
# align text to left
S.append(String(thisx+maxWidth[j],y,t,fontName=fontName,fontSize=fontSize,fillColor=fillColor,
textAnchor = "end"))
y -= leading
x = thisx+maxWidth[j]+dxTextSpace
elif alignment == "right":
if isSeqType(name):
y0 = y
for t in T[0]:
S.append(String(thisx+dx+dxTextSpace,y,t,fontName=fontName,fontSize=fontSize,fillColor=fillColor,
textAnchor = "start"))
y -= leading
yd = y
y = y0
for t in T[1]:
S.append(String(thisx+dx+dxTextSpace+maxWidth[j],y,t,fontName=fontName,fontSize=fontSize,fillColor=fillColor,
textAnchor = "end"))
y -= leading
y = min(yd,y)
开发者ID:alexissmirnov,项目名称:donomo,代码行数:67,代码来源:legends.py
注:本文中的reportlab.lib.utils.isSeqType函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论