本文整理汇总了Python中reportlab.lib.utils.isSeqType函数的典型用法代码示例。如果您正苦于以下问题:Python isSeqType函数的具体用法?Python isSeqType怎么用?Python isSeqType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isSeqType函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _getStr
def _getStr(s):
if isSeqType(s):
return map(_getStr,s)
elif isinstance(s,(unicode,str)):
return s
else:
return str(s)
示例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)
示例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
示例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)
示例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])))
示例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
示例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
示例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
示例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())
示例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[:]
示例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")
示例12: _getLineCount
def _getLineCount(s):
T = _getLines(s)
if isSeqType(s):
return max([len(x) for x in T])
else:
return len(T)
示例13: _getLines
def _getLines(s):
if isSeqType(s):
return tuple([(x or '').split('\n') for x in s])
else:
return (s or '').split('\n')
示例14: _getStr
def _getStr(s):
if isSeqType(s):
return map(_getStr,s)
else:
return _objStr(s)
示例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)