[MERGE] Remove the embedded pychart library, and use the online version
[odoo/odoo.git] /
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2000-2005 by Yasushi Saito (yasushi.saito@gmail.com)
4
5 # Jockey is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2, or (at your option) any
8 # later version.
9 #
10 # Jockey is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13 # for more details.
14 #
15 import pychart_util
16 import types
17 AnyType = 9998
18
19 def CoordType(val):
20     if type(val) != types.TupleType and type(val) != types.ListType:
21         return (" not a valid coordinate.")
22     if len(val) != 2:
23         return "Coordinate must be a pair of numbers.\n"
24     if val[0] != None:
25         error = NumType(val[0])
26         if error: return error
27     if val[1] != None:    
28         error = NumType(val[1])
29         if error: return error
30     return None    
31
32 def IntervalType(val):
33     if type(val) in (types.IntType, types.LongType,
34                      types.FloatType, types.FunctionType):
35         return None
36     return "Expecting a number or a function"
37
38 def CoordOrNoneType(val):
39     if type(val) not in (types.TupleType, types.ListType):
40         return "Expecting a tuple or a list."
41     if len(val) != 2:
42         return "Coordinate must be a pair of numbers.\n"
43     for v in val:
44         if v != None and NumType(val[0]) != None:
45             return "Expecting a pair of numbers"
46     return None    
47     
48 def NumType(val):
49     if type(val) in (types.IntType, types.LongType, types.FloatType):
50         return None
51     else:
52         return "Expecting a number, found \"" + str(val) + "\""
53
54 def UnitType(val):
55     if type(val) in (types.IntType, types.LongType, types.FloatType):
56         return None
57     else:
58         return "Expecting a unit, found \"" + str(val) + "\""
59     
60 def ShadowType(val):
61     if type(val) not in (types.TupleType, types.ListType):
62         return "Expecting tuple or list."
63     if len(val) != 3:
64         return "Expecting (xoff, yoff, fill)."
65     return None
66
67 def FormatType(val):
68     if type(val) in (types.StringType, types.FunctionType):
69         return None
70     return "Format must be a string or a function"
71