~openerp-groupes/openobject-server/6.0-fix-setup-windows

« back to all changes in this revision

Viewing changes to bin/pychart/pychart_types.py

  • Committer: pinky
  • Date: 2006-12-07 13:41:40 UTC
  • Revision ID: pinky-3f10ee12cea3c4c75cef44ab04ad33ef47432907
New trunk

Show diffs side-by-side

added added

removed removed

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