[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 class T(object):
16     def __init__(self, *objs):
17         self.__objs = list(objs)
18     def add(self, *objs):
19         self.__objs.extend(objs)
20     def add_objects(self, objs):
21         self.__objs.extend(objs)
22     def iterate(self):
23         return Iterator(self)
24     def list(self):
25         return self.__objs
26     def __getitem__(self, idx):
27         return self.__objs[idx]
28     def nth(self, idx):
29         return self.__objs[idx]
30     
31 class Iterator(object):
32     def __init__(self, set_):
33         self.__set = set_
34         self.__idx = 0
35     def reset(self):
36         self.__idx = 0
37     def next(self):
38         val = self.__set.nth(self.__idx)
39         self.__idx += 1
40         if self.__idx >= len(self.__set.list()):
41             self.__idx = 0
42         return val
43
44