~divmod-dev/divmod.org/no-addperson-2190

« back to all changes in this revision

Viewing changes to Imaginary/pottery/predicates.py

  • Committer: exarkun
  • Date: 2006-02-26 02:37:39 UTC
  • Revision ID: svn-v4:866e43f7-fbfc-0310-8f2a-ec88d1da2979:trunk:4991
Merge move-pottery-to-trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
class atLeastOne(object):
 
2
    def __init__(self, methodName, *objs):
 
3
        self.methodName = methodName
 
4
        self.objs = objs
 
5
 
 
6
    def __call__(self, obj):
 
7
        for o in self.objs:
 
8
            if getattr(obj, self.methodName)(o):
 
9
                return True
 
10
        return False
 
11
 
 
12
class isNot(object):
 
13
    def __init__(self, *objs):
 
14
        self.objs = objs
 
15
 
 
16
    def __call__(self, obj):
 
17
        for o in self.objs:
 
18
            if o is obj:
 
19
                return False
 
20
        return True
 
21
 
 
22
class And(object):
 
23
    def __init__(self, *what):
 
24
        self.what = what
 
25
 
 
26
    def __call__(self, obj):
 
27
        for w in self.what:
 
28
            if not w(obj):
 
29
                return False
 
30
        return True