summaryrefslogtreecommitdiffstats
path: root/func/yaml/ordered_dict.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2008-07-07 17:06:34 -0400
committerMichael DeHaan <mdehaan@redhat.com>2008-07-07 17:06:34 -0400
commitcda37e78dc61e8993e5868f3bbac173a69c5afd3 (patch)
tree56679db9fcfc1186753883676656ae1723e8dc63 /func/yaml/ordered_dict.py
parent1d774702a1972f7f50b77a07553e59eeaebf0781 (diff)
downloadfunc-cda37e78dc61e8993e5868f3bbac173a69c5afd3.tar.gz
func-cda37e78dc61e8993e5868f3bbac173a69c5afd3.tar.xz
func-cda37e78dc61e8993e5868f3bbac173a69c5afd3.zip
Including yaml parser for use by Func-transmit, as we want to make sure we have
one around that is compatible with older Python, and also tweaked not to do crayz things with stream layout.
Diffstat (limited to 'func/yaml/ordered_dict.py')
-rw-r--r--func/yaml/ordered_dict.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/func/yaml/ordered_dict.py b/func/yaml/ordered_dict.py
new file mode 100644
index 0000000..5bc2e3e
--- /dev/null
+++ b/func/yaml/ordered_dict.py
@@ -0,0 +1,38 @@
+"""
+pyyaml legacy
+Copyright (c) 2001 Steve Howell and Friends; All Rights Reserved
+(see open source license information in docs/ directory)
+"""
+
+
+# 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
+
+
+
+