# 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
# 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)
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:
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:
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')
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)