etisserant@400: #! /usr/bin/env python etisserant@400: # etisserant@400: # -*- coding: iso-8859-1 -*- etisserant@400: # etisserant@400: # etisserant@400: # FILE: EDS2CSV.py etisserant@400: # BEGIN: Nov 30,2007 etisserant@400: # AUTHOR: Giuseppe Massimo Bertani etisserant@400: # EMAIL gmbertani@users.sourceforge.net etisserant@400: # etisserant@400: # This program is free software; you can redistribute it and/or modify etisserant@400: # it under the terms of the GNU General Public License as published by etisserant@400: # the Free Software Foundation; either version 2 of the License, or etisserant@400: # (at your option) any later version. etisserant@400: # etisserant@400: # Coding style params: etisserant@400: # skips=4 etisserant@400: # are replaced with blanks etisserant@400: # etisserant@400: # etisserant@400: etisserant@400: import sys etisserant@400: import os etisserant@400: import ConfigParser as cp etisserant@400: etisserant@400: if (len(sys.argv) != 2): etisserant@400: print "Usage:" etisserant@400: print etisserant@400: print "EDS2CSV.py " etisserant@400: print etisserant@400: print etisserant@400: sys.exit(0) etisserant@400: etisserant@400: EDSname = os.path.abspath( os.path.dirname(sys.argv[1]) ) + '/' + sys.argv[1] etisserant@400: etisserant@400: if (os.path.exists(EDSname) is not True): etisserant@400: print etisserant@400: print "Input file ",EDS2CSV," not found." etisserant@400: print etisserant@400: print etisserant@400: sys.exit(0) etisserant@400: etisserant@400: eds = cp.ConfigParser() etisserant@400: eds.read(EDSname) etisserant@400: etisserant@400: ssorted = sorted(eds.sections()) etisserant@400: etisserant@400: # dump entire EDS file to stdout in CSV format comma separated etisserant@400: print "Object Dictionary,",sys.argv[1] etisserant@400: print etisserant@400: for section in ssorted: etisserant@400: print section etisserant@400: print ",", etisserant@400: osorted = sorted(eds.options(section)) etisserant@400: for option in osorted: etisserant@400: print option, ",", etisserant@400: print etisserant@400: print ",", etisserant@400: for option in osorted: etisserant@400: print eds.get(section, option), ",", etisserant@400: print etisserant@400: print etisserant@400: