本文整理汇总了Python中monte.runtime.base.throw.eject函数的典型用法代码示例。如果您正苦于以下问题:Python eject函数的具体用法?Python eject怎么用?Python eject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了eject函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _subCoerce
def _subCoerce(self, specimen, ej):
if specimen in [true, false]:
return specimen
elif specimen in [True, False]:
return bwrap(specimen)
else:
throw.eject(ej, "%r is not a boolean" % (specimen,))
开发者ID:froztbyte,项目名称:monte,代码行数:7,代码来源:data.py
示例2: _subCoerce
def _subCoerce(self, specimen, ej):
if isinstance(specimen, VarSlot) and self.valueGuard == specimen.valueGuard:
if (self.valueGuard.supersetOf(specimen.valueGuard) or
self.valueGuard == specimen.valueGuard):
return specimen
throw.eject(ej, "is not a %s" % (self,))
开发者ID:geraldstanje,项目名称:monte,代码行数:7,代码来源:bindings.py
示例3: requireDeepFrozen
def requireDeepFrozen(specimen, sofar, ej, root):
from monte.runtime.audit import auditedBy
from monte.runtime.equalizer import equalizer
from monte.runtime.ref import _isBroken, _optProblem
from monte.runtime.tables import ConstList
from monte.runtime.guards.tables import listGuard
if id(specimen) in sofar:
return
sofar.add(id(specimen))
if auditedBy(deepFrozenGuard, specimen):
return
if _isBroken(specimen):
requireDeepFrozen(_optProblem(specimen), sofar, ej, root)
if selflessGuard.passes(specimen) is true:
if transparentGuard.passes(specimen):
portrayal = specimen._uncall()
if not isinstance(portrayal, ConstList):
raise RuntimeError("%s did not uncall to a list" % (toString(specimen),))
requireDeepFrozen(portrayal.l[0], sofar, ej, root)
requireDeepFrozen(portrayal.l[1], sofar, ej, root)
for x in listGuard.coerce(portrayal.l[2], throw):
requireDeepFrozen(x, sofar, ej, root)
else:
throw("Don't know how to deal with Selfless object " + toString(specimen))
else:
if equalizer.sameYet(specimen, root) is true:
throw.eject(ej, toQuote(root) + " is not DeepFrozen")
else:
throw.eject(ej, "%s is not DeepFrozen because %s is not" % (toQuote(root), toQuote(specimen)))
开发者ID:justinnoah,项目名称:monte,代码行数:29,代码来源:base.py
示例4: _subCoerce
def _subCoerce(self, specimen, ej):
if isinstance(specimen, Integer):
return Float(specimen.n)
elif isinstance(specimen, Float):
return specimen
else:
throw.eject(ej, "%r is not a number" % (specimen,))
开发者ID:washort,项目名称:monte,代码行数:7,代码来源:data.py
示例5: listSplitter
def listSplitter(specimen, ej):
specimen = listGuard.coerce(specimen, throw)
if len(specimen.l) < cut:
throw.eject(
ej, "A %s size list doesn't match a >= %s size list pattern"
% (len(specimen), cut))
vals = list(specimen.l[:cut])
vals.append(ConstList(specimen.l[cut:]))
return ConstList(vals)
开发者ID:washort,项目名称:monte,代码行数:9,代码来源:helpers.py
示例6: coerce
def coerce(self, specimen, ejector):
from monte.runtime.audit import auditedBy
if auditedBy(self, specimen):
return specimen
c = specimen._conformTo(self)
if auditedBy(self, c):
return c
throw.eject(ejector, "%s isn't approved as a SubrangeGuard[%s]" % (
toQuote(specimen), toQuote(self.superrangeGuard)))
开发者ID:justinnoah,项目名称:monte,代码行数:9,代码来源:base.py
示例7: listSplitter
def listSplitter(specimen, ej):
specimen = typecheck(specimen, (ConstList, FlexList))
if len(specimen.l) < cut:
throw.eject(
ej, "A %s size list doesn't match a >= %s size list pattern"
% (len(specimen), cut))
vals = list(specimen.l[:cut])
vals.append(ConstList(specimen.l[cut:]))
return ConstList(vals)
开发者ID:froztbyte,项目名称:monte,代码行数:9,代码来源:helpers.py
示例8: listSplitter
def listSplitter(specimen, ej):
if not isinstance(specimen, (ConstList, FlexList)):
raise RuntimeError("%r is not a list" % (specimen,))
if len(specimen.l) < cut:
throw.eject(
ej, "A %s size list doesn't match a >= %s size list pattern"
% (len(specimen), cut))
vals = list(specimen.l[:cut])
vals.append(ConstList(specimen.l[cut:]))
return ConstList(vals)
开发者ID:songaal,项目名称:monte,代码行数:10,代码来源:helpers.py
示例9: _subCoerce
def _subCoerce(self, specimen, ej):
if isinstance(specimen, ConstMap):
if self.keyGuard is anyGuard and self.valueGuard is anyGuard:
return specimen
else:
d = {}
ks = []
for i, k in enumerate(specimen._keys):
coercedK = self.keyGuard.coerce(k, ej)
coercedV = self.valueGuard.coerce(specimen.d[k], ej)
ks.append(coercedK)
d[coercedK] = coercedV
return ConstMap(d, ks)
else:
throw.eject(ej, "is not a ConstMap")
开发者ID:froztbyte,项目名称:monte,代码行数:15,代码来源:tables.py
示例10: auditForDeepFrozen
def auditForDeepFrozen(audition, ej):
from monte.expander import scope
expr = audition.getObjectExpr()
patternSS = scope(expr.args[1])
scriptSS = scope(expr.args[3])
fqn = audition.getFQN()
names = scriptSS.namesUsed().butNot(patternSS.defNames)
for name in names:
if name in patternSS.varNames:
throw.eject(ej, "%s in the definition of %s is a variable pattern "
"and therefore not DeepFrozen" % (toQuote(name), fqn))
else:
nameObj = String(name)
guard = audition.getGuard(nameObj)
if deepFrozenGuard.supersetOf(guard) is false:
throw.eject(ej, "%s in the lexical scope of %s does not have "
"a guard implying DeepFrozen, but %s" % (
toQuote(name), fqn, toQuote(guard)))
开发者ID:justinnoah,项目名称:monte,代码行数:18,代码来源:base.py
示例11: matchBind
def matchBind(self, values, specimen, ej):
#XXX maybe put this on a different object?
specimen = twineGuard.coerce(specimen, ej).bare().s
values = listGuard.coerce(values, throw)
values = values.l
i = 0
bindings = []
for n in range(len(self.segments)):
typ, val = self.segments[n]
if typ is LITERAL:
j = i + len(val)
if specimen[i:j] != val:
throw.eject(ej, "expected %r..., found %r" % (
val, specimen[i:j]))
elif typ is VALUE_HOLE:
s = values[val]
s = twineGuard.coerce(s, throw).bare().s
j = i + len(s)
if specimen[i:j] != s:
throw.eject(ej, "expected %r... ($-hole %s), found %r" % (
s, val, specimen[i:j]))
elif typ is PATTERN_HOLE:
nextVal = None
if n == len(self.segments) - 1:
bindings.append(String(specimen[i:]))
i = len(specimen)
continue
nextType, nextVal = self.segments[n + 1]
if nextType is VALUE_HOLE:
nextVal = twineGuard.coerce(values[nextVal], throw).bare().s
elif nextType is PATTERN_HOLE:
bindings.append(String(u""))
continue
j = specimen.find(nextVal, i)
if j == -1:
throw.eject(ej, "expected %r..., found %r" % (
nextVal,
specimen[i:]))
bindings.append(String(specimen[i:j]))
i = j
if (i == len(specimen)):
return ConstList(bindings)
throw.eject(ej, "Excess unmatched: " + specimen[i:])
开发者ID:washort,项目名称:monte,代码行数:44,代码来源:text.py
示例12: matchBind
def matchBind(self, values, specimen, ej):
#XXX maybe put this on a different object?
if not isinstance(specimen, Twine):
raise RuntimeError("%r is not a string" % (specimen,))
if not isinstance(values, (ConstList, FlexList)):
raise RuntimeError("%r is not a list" % (values,))
specimen = unicodeFromTwine(specimen)
values = values.l
i = 0
bindings = []
for n in range(len(self.segments)):
typ, val = self.segments[n]
if typ is LITERAL:
j = i + len(val)
if specimen[i:j] != val:
throw.eject(ej, "expected %r..., found %r" % (
val, specimen[i:j]))
elif typ is VALUE_HOLE:
s = values[val]
if not isinstance(s, String):
raise RuntimeError("%r is not a string" % (s,))
s = unicodeFromTwine(s)
j = i + len(s)
if specimen[i:j] != s:
throw.eject(ej, "expected %r... ($-hole %s), found %r" % (
s, val, specimen[i:j]))
elif typ is PATTERN_HOLE:
nextVal = None
if n == len(self.segments) - 1:
bindings.append(String(specimen[i:]))
continue
nextType, nextVal = self.segments[n + 1]
if nextType is VALUE_HOLE:
nextVal = values[nextVal]
if not isinstance(nextVal, String):
raise RuntimeError("%r is not a string" % (nextVal,))
nextVal = unicodeFromTwine(nextVal)
elif nextType is PATTERN_HOLE:
bindings.append(String(u""))
continue
j = specimen.find(nextVal, i)
if j == -1:
throw.eject(ej, "expected %r..., found %r" % (
unicodeFromTwine(nextVal),
specimen[i:]))
bindings.append(String(specimen[i:j]))
i = j
return ConstList(bindings)
开发者ID:songaal,项目名称:monte,代码行数:48,代码来源:text.py
示例13: matchBind
def matchBind(self, values, specimen, ej):
#XXX maybe put this on a different object?
if not isinstance(specimen, String):
raise RuntimeError("%r is not a string" % (specimen,))
if not isinstance(values, (ConstList, FlexList)):
raise RuntimeError("%r is not a list" % (values,))
specimen = specimen.s
values = values.l
i = 0
bindings = []
for n in range(len(self.segments)):
typ, val = self.segments[n]
if typ == 'literal':
j = i + len(val)
if specimen[i:j] != val:
throw.eject(ej, "expected %r..., found %r" % (
val, specimen[i:j]))
elif typ == 'value':
s = values[val]
if not isinstance(s, String):
raise RuntimeError("%r is not a string" % (s,))
s = s.s
j = i + len(s)
if specimen[i:j] != s:
throw.eject(ej, "expected %r... ($-hole %s), found %r" % (
s, val, specimen[i:j]))
elif typ == 'pattern':
nextVal = None
if n == len(self.segments) - 1:
bindings.append(String(specimen[i:]))
continue
nextType, nextVal = self.segments[n + 1]
if nextType == 'value':
nextVal = values[nextVal]
if not isinstance(nextVal, String):
raise RuntimeError("%r is not a string" % (nextVal,))
nextVal = nextVal.s
elif nextType == 'pattern':
bindings.append(String(u""))
continue
j = specimen.find(nextVal)
if j == -1:
throw.eject(ej, "expected %r..., found %r" % (nextVal.s, specimen[i:]))
bindings.append(String(specimen[i:j]))
i = j
return ConstList(bindings)
开发者ID:justinnoah,项目名称:monte,代码行数:46,代码来源:text.py
示例14: coerce
def coerce(self, specimen, ej):
if specimen is not null:
throw.eject(ej, "%s must be null" % (toQuote(specimen),))
return null
开发者ID:washort,项目名称:monte,代码行数:4,代码来源:base.py
示例15: next
def next(self, ej):
try:
return self.it.next()
except StopIteration:
throw.eject(ej, "iteration done")
开发者ID:froztbyte,项目名称:monte,代码行数:5,代码来源:flow.py
示例16: coerce
def coerce(self, specimen, ej):
if specimen.size() == Integer(0):
return specimen
else:
throw.eject(ej, "Not empty: %s" % specimen)
开发者ID:songaal,项目名称:monte,代码行数:5,代码来源:helpers.py
示例17: _subCoerce
def _subCoerce(self, specimen, ej):
if not selflessGuard in specimen._m_auditorStamps:
throw.eject(ej, "is not Selfless")
开发者ID:justinnoah,项目名称:monte,代码行数:3,代码来源:base.py
示例18: _subCoerce
def _subCoerce(self, specimen, ej):
if not transparentStamp in specimen._m_auditorStamps:
throw.eject(ej, "%s is not Transparent" % (toQuote(self.specimen),))
开发者ID:washort,项目名称:monte,代码行数:3,代码来源:base.py
注:本文中的monte.runtime.base.throw.eject函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论