Commit 9b282143 authored by Marc-André Lureau's avatar Marc-André Lureau 🎺 Committed by Sebastian Dröge

scangobj-merge.py: Don't depend on Twisted just for the OrderedDict but...

scangobj-merge.py: Don't depend on Twisted just for the OrderedDict but implement our own ordered dictionary class. F...

Original commit message from CVS:
Patch by: Marc-Andre Lureau <marcandre dot lureau at gmail dot com>
* scangobj-merge.py:
Don't depend on Twisted just for the OrderedDict but implement our
own ordered dictionary class. Fixes bug #531577.
parent f6fc3fa7
2008-05-06 Sebastian Dröge <slomo@circular-chaos.org>
Patch by: Marc-Andre Lureau <marcandre dot lureau at gmail dot com>
* scangobj-merge.py:
Don't depend on Twisted just for the OrderedDict but implement our
own ordered dictionary class. Fixes bug #531577.
2008-04-23 Edward Hervey <edward.hervey@collabora.co.uk>
* gst.supp:
......
......@@ -6,18 +6,70 @@
parse, update and write .signals and .args files
"""
from twisted.python import util
import sys
import os
def debug(*args):
pass
# OrderedDict class based on
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/107747
# Licensed under the Python License
class OrderedDict(dict):
def __init__(self, dict = None):
self._keys = []
dict.__init__(self, dict)
def __delitem__(self, key):
dict.__delitem__(self, key)
self._keys.remove(key)
def __setitem__(self, key, item):
dict.__setitem__(self, key, item)
if key not in self._keys: self._keys.append(key)
def clear(self):
dict.clear(self)
self._keys = []
def copy(self):
dict = dict.copy(self)
dict._keys = self._keys[:]
return dict
def items(self):
return zip(self._keys, self.values())
def keys(self):
return self._keys
def popitem(self):
try:
key = self._keys[-1]
except IndexError:
raise KeyError('dictionary is empty')
val = self[key]
del self[key]
return (key, val)
def setdefault(self, key, failobj = None):
dict.setdefault(self, key, failobj)
if key not in self._keys: self._keys.append(key)
def update(self, dict):
dict.update(self, dict)
for key in dict.keys():
if key not in self._keys: self._keys.append(key)
def values(self):
return map(self.get, self._keys)
class Object:
def __init__(self, name):
self._signals = util.OrderedDict()
self._args = util.OrderedDict()
self._signals = OrderedDict()
self._args = OrderedDict()
self.name = name
def __repr__(self):
......@@ -81,7 +133,7 @@ class GDoc:
class Signals(GDoc):
def __init__(self):
self._objects = util.OrderedDict()
self._objects = OrderedDict()
def load_data(self, data):
"""
......@@ -138,7 +190,7 @@ class Signals(GDoc):
class Args(GDoc):
def __init__(self):
self._objects = util.OrderedDict()
self._objects = OrderedDict()
def load_data(self, data):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment