2 # GObject-Introspection - a framework for introspecting GObject libraries
3 # Copyright (C) 2008 Johan Dahlin
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the
17 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 # Boston, MA 02111-1307, USA.
21 """odict - an ordered dictionary"""
24 # Starting with Python 2.7 we can use collections.OrderedDict
25 from collections import OrderedDict as odict
27 # But we still support Python 2.5 and 2.6
28 from UserDict import DictMixin
31 class odict(DictMixin):
37 def __setitem__(self, key, value):
38 if key not in self._items:
39 self._keys.append(key)
40 self._items[key] = value
42 def __getitem__(self, key):
43 return self._items[key]
45 def __delitem__(self, key):
47 self._keys.remove(key)