diff --git a/planet.py b/planet.py index c278c06..881f756 100755 --- a/planet.py +++ b/planet.py @@ -22,6 +22,7 @@ if __name__ == "__main__": verbose = 0 only_if_new = 0 expunge = 0 + debug_splice = 0 for arg in sys.argv[1:]: if arg == "-h" or arg == "--help": @@ -43,6 +44,8 @@ if __name__ == "__main__": only_if_new = 1 elif arg == "-x" or arg == "--expunge": expunge = 1 + elif arg == "-d" or arg == "--debug-splice": + debug_splice = 1 elif arg.startswith("-"): print >>sys.stderr, "Unknown option:", arg sys.exit(1) @@ -65,6 +68,20 @@ if __name__ == "__main__": from planet import splice doc = splice.splice() + + if debug_splice: + from planet import logger + logger.info('writing debug.atom') + debug=open('debug.atom','w') + try: + from lxml import etree + from StringIO import StringIO + tree = etree.tostring(etree.parse(StringIO(doc.toxml()))) + debug.write(etree.tostring(tree, pretty_print=True)) + except: + debug.write(doc.toprettyxml(indent=' ', encoding='utf-8')) + debug.close + splice.apply(doc.toxml('utf-8')) if expunge: