tizen 2.0 init
[framework/multimedia/gst-plugins-good0.10.git] / common / scangobj-merge.py
index 5e84235..9a1cac9 100755 (executable)
@@ -3,7 +3,7 @@
 # vi:si:et:sw=4:sts=4:ts=4
 
 """
-parse, update and write .signals and .args files
+parse, merge and write gstdoc-scanobj files
 """
 
 import sys
@@ -16,9 +16,9 @@ def debug(*args):
 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/107747
 # Licensed under the Python License
 class OrderedDict(dict):
-    def __init__(self, dict = None):
+    def __init__(self):
         self._keys = []
-        dict.__init__(self, dict)
+        dict.__init__(self)
 
     def __delitem__(self, key):
         dict.__delitem__(self, key)
@@ -110,8 +110,7 @@ class GDoc:
 
     def save_file(self, filename, backup=False):
         """
-        Save the signals information to the given .signals file if the
-        file content changed.
+        Save the information to the given file if the file content changed.
         """
         olddata = None
         try:
@@ -256,6 +255,25 @@ class Args(GDoc):
 
         return "\n".join(lines) + '\n'
 
+class SingleLine(GDoc):
+    def __init__(self):
+        self._objects = []
+
+    def load_data(self, data):
+        """
+        Load the .interfaces/.prerequisites lines, merge duplicates
+        """
+        # split data on '\n'
+        lines = data.splitlines();
+        # merge them into self._objects
+        for line in lines:
+            if line not in self._objects:
+                self._objects.append(line)
+
+    def get_data(self):
+        lines = sorted(self._objects)
+        return "\n".join(lines) + '\n'
+
 def main(argv):
     modulename = None
     try:
@@ -264,7 +282,6 @@ def main(argv):
         sys.stderr.write('Please provide a documentation module name\n')
         sys.exit(1)
 
-    print "Merging scangobj output for %s" % modulename
     signals = Signals()
     signals.load_file(modulename + '.signals')
     signals.load_file(modulename + '.signals.new')
@@ -277,4 +294,16 @@ def main(argv):
     args.save_file(modulename + '.args', backup=True)
     os.unlink(modulename + '.args.new')
 
+    ifaces = SingleLine()
+    ifaces.load_file(modulename + '.interfaces')
+    ifaces.load_file(modulename + '.interfaces.new')
+    ifaces.save_file(modulename + '.interfaces', backup=True)
+    os.unlink(modulename + '.interfaces.new')
+
+    prereq = SingleLine()
+    prereq.load_file(modulename + '.prerequisites')
+    prereq.load_file(modulename + '.prerequisites.new')
+    prereq.save_file(modulename + '.prerequisites', backup=True)
+    os.unlink(modulename + '.prerequisites.new')
+
 main(sys.argv)