diff options
author | Michael DeHaan <mdehaan@redhat.com> | 2006-06-28 16:57:49 -0400 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2006-06-28 16:57:49 -0400 |
commit | 98bdc7c86a28eafbab15061e9a5d0fd4f5cdace1 (patch) | |
tree | 12bc44a95469ee2d75f590c1f637ff12d80d2347 /cobbler/yaml/ordered_dict.py | |
parent | 662c68e18943d913b503ba86758d91c27f92be98 (diff) | |
download | third_party-cobbler-98bdc7c86a28eafbab15061e9a5d0fd4f5cdace1.tar.gz third_party-cobbler-98bdc7c86a28eafbab15061e9a5d0fd4f5cdace1.tar.xz third_party-cobbler-98bdc7c86a28eafbab15061e9a5d0fd4f5cdace1.zip |
Make cobbler use the Howell-Evans YAML parser now, so RHEL4 support
will be possible (Syck needs Python 2.4).
Diffstat (limited to 'cobbler/yaml/ordered_dict.py')
-rw-r--r-- | cobbler/yaml/ordered_dict.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/cobbler/yaml/ordered_dict.py b/cobbler/yaml/ordered_dict.py new file mode 100644 index 0000000..32dc9b4 --- /dev/null +++ b/cobbler/yaml/ordered_dict.py @@ -0,0 +1,31 @@ +# This is extremely crude implementation of an OrderedDict. +# If you know of a better implementation, please send it to +# the author Steve Howell. You can find my email via +# the YAML mailing list or wiki. + +class OrderedDict(dict): + def __init__(self): + self._keys = [] + + def __setitem__(self, key, val): + self._keys.append(key) + dict.__setitem__(self, key, val) + + def keys(self): + return self._keys + + def items(self): + return [(key, self[key]) for key in self._keys] + +if __name__ == '__main__': + data = OrderedDict() + data['z'] = 26 + data['m'] = 13 + data['a'] = 1 + for key in data.keys(): + print "The value for %s is %s" % (key, data[key]) + print data + + + + |