src/reportlab/lib/validators.py
author robin <robin@reportlab.com>
Tue, 07 Mar 2017 10:00:34 +0000
changeset 4330 617ffa6bbdc8
parent 4252 fe660f227cac
child 4367 9960d82643bf
permissions -rw-r--r--
changes for release 3.4.0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4330
617ffa6bbdc8 changes for release 3.4.0
robin <robin@reportlab.com>
parents: 4252
diff changeset
     1
#Copyright ReportLab Europe Ltd. 2000-2017
1559
2bb75ab0d0aa Added __version__
rgbecker
parents: 1391
diff changeset
     2
#see license.txt for license details
2332
2a7ab4405e18 Remove $Header:, fix CopyRight & history
rgbecker
parents: 2321
diff changeset
     3
#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/lib/validators.py
4252
fe660f227cac changes for release 3.3.0
robin
parents: 3908
diff changeset
     4
__version__='3.3.0'
3029
eded59f94021 adding docstrings to lib
andy
parents: 2964
diff changeset
     5
__doc__="""Standard verifying functions used by attrmap."""
908
3564ccbf97e6 Added future validators module (stripped off from shapes.py).
dinu_gherman
parents:
diff changeset
     6
3824
27242f7ef7e2 validators.py: fix _isBoolean
robin
parents: 3762
diff changeset
     7
import sys, codecs
3835
8e35c471e0ee various: attempt to be more consistent about isStr
robin
parents: 3829
diff changeset
     8
from reportlab.lib.utils import isSeq, isBytes, isStr, isPy3
908
3564ccbf97e6 Added future validators module (stripped off from shapes.py).
dinu_gherman
parents:
diff changeset
     9
from reportlab.lib import colors
3564ccbf97e6 Added future validators module (stripped off from shapes.py).
dinu_gherman
parents:
diff changeset
    10
3625
c459ddaafe88 linecharts.py: added in lineStyle (for bars)
rgbecker
parents: 3617
diff changeset
    11
class Percentage(float):
c459ddaafe88 linecharts.py: added in lineStyle (for bars)
rgbecker
parents: 3617
diff changeset
    12
    pass
c459ddaafe88 linecharts.py: added in lineStyle (for bars)
rgbecker
parents: 3617
diff changeset
    13
945
4c7026f40785 New Scheme Validators
rgbecker
parents: 941
diff changeset
    14
class Validator:
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    15
    "base validator class"
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    16
    def __call__(self,x):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    17
        return self.test(x)
945
4c7026f40785 New Scheme Validators
rgbecker
parents: 941
diff changeset
    18
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    19
    def __str__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    20
        return getattr(self,'_str',self.__class__.__name__)
908
3564ccbf97e6 Added future validators module (stripped off from shapes.py).
dinu_gherman
parents:
diff changeset
    21
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    22
    def normalize(self,x):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    23
        return x
931
07db840b3db6 Changed validator functions into classes.
dinu_gherman
parents: 909
diff changeset
    24
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    25
    def normalizeTest(self,x):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    26
        try:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    27
            self.normalize(x)
2120
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
    28
            return True
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    29
        except:
2120
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
    30
            return False
908
3564ccbf97e6 Added future validators module (stripped off from shapes.py).
dinu_gherman
parents:
diff changeset
    31
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
    32
class _isAnything(Validator):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    33
    def test(self,x):
2120
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
    34
        return True
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
    35
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
    36
class _isNothing(Validator):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    37
    def test(self,x):
2120
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
    38
        return False
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
    39
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
    40
class _isBoolean(Validator):
3762
4817e577522d some fixes to typeing etc etc
robin
parents: 3731
diff changeset
    41
    def test(self,x):
4817e577522d some fixes to typeing etc etc
robin
parents: 3731
diff changeset
    42
        if isinstance(int,bool): return x in (0,1)
4817e577522d some fixes to typeing etc etc
robin
parents: 3731
diff changeset
    43
        return self.normalizeTest(x)
931
07db840b3db6 Changed validator functions into classes.
dinu_gherman
parents: 909
diff changeset
    44
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    45
    def normalize(self,x):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    46
        if x in (0,1): return x
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    47
        try:
3824
27242f7ef7e2 validators.py: fix _isBoolean
robin
parents: 3762
diff changeset
    48
            S = x.upper()
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    49
        except:
3824
27242f7ef7e2 validators.py: fix _isBoolean
robin
parents: 3762
diff changeset
    50
            raise ValueError('Must be boolean not %s' % ascii(s))
2120
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
    51
        if S in ('YES','TRUE'): return True
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
    52
        if S in ('NO','FALSE',None): return False
3824
27242f7ef7e2 validators.py: fix _isBoolean
robin
parents: 3762
diff changeset
    53
        raise ValueError('Must be boolean not %s' % ascii(s))
909
a5ee7d2bdb17 Extracted validator functions into lib.validators.
dinu_gherman
parents: 908
diff changeset
    54
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
    55
class _isString(Validator):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    56
    def test(self,x):
3908
edd638c620e0 validators.py: fix isString for python2
robin
parents: 3835
diff changeset
    57
        return isStr(x)
931
07db840b3db6 Changed validator functions into classes.
dinu_gherman
parents: 909
diff changeset
    58
2616
e3f68f895246 codec validator for diagra
andy
parents: 2575
diff changeset
    59
class _isCodec(Validator):
e3f68f895246 codec validator for diagra
andy
parents: 2575
diff changeset
    60
    def test(self,x):
3762
4817e577522d some fixes to typeing etc etc
robin
parents: 3731
diff changeset
    61
        if not isStr(x):
2616
e3f68f895246 codec validator for diagra
andy
parents: 2575
diff changeset
    62
            return False
e3f68f895246 codec validator for diagra
andy
parents: 2575
diff changeset
    63
        try:
e3f68f895246 codec validator for diagra
andy
parents: 2575
diff changeset
    64
            a,b,c,d = codecs.lookup(x)
e3f68f895246 codec validator for diagra
andy
parents: 2575
diff changeset
    65
            return True
e3f68f895246 codec validator for diagra
andy
parents: 2575
diff changeset
    66
        except LookupError:
e3f68f895246 codec validator for diagra
andy
parents: 2575
diff changeset
    67
            return False
e3f68f895246 codec validator for diagra
andy
parents: 2575
diff changeset
    68
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
    69
class _isNumber(Validator):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    70
    def test(self,x):
3762
4817e577522d some fixes to typeing etc etc
robin
parents: 3731
diff changeset
    71
        if isinstance(x,(float,int)): return True
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    72
        return self.normalizeTest(x)
931
07db840b3db6 Changed validator functions into classes.
dinu_gherman
parents: 909
diff changeset
    73
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    74
    def normalize(self,x):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    75
        try:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    76
            return float(x)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    77
        except:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    78
            return int(x)
908
3564ccbf97e6 Added future validators module (stripped off from shapes.py).
dinu_gherman
parents:
diff changeset
    79
1055
30ca3865f6ed Added isInt and changed SequenceOf and OneOf to be more friendly
rgbecker
parents: 1022
diff changeset
    80
class _isInt(Validator):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    81
    def test(self,x):
3824
27242f7ef7e2 validators.py: fix _isBoolean
robin
parents: 3762
diff changeset
    82
        if not isinstance(x,int) and not isStr(x): return False
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    83
        return self.normalizeTest(x)
1055
30ca3865f6ed Added isInt and changed SequenceOf and OneOf to be more friendly
rgbecker
parents: 1022
diff changeset
    84
3835
8e35c471e0ee various: attempt to be more consistent about isStr
robin
parents: 3829
diff changeset
    85
    if not isPy3:
8e35c471e0ee various: attempt to be more consistent about isStr
robin
parents: 3829
diff changeset
    86
        def normalize(self,x):
8e35c471e0ee various: attempt to be more consistent about isStr
robin
parents: 3829
diff changeset
    87
            return int(x)
8e35c471e0ee various: attempt to be more consistent about isStr
robin
parents: 3829
diff changeset
    88
    else:
8e35c471e0ee various: attempt to be more consistent about isStr
robin
parents: 3829
diff changeset
    89
        def normalize(self,x):
8e35c471e0ee various: attempt to be more consistent about isStr
robin
parents: 3829
diff changeset
    90
            return int(x.decode('utf8') if isBytes(x) else x)
1683
7fa753e4420a Removed all trailing whitespace
andy_robinson
parents: 1677
diff changeset
    91
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
    92
class _isNumberOrNone(_isNumber):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    93
    def test(self,x):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    94
        return x is None or isNumber(x)
908
3564ccbf97e6 Added future validators module (stripped off from shapes.py).
dinu_gherman
parents:
diff changeset
    95
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    96
    def normalize(self,x):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    97
        if x is None: return x
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
    98
        return _isNumber.normalize(x)
908
3564ccbf97e6 Added future validators module (stripped off from shapes.py).
dinu_gherman
parents:
diff changeset
    99
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
   100
class _isListOfNumbersOrNone(Validator):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   101
    "ListOfNumbersOrNone validator class."
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   102
    def test(self, x):
2120
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
   103
        if x is None: return True
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   104
        return isListOfNumbers(x)
931
07db840b3db6 Changed validator functions into classes.
dinu_gherman
parents: 909
diff changeset
   105
3198
683ca9eb6b18 reportlab: added in support for Overprint/Opacity & Separated colours (Opacity inspired by Simon King)
rgbecker
parents: 3029
diff changeset
   106
class isNumberInRange(_isNumber):
683ca9eb6b18 reportlab: added in support for Overprint/Opacity & Separated colours (Opacity inspired by Simon King)
rgbecker
parents: 3029
diff changeset
   107
    def __init__(self, min, max):
683ca9eb6b18 reportlab: added in support for Overprint/Opacity & Separated colours (Opacity inspired by Simon King)
rgbecker
parents: 3029
diff changeset
   108
        self.min = min
683ca9eb6b18 reportlab: added in support for Overprint/Opacity & Separated colours (Opacity inspired by Simon King)
rgbecker
parents: 3029
diff changeset
   109
        self.max = max
683ca9eb6b18 reportlab: added in support for Overprint/Opacity & Separated colours (Opacity inspired by Simon King)
rgbecker
parents: 3029
diff changeset
   110
683ca9eb6b18 reportlab: added in support for Overprint/Opacity & Separated colours (Opacity inspired by Simon King)
rgbecker
parents: 3029
diff changeset
   111
    def test(self, x):
683ca9eb6b18 reportlab: added in support for Overprint/Opacity & Separated colours (Opacity inspired by Simon King)
rgbecker
parents: 3029
diff changeset
   112
        try:
683ca9eb6b18 reportlab: added in support for Overprint/Opacity & Separated colours (Opacity inspired by Simon King)
rgbecker
parents: 3029
diff changeset
   113
            n = self.normalize(x)
683ca9eb6b18 reportlab: added in support for Overprint/Opacity & Separated colours (Opacity inspired by Simon King)
rgbecker
parents: 3029
diff changeset
   114
            if self.min <= n <= self.max:
683ca9eb6b18 reportlab: added in support for Overprint/Opacity & Separated colours (Opacity inspired by Simon King)
rgbecker
parents: 3029
diff changeset
   115
                return True
683ca9eb6b18 reportlab: added in support for Overprint/Opacity & Separated colours (Opacity inspired by Simon King)
rgbecker
parents: 3029
diff changeset
   116
        except ValueError:
683ca9eb6b18 reportlab: added in support for Overprint/Opacity & Separated colours (Opacity inspired by Simon King)
rgbecker
parents: 3029
diff changeset
   117
            pass
683ca9eb6b18 reportlab: added in support for Overprint/Opacity & Separated colours (Opacity inspired by Simon King)
rgbecker
parents: 3029
diff changeset
   118
        return False
3219
b28d6eef8227 reportlab: add support for String anchor 'numeric'
rgbecker
parents: 3198
diff changeset
   119
3198
683ca9eb6b18 reportlab: added in support for Overprint/Opacity & Separated colours (Opacity inspired by Simon King)
rgbecker
parents: 3029
diff changeset
   120
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
   121
class _isListOfShapes(Validator):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   122
    "ListOfShapes validator class."
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   123
    def test(self, x):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   124
        from reportlab.graphics.shapes import Shape
3731
b233dd0577ff another round of changes mostly type related
rptlab
parents: 3721
diff changeset
   125
        if isSeq(x):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   126
            answer = 1
2775
b6a79c190a5e validators.py: fix bug in isListOfShapes
rgbecker
parents: 2616
diff changeset
   127
            for e in x:
b6a79c190a5e validators.py: fix bug in isListOfShapes
rgbecker
parents: 2616
diff changeset
   128
                if not isinstance(e, Shape):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   129
                    answer = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   130
            return answer
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   131
        else:
2120
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
   132
            return False
931
07db840b3db6 Changed validator functions into classes.
dinu_gherman
parents: 909
diff changeset
   133
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
   134
class _isListOfStringsOrNone(Validator):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   135
    "ListOfStringsOrNone validator class."
931
07db840b3db6 Changed validator functions into classes.
dinu_gherman
parents: 909
diff changeset
   136
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   137
    def test(self, x):
2120
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
   138
        if x is None: return True
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   139
        return isListOfStrings(x)
931
07db840b3db6 Changed validator functions into classes.
dinu_gherman
parents: 909
diff changeset
   140
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
   141
class _isTransform(Validator):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   142
    "Transform validator class."
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   143
    def test(self, x):
3731
b233dd0577ff another round of changes mostly type related
rptlab
parents: 3721
diff changeset
   144
        if isSeq(x):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   145
            if len(x) == 6:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   146
                for element in x:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   147
                    if not isNumber(element):
2120
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
   148
                        return False
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
   149
                return True
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   150
            else:
2120
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
   151
                return False
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   152
        else:
2120
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
   153
            return False
908
3564ccbf97e6 Added future validators module (stripped off from shapes.py).
dinu_gherman
parents:
diff changeset
   154
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
   155
class _isColor(Validator):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   156
    "Color validator class."
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   157
    def test(self, x):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   158
        return isinstance(x, colors.Color)
908
3564ccbf97e6 Added future validators module (stripped off from shapes.py).
dinu_gherman
parents:
diff changeset
   159
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
   160
class _isColorOrNone(Validator):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   161
    "ColorOrNone validator class."
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   162
    def test(self, x):
2120
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
   163
        if x is None: return True
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   164
        return isColor(x)
908
3564ccbf97e6 Added future validators module (stripped off from shapes.py).
dinu_gherman
parents:
diff changeset
   165
3339
26eb637a7f55 validators.py: add isNormalDate
rgbecker
parents: 3326
diff changeset
   166
from reportlab.lib.normalDate import NormalDate
26eb637a7f55 validators.py: add isNormalDate
rgbecker
parents: 3326
diff changeset
   167
class _isNormalDate(Validator):
26eb637a7f55 validators.py: add isNormalDate
rgbecker
parents: 3326
diff changeset
   168
    def test(self,x):
26eb637a7f55 validators.py: add isNormalDate
rgbecker
parents: 3326
diff changeset
   169
        if isinstance(x,NormalDate):
26eb637a7f55 validators.py: add isNormalDate
rgbecker
parents: 3326
diff changeset
   170
            return True
3418
25f506eaf3c1 validators.py: fix _isNormalDate
rgbecker
parents: 3357
diff changeset
   171
        return x is not None and self.normalizeTest(x)
3339
26eb637a7f55 validators.py: add isNormalDate
rgbecker
parents: 3326
diff changeset
   172
26eb637a7f55 validators.py: add isNormalDate
rgbecker
parents: 3326
diff changeset
   173
    def normalize(self,x):
26eb637a7f55 validators.py: add isNormalDate
rgbecker
parents: 3326
diff changeset
   174
        return NormalDate(x)
26eb637a7f55 validators.py: add isNormalDate
rgbecker
parents: 3326
diff changeset
   175
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
   176
class _isValidChild(Validator):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   177
    "ValidChild validator class."
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   178
    def test(self, x):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   179
        """Is this child allowed in a drawing or group?
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   180
        I.e. does it descend from Shape or UserNode?
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   181
        """
931
07db840b3db6 Changed validator functions into classes.
dinu_gherman
parents: 909
diff changeset
   182
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   183
        from reportlab.graphics.shapes import UserNode, Shape
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   184
        return isinstance(x, UserNode) or isinstance(x, Shape)
931
07db840b3db6 Changed validator functions into classes.
dinu_gherman
parents: 909
diff changeset
   185
1083
cb535e133d57 Added isValidChildOrNone
rgbecker
parents: 1059
diff changeset
   186
class _isValidChildOrNone(_isValidChild):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   187
    def test(self,x):
2575
0cba68b93555 reportlab-utf8 moved to trunk
rgbecker
parents: 2573
diff changeset
   188
        return _isValidChild.test(self,x) or x is None
1083
cb535e133d57 Added isValidChildOrNone
rgbecker
parents: 1059
diff changeset
   189
1391
35552052df99 Added a _isCallable + a couple of new vaildators
rgbecker
parents: 1385
diff changeset
   190
class _isCallable(Validator):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   191
    def test(self, x):
3326
ce725978d11c Initial Python3 compatibility fixes
damian
parents: 3219
diff changeset
   192
        return hasattr(x,'__call__')
1391
35552052df99 Added a _isCallable + a couple of new vaildators
rgbecker
parents: 1385
diff changeset
   193
931
07db840b3db6 Changed validator functions into classes.
dinu_gherman
parents: 909
diff changeset
   194
class OneOf(Validator):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   195
    """Make validator functions for list of choices.
931
07db840b3db6 Changed validator functions into classes.
dinu_gherman
parents: 909
diff changeset
   196
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   197
    Usage:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   198
    f = reportlab.lib.validators.OneOf('happy','sad')
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   199
    or
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   200
    f = reportlab.lib.validators.OneOf(('happy','sad'))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   201
    f('sad'),f('happy'), f('grumpy')
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   202
    (1,1,0)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   203
    """
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   204
    def __init__(self, enum,*args):
3762
4817e577522d some fixes to typeing etc etc
robin
parents: 3731
diff changeset
   205
        if isSeq(enum):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   206
            if args!=():
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3645
diff changeset
   207
                raise ValueError("Either all singleton args or a single sequence argument")
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   208
            self._enum = tuple(enum)+args
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   209
        else:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   210
            self._enum = (enum,)+args
908
3564ccbf97e6 Added future validators module (stripped off from shapes.py).
dinu_gherman
parents:
diff changeset
   211
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   212
    def test(self, x):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   213
        return x in self._enum
931
07db840b3db6 Changed validator functions into classes.
dinu_gherman
parents: 909
diff changeset
   214
945
4c7026f40785 New Scheme Validators
rgbecker
parents: 941
diff changeset
   215
class SequenceOf(Validator):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   216
    def __init__(self,elemTest,name=None,emptyOK=1, NoneOK=0, lo=0,hi=0x7fffffff):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   217
        self._elemTest = elemTest
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   218
        self._emptyOK = emptyOK
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   219
        self._NoneOK = NoneOK
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   220
        self._lo, self._hi = lo, hi
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   221
        if name: self._str = name
908
3564ccbf97e6 Added future validators module (stripped off from shapes.py).
dinu_gherman
parents:
diff changeset
   222
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   223
    def test(self, x):
3731
b233dd0577ff another round of changes mostly type related
rptlab
parents: 3721
diff changeset
   224
        if not isSeq(x):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   225
            if x is None: return self._NoneOK
2120
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
   226
            return False
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   227
        if x==[] or x==():
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   228
            return self._emptyOK
2120
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
   229
        elif not self._lo<=len(x)<=self._hi: return False
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   230
        for e in x:
2120
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
   231
            if not self._elemTest(e): return False
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
   232
        return True
908
3564ccbf97e6 Added future validators module (stripped off from shapes.py).
dinu_gherman
parents:
diff changeset
   233
1385
5d88aaeb63af Fixed EitherOr
rgbecker
parents: 1365
diff changeset
   234
class EitherOr(Validator):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   235
    def __init__(self,tests,name=None):
3731
b233dd0577ff another round of changes mostly type related
rptlab
parents: 3721
diff changeset
   236
        if not isSeq(tests): tests = (tests,)
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   237
        self._tests = tests
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   238
        if name: self._str = name
1385
5d88aaeb63af Fixed EitherOr
rgbecker
parents: 1365
diff changeset
   239
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   240
    def test(self, x):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   241
        for t in self._tests:
2120
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
   242
            if t(x): return True
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
   243
        return False
1385
5d88aaeb63af Fixed EitherOr
rgbecker
parents: 1365
diff changeset
   244
1197
d7ce043c87b4 Added NoneOr and various specialized validators
rgbecker
parents: 1083
diff changeset
   245
class NoneOr(Validator):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   246
    def __init__(self,elemTest,name=None):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   247
        self._elemTest = elemTest
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   248
        if name: self._str = name
1197
d7ce043c87b4 Added NoneOr and various specialized validators
rgbecker
parents: 1083
diff changeset
   249
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   250
    def test(self, x):
2120
211d3391bd9d Allow for True/False
rgbecker
parents: 2115
diff changeset
   251
        if x is None: return True
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   252
        return self._elemTest(x)
1197
d7ce043c87b4 Added NoneOr and various specialized validators
rgbecker
parents: 1083
diff changeset
   253
2424
101cf0c8500e validators.py: better auto support
rgbecker
parents: 2421
diff changeset
   254
class Auto(Validator):
2426
fac927fa6f7c Auto Legends
rgbecker
parents: 2424
diff changeset
   255
    def __init__(self,**kw):
fac927fa6f7c Auto Legends
rgbecker
parents: 2424
diff changeset
   256
        self.__dict__.update(kw)
fac927fa6f7c Auto Legends
rgbecker
parents: 2424
diff changeset
   257
2424
101cf0c8500e validators.py: better auto support
rgbecker
parents: 2421
diff changeset
   258
    def test(self,x):
2426
fac927fa6f7c Auto Legends
rgbecker
parents: 2424
diff changeset
   259
        return x is self.__class__ or isinstance(x,self.__class__)
2424
101cf0c8500e validators.py: better auto support
rgbecker
parents: 2421
diff changeset
   260
2421
3d4a0d0858a0 validators.py: forgot to check in with AutoOr
rgbecker
parents: 2341
diff changeset
   261
class AutoOr(NoneOr):
3d4a0d0858a0 validators.py: forgot to check in with AutoOr
rgbecker
parents: 2341
diff changeset
   262
    def test(self,x):
2426
fac927fa6f7c Auto Legends
rgbecker
parents: 2424
diff changeset
   263
        return isAuto(x) or self._elemTest(x)
2421
3d4a0d0858a0 validators.py: forgot to check in with AutoOr
rgbecker
parents: 2341
diff changeset
   264
1248
d0c16c9d621a Added isInstanceOf
rgbecker
parents: 1246
diff changeset
   265
class isInstanceOf(Validator):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   266
    def __init__(self,klass=None):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   267
        self._klass = klass
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   268
    def test(self,x):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1559
diff changeset
   269
        return isinstance(x,self._klass)
1248
d0c16c9d621a Added isInstanceOf
rgbecker
parents: 1246
diff changeset
   270
2573
273f77e79536 new pattern matcher - partially done
andy
parents: 2547
diff changeset
   271
class matchesPattern(Validator):
273f77e79536 new pattern matcher - partially done
andy
parents: 2547
diff changeset
   272
    """Matches value, or its string representation, against regex"""
273f77e79536 new pattern matcher - partially done
andy
parents: 2547
diff changeset
   273
    def __init__(self, pattern):
273f77e79536 new pattern matcher - partially done
andy
parents: 2547
diff changeset
   274
        self._pattern = re.compile(pattern)
273f77e79536 new pattern matcher - partially done
andy
parents: 2547
diff changeset
   275
273f77e79536 new pattern matcher - partially done
andy
parents: 2547
diff changeset
   276
    def test(self,x):
3762
4817e577522d some fixes to typeing etc etc
robin
parents: 3731
diff changeset
   277
        x = str(x)
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3645
diff changeset
   278
        print('testing %s against %s' % (x, self._pattern))
3762
4817e577522d some fixes to typeing etc etc
robin
parents: 3731
diff changeset
   279
        return (self._pattern.match(x) != None)
2573
273f77e79536 new pattern matcher - partially done
andy
parents: 2547
diff changeset
   280
2547
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   281
class DerivedValue:
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   282
    """This is used for magic values which work themselves out.
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   283
    An example would be an "inherit" property, so that one can have
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   284
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   285
      drawing.chart.categoryAxis.labels.fontName = inherit
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   286
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   287
    and pick up the value from the top of the drawing.
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   288
    Validators will permit this provided that a value can be pulled
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   289
    in which satisfies it.  And the renderer will have special
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   290
    knowledge of these so they can evaluate themselves.
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   291
    """
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   292
    def getValue(self, renderer, attr):
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   293
        """Override this.  The renderers will pass the renderer,
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   294
        and the attribute name.  Algorithms can then backtrack up
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   295
        through all the stuff the renderer provides, including
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   296
        a correct stack of parent nodes."""
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   297
        return None
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   298
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   299
class Inherit(DerivedValue):
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   300
    def __repr__(self):
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   301
        return "inherit"
3219
b28d6eef8227 reportlab: add support for String anchor 'numeric'
rgbecker
parents: 3198
diff changeset
   302
2547
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   303
    def getValue(self, renderer, attr):
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   304
        return renderer.getStateValue(attr)
3219
b28d6eef8227 reportlab: add support for String anchor 'numeric'
rgbecker
parents: 3198
diff changeset
   305
inherit = Inherit()
2547
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   306
3219
b28d6eef8227 reportlab: add support for String anchor 'numeric'
rgbecker
parents: 3198
diff changeset
   307
class NumericAlign(str):
b28d6eef8227 reportlab: add support for String anchor 'numeric'
rgbecker
parents: 3198
diff changeset
   308
    '''for creating the numeric string value for anchors etc etc
b28d6eef8227 reportlab: add support for String anchor 'numeric'
rgbecker
parents: 3198
diff changeset
   309
    dp is the character to align on (the last occurrence will be used)
b28d6eef8227 reportlab: add support for String anchor 'numeric'
rgbecker
parents: 3198
diff changeset
   310
    dpLen is the length of characters after the dp
b28d6eef8227 reportlab: add support for String anchor 'numeric'
rgbecker
parents: 3198
diff changeset
   311
    '''
b28d6eef8227 reportlab: add support for String anchor 'numeric'
rgbecker
parents: 3198
diff changeset
   312
    def __new__(cls,dp='.',dpLen=0):
b28d6eef8227 reportlab: add support for String anchor 'numeric'
rgbecker
parents: 3198
diff changeset
   313
        self = str.__new__(cls,'numeric')
b28d6eef8227 reportlab: add support for String anchor 'numeric'
rgbecker
parents: 3198
diff changeset
   314
        self._dp=dp
b28d6eef8227 reportlab: add support for String anchor 'numeric'
rgbecker
parents: 3198
diff changeset
   315
        self._dpLen = dpLen
b28d6eef8227 reportlab: add support for String anchor 'numeric'
rgbecker
parents: 3198
diff changeset
   316
        return self
2547
9d13685212f2 datacharts synchronised
andy
parents: 2426
diff changeset
   317
2424
101cf0c8500e validators.py: better auto support
rgbecker
parents: 2421
diff changeset
   318
isAuto = Auto()
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
   319
isBoolean = _isBoolean()
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
   320
isString = _isString()
2616
e3f68f895246 codec validator for diagra
andy
parents: 2575
diff changeset
   321
isCodec = _isCodec()
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
   322
isNumber = _isNumber()
1055
30ca3865f6ed Added isInt and changed SequenceOf and OneOf to be more friendly
rgbecker
parents: 1022
diff changeset
   323
isInt = _isInt()
1365
2ad55cb39128 Added isNoneOrInt
rgbecker
parents: 1353
diff changeset
   324
isNoneOrInt = NoneOr(isInt,'isNoneOrInt')
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
   325
isNumberOrNone = _isNumberOrNone()
1807
b7c571a2e141 Minor enhancements to SpiderChart/Label
rgbecker
parents: 1694
diff changeset
   326
isTextAnchor = OneOf('start','middle','end','boxauto')
945
4c7026f40785 New Scheme Validators
rgbecker
parents: 941
diff changeset
   327
isListOfNumbers = SequenceOf(isNumber,'isListOfNumbers')
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
   328
isListOfNumbersOrNone = _isListOfNumbersOrNone()
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
   329
isListOfShapes = _isListOfShapes()
945
4c7026f40785 New Scheme Validators
rgbecker
parents: 941
diff changeset
   330
isListOfStrings = SequenceOf(isString,'isListOfStrings')
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
   331
isListOfStringsOrNone = _isListOfStringsOrNone()
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
   332
isTransform = _isTransform()
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
   333
isColor = _isColor()
1022
2a7cdced12e3 Added isListofColors.
dinu_gherman
parents: 948
diff changeset
   334
isListOfColors = SequenceOf(isColor,'isListOfColors')
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
   335
isColorOrNone = _isColorOrNone()
1694
1f1031671ae6 Added isShape & isNoneOrShape
rgbecker
parents: 1683
diff changeset
   336
isShape = isValidChild = _isValidChild()
1f1031671ae6 Added isShape & isNoneOrShape
rgbecker
parents: 1683
diff changeset
   337
isNoneOrShape = isValidChildOrNone = _isValidChildOrNone()
948
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
   338
isAnything = _isAnything()
2531b35adf85 New AttrMap emplacement
rgbecker
parents: 945
diff changeset
   339
isNothing = _isNothing()
1059
f0abeaa8e232 Added isXYCoord and isBoxAnchor validators
uid22986
parents: 1055
diff changeset
   340
isXYCoord = SequenceOf(isNumber,lo=2,hi=2,emptyOK=0)
2174
dc5ab1ba37c8 Allow autox/y boxanchor
rgbecker
parents: 2120
diff changeset
   341
isBoxAnchor = OneOf('nw','n','ne','w','c','e','sw','s','se', 'autox', 'autoy')
1197
d7ce043c87b4 Added NoneOr and various specialized validators
rgbecker
parents: 1083
diff changeset
   342
isNoneOrString = NoneOr(isString,'NoneOrString')
1199
5528c92307b2 Allowd SequenceOf to have NoneOK arg
rgbecker
parents: 1197
diff changeset
   343
isNoneOrListOfNoneOrStrings=SequenceOf(isNoneOrString,'isNoneOrListOfNoneOrStrings',NoneOK=1)
1353
0de5adb7beac Added isListOfNoneOrString
rgbecker
parents: 1248
diff changeset
   344
isListOfNoneOrString=SequenceOf(isNoneOrString,'isListOfNoneOrString',NoneOK=0)
1199
5528c92307b2 Allowd SequenceOf to have NoneOK arg
rgbecker
parents: 1197
diff changeset
   345
isNoneOrListOfNoneOrNumbers=SequenceOf(isNumberOrNone,'isNoneOrListOfNoneOrNumbers',NoneOK=1)
1391
35552052df99 Added a _isCallable + a couple of new vaildators
rgbecker
parents: 1385
diff changeset
   346
isCallable = _isCallable()
3645
388ffb1a42df graphics/charts: added CustomDrawChanger class
robin
parents: 3631
diff changeset
   347
isNoneOrCallable = NoneOr(isCallable)
1391
35552052df99 Added a _isCallable + a couple of new vaildators
rgbecker
parents: 1385
diff changeset
   348
isStringOrCallable=EitherOr((isString,isCallable),'isStringOrCallable')
1694
1f1031671ae6 Added isShape & isNoneOrShape
rgbecker
parents: 1683
diff changeset
   349
isStringOrCallableOrNone=NoneOr(isStringOrCallable,'isStringOrCallableNone')
1963
ac30760d5586 Added isStringOrNone
rgbecker
parents: 1941
diff changeset
   350
isStringOrNone=NoneOr(isString,'isStringOrNone')
3339
26eb637a7f55 validators.py: add isNormalDate
rgbecker
parents: 3326
diff changeset
   351
isNormalDate=_isNormalDate()