Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from foolscap.tokens import Violation, UnknownSchemaType, BananaError, \
tokenNames
# make constraints available in a single location
from foolscap.constraint import Constraint, Any, ByteStringConstraint, \
IntegerConstraint, NumberConstraint, IConstraint, Optional, Shared
from foolscap.slicers.unicode import UnicodeConstraint
from foolscap.slicers.bool import BooleanConstraint
from foolscap.slicers.dict import DictConstraint
from foolscap.slicers.list import ListConstraint
from foolscap.slicers.set import SetConstraint
from foolscap.slicers.tuple import TupleConstraint
from foolscap.slicers.none import Nothing
# we don't import RemoteMethodSchema from remoteinterface.py, because
# remoteinterface.py needs to import us (for addToConstraintTypeMap)
ignored = [Constraint, Any, ByteStringConstraint, UnicodeConstraint,
IntegerConstraint, NumberConstraint, BooleanConstraint,
DictConstraint, ListConstraint, SetConstraint, TupleConstraint,
Nothing, Optional, Shared,
] # hush pyflakes
# convenience shortcuts
TupleOf = TupleConstraint
ListOf = ListConstraint
DictOf = DictConstraint
SetOf = SetConstraint
# note: using PolyConstraint (aka ChoiceOf) for inbound tasting is probably
# not fully vetted. One of the issues would be with something like
# ListOf(ChoiceOf(TupleOf(stuff), SetOf(stuff))). The ListUnslicer, when
def getKeywordArgConstraint(self, argname, num_posargs=0,
previous_kwargs=[]):
return (True, Any())
def checkAllArgs(self, args, kwargs, inbound):
def setConstraint(self, constraint):
if isinstance(constraint, Any):
return
assert isinstance(constraint, ListConstraint)
self.maxLength = constraint.maxLength
self.itemConstraint = constraint.constraint
def setConstraint(self, constraint):
if isinstance(constraint, Any):
return
assert False, "DecimalUnslicer does not currently accept a constraint"
def setConstraint(self, constraint):
if isinstance(constraint, Any):
return
assert isinstance(constraint, BooleanConstraint)
self.constraint = constraint
def setConstraint(self, constraint):
if isinstance(constraint, Any):
return
assert isinstance(constraint, UnicodeConstraint)
self.constraint = constraint
def setConstraint(self, constraint):
if isinstance(constraint, Any):
return
assert isinstance(constraint, ByteStringConstraint)
self.valueConstraint = constraint
def setConstraint(self, constraint):
if isinstance(constraint, Any):
return
assert isinstance(constraint, SetConstraint)
self.maxLength = constraint.maxLength
self.itemConstraint = constraint.constraint
def getReferenceByName(name=bytes):
"""If I have published an object by that name, return a reference to
it."""
# return Remote(interface=any)
return Any()
def decref(clid=int, count=int):
def getPositionalArgConstraint(self, argnum):
return (True, Any())
def getKeywordArgConstraint(self, argname, num_posargs=0,