1 # Clebson Derivan ( cderivan@gmail.com ) 2 3 import sys, os, ConfigParser 4 if __name__ == "__main__": 5 6 file = sys.argv[1:] 7 8 print """Clebson Derivan ( cderivan@gmail.com ) 9 cfgReader - open QuickFix Cfg file using python APIs. 10 """ 11 12 if file == []: 13 print "please provide QuickFix config file name:", "\r\n" 14 print " cfgReader.py example.cfg" 15 sys.exit(0) 16 17 print "Opening file:", file 18 19 config = ConfigParser.RawConfigParser() 20 filesread = config.read( os.path.expanduser( file ) ) 21 if not filesread: 22 print "cant open file:", file, "\r\n" 23 sys.exit(0) 24 25 #dump file content 26 for section in config.sections(): 27 print "section:", section 28 for i in config.items(section): 29 print i[0], " = ", i[1]