本文整理汇总了Python中reportlab.lib.utils.isSeq函数的典型用法代码示例。如果您正苦于以下问题:Python isSeq函数的具体用法?Python isSeq怎么用?Python isSeq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isSeq函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, enum,*args):
if isSeq(enum):
if args!=():
raise ValueError("Either all singleton args or a single sequence argument")
self._enum = tuple(enum)+args
else:
self._enum = (enum,)+args
开发者ID:luannguyen49,项目名称:OdooPortable,代码行数:7,代码来源:validators.py
示例2: __init__
def __init__(
self,
id=None,
frames=[],
onPage=_doNothing,
onPageEnd=_doNothing,
pagesize=None,
autoNextPageTemplate=None,
cropBox=None,
artBox=None,
trimBox=None,
bleedBox=None,
):
frames = frames or []
if not isSeq(frames):
frames = [frames]
assert [x for x in frames if not isinstance(x, Frame)] == [], "frames argument error"
self.id = id
self.frames = frames
self.onPage = onPage
self.onPageEnd = onPageEnd
self.pagesize = pagesize
self.autoNextPageTemplate = autoNextPageTemplate
self.cropBox = cropBox
self.artBox = artBox
self.trimBox = trimBox
self.bleedBox = bleedBox
开发者ID:serrufSe,项目名称:reportlab,代码行数:27,代码来源:doctemplate.py
示例3: addProxyAttribute
def addProxyAttribute(src,name,validate=None,desc=None,initial=None,dst=None):
'''
Add a proxy attribute 'name' to src with targets dst
'''
#sanity
assert hasattr(src,'_attrMap'), 'src object has no _attrMap'
A, oA = _privateAttrMap(src,1)
if not isSeq(dst): dst = dst,
D = []
DV = []
for d in dst:
if isSeq(d):
d, e = d[0], d[1:]
obj, attr = _findObjectAndAttr(src,d)
if obj:
dA = getattr(obj,'_attrMap',None)
开发者ID:Aeium,项目名称:dotStudio,代码行数:16,代码来源:attrmap.py
示例4: _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 isSeq(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:CometHale,项目名称:lphw,代码行数:34,代码来源:cidfonts.py
示例5: __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 isSeq(action):
action = (action,)
self.action = tuple(action)
开发者ID:RossLote,项目名称:reportlab,代码行数:7,代码来源:doctemplate.py
示例6: addPageTemplates
def addPageTemplates(self,pageTemplates):
'add one or a sequence of pageTemplates'
if not isSeq(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:RossLote,项目名称:reportlab,代码行数:8,代码来源:doctemplate.py
示例7: _evalMeasurement
def _evalMeasurement(n):
if isinstance(n, str):
from reportlab.platypus.paraparser import _num
n = _num(n)
if isSeq(n):
n = n[1]
return n
开发者ID:serrufSe,项目名称:reportlab,代码行数:8,代码来源:doctemplate.py
示例8: _samePT
def _samePT(self,npt):
if isSeq(npt):
return getattr(self,'_nextPageTemplateCycle',[])
if isinstance(npt,strTypes):
return npt == (self.pageTemplates[self._nextPageTemplateIndex].id if hasattr(self,'_nextPageTemplateIndex') else self.pageTemplate.id)
if isinstance(npt,int) and 0<=npt<len(self.pageTemplates):
if hasattr(self,'_nextPageTemplateIndex'):
return npt==self._nextPageTemplateIndex
return npt==self.pageTemplates.find(self.pageTemplate)
开发者ID:RossLote,项目名称:reportlab,代码行数:9,代码来源:doctemplate.py
示例9: test
def test(self, x):
if not isSeq(x):
if x is None: return self._NoneOK
return False
if x==[] or x==():
return self._emptyOK
elif not self._lo<=len(x)<=self._hi: return False
for e in x:
if not self._elemTest(e): return False
return True
开发者ID:luannguyen49,项目名称:OdooPortable,代码行数:10,代码来源:validators.py
示例10: getContext
def getContext(self, tag):
"""Return main context for tag
>>> g = Cleaner()
>>> eqCheck(g.getContext('i'),'inline')
>>> eqCheck(g.getContext('li'),'list')
"""
context = self._tagDict[tag]['context']
if isSeq(context):
return context[0]
return context
开发者ID:AndyKovv,项目名称:hostel,代码行数:11,代码来源:html_cleaner.py
示例11: structToPDF
def structToPDF(structure):
"Converts deeply nested structure to PDFdoc dictionary/array objects"
if isinstance(structure,dict):
newDict = {}
for k, v in structure.items():
newDict[k] = structToPDF(v)
return pdfdoc.PDFDictionary(newDict)
elif isSeq(structure):
newList = []
for elem in structure:
newList.append(structToPDF(elem))
return pdfdoc.PDFArray(newList)
else:
return structure
开发者ID:CometHale,项目名称:lphw,代码行数:14,代码来源:cidfonts.py
示例12: __init__
def __init__(self,BASE=None,UNWANTED=[],**kw):
data = {}
if BASE:
if isinstance(BASE,AttrMap):
data = BASE
else:
if not isSeq(BASE): BASE = (BASE,)
for B in BASE:
am = getattr(B,'_attrMap',self)
if am is not self:
if am: data.update(am)
else:
raise ValueError('BASE=%s has wrong kind of value' % ascii(B))
dict.__init__(self,data)
self.remove(UNWANTED)
self.update(kw)
开发者ID:Aeium,项目名称:dotStudio,代码行数:17,代码来源:attrmap.py
示例13: _getWidths
def _getWidths(i,s, fontName, fontSize, subCols):
S = []
aS = S.append
if isSeq(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:Distrotech,项目名称:reportlab,代码行数:20,代码来源:legends.py
示例14: fp_str
def fp_str(*a):
'''convert separate arguments (or single sequence arg) into space separated numeric strings'''
if len(a)==1 and isSeq(a[0]): a = a[0]
s = []
A = s.append
for i in a:
sa =abs(i)
if sa<=1e-7: A('0')
else:
l = sa<=1 and 6 or min(max(0,(6-int(_log_10(sa)))),6)
n = _fp_fmts[l]%i
if l:
j = len(n)
while j:
j -= 1
if n[j]!='0':
if n[j]!='.': j += 1
break
n = n[:j]
A((n[0]!='0' or len(n)==1) and n or n[1:])
return ' '.join(s)
开发者ID:CometHale,项目名称:lphw,代码行数:21,代码来源:rl_accel.py
示例15: __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 isStr(base):
baseEnc = getEncoding(base)
self.baseEncodingName = baseEnc.name
self.vector = baseEnc.vector[:]
elif isSeq(base):
self.baseEncodingName = defaultEncoding
self.vector = base[:]
elif isinstance(base, Encoding):
# accept a vector
self.baseEncodingName = base.name
self.vector = base.vector[:]
开发者ID:Aeium,项目名称:dotStudio,代码行数:22,代码来源:pdfmetrics.py
示例16: handle_nextPageTemplate
def handle_nextPageTemplate(self, pt):
"""On endPage change to the page template with name or index pt"""
if isinstance(pt, strTypes):
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 isinstance(pt, int):
if hasattr(self, "_nextPageTemplateCycle"):
del self._nextPageTemplateCycle
self._nextPageTemplateIndex = pt
elif isSeq(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
else:
raise TypeError("argument pt should be string or integer or list")
开发者ID:serrufSe,项目名称:reportlab,代码行数:38,代码来源:doctemplate.py
示例17: _setupGrammar
def _setupGrammar(self):
self.DEFAULT_BLOCK_TAG = 'p' #used to close blocks if nothing else given
def uniDict(d):
r = {}
for k in d:
r[asUnicode(k)] = d[k]
return r
def byName(listOfDicts):
out = {}
for d in listOfDicts:
d = uniDict(d)
out[d['name']] = d
return out
#situations in which a tag can appear.
self._contextDict = byName([
dict(name='block', allowedIn=None), #None=top-level
dict(name='inline', allowedIn='block'),
dict(name='table', allowedIn='block'),
dict(name='list', allowedIn='block'),
dict(name='li', allowedIn='list'),
dict(name='tr', allowedIn='table'),
dict(name='td', allowedIn='tr'), #no contents for now
])
# if not self.allowTables:
# del self._contextDict['table']
for context in self._contextDict.values():
context['canContain'] = set()
allowParaAttrs = []
if self.allowStyleAttr: allowParaAttrs.append('style')
if self.allowAlignAttr: allowParaAttrs.append('align')
self._tagDict = byName([
dict(name='p',context='block', attrs=allowParaAttrs),
dict(name='h1',context='block', attrs=allowParaAttrs),
dict(name='h2',context='block', attrs=allowParaAttrs),
dict(name='h3',context='block', attrs=allowParaAttrs),
dict(name='h4',context='block', attrs=allowParaAttrs),
dict(name='h5',context='block', attrs=allowParaAttrs),
dict(name='h6',context='block', attrs=allowParaAttrs),
dict(name='strong',context=('inline', 'li', 'td'), attrs=[]),
dict(name='em',context=('inline', 'li', 'td'), attrs=[]),
dict(name='i',context=('inline', 'li', 'td'), attrs=[]),
dict(name='b',context=('inline', 'li', 'td'), attrs=[]),
dict(name='',context=('inline', 'li', 'td'), attrs=[]),
dict(name='sup',context=('inline', 'li', 'td'), attrs=[]),
dict(name='sub',context=('inline', 'li', 'td'), attrs=[]),
dict(name='br',context=('inline', 'li', 'td'), attrs=[], selfClosing=True),
dict(name='a',context=('inline', 'li', 'td'), attrs=['href']),
# force_attrs. These attributes will be added to make sure xhtml validation passes.
dict(name='img',context=('inline', 'li'), attrs=['src','width','height','alt'], force_attrs=['alt'], selfClosing=True),
dict(name='table',context='block', attrs=[]),
dict(name='tr',context='table', attrs=[]),
dict(name='td',context='tr', attrs=[]),
dict(name='th',context='tr', attrs=[]),
dict(name='ul',context='block', attrs=[]),
dict(name='ol',context='block', attrs=[]),
dict(name='li',context='list', attrs=[]),
])
# Tags to use to cover naked text up with in the given context
self._dataCover = uniDict(dict(
block=(self.DEFAULT_BLOCK_TAG,),
table=('tr', 'td'),
tr=('td',),
list=('li',),
))
# if not self.allowTables:
# del self._tagDict['table']
# del self._tagDict['tr']
# del self._tagDict['td']
if not self.allowImages:
del self._tagDict['img']
if not self.allowAtags:
del self._tagDict['a']
#work out in-place the set of tags allowed in each context.
for tagName,tag in self._tagDict.items():
if 'selfClosing' not in tag:
tag['selfClosing'] = False
contexts = tag['context']
if not isSeq(contexts):
contexts = contexts,
for ctxName in contexts:
context = self._contextDict.get(ctxName)
context['canContain'].add(tagName)
#work out certain useful attributes
#.........这里部分代码省略.........
开发者ID:AndyKovv,项目名称:hostel,代码行数:101,代码来源:html_cleaner.py
示例18: _getLineCount
def _getLineCount(s):
T = _getLines(s)
if isSeq(s):
return max([len(x) for x in T])
else:
return len(T)
开发者ID:Distrotech,项目名称:reportlab,代码行数:6,代码来源:legends.py
示例19: _getLines
def _getLines(s):
if isSeq(s):
return tuple([(x or '').split('\n') for x in s])
else:
return (s or '').split('\n')
开发者ID:Distrotech,项目名称:reportlab,代码行数:5,代码来源:legends.py
示例20: _getStr
def _getStr(s):
if isSeq(s):
return list(map(_getStr,s))
else:
return _objStr(s)
开发者ID:Distrotech,项目名称:reportlab,代码行数:5,代码来源:legends.py
注:本文中的reportlab.lib.utils.isSeq函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论