quarta-feira, 18 de agosto de 2010

Reading QuickFix Cfg file using python APIs.

Achei bem simples ( lembrando que estou aprendendo python ), pretendo automatizar, mais meus testes ;)

# Clebson Derivan ( cderivan@gmail.com )

import sys, os, ConfigParser
if __name__ == "__main__":

file
= sys.argv[1:]

print """Clebson Derivan ( cderivan@gmail.com )
cfgReader - open QuickFix Cfg file using python APIs.
"""

if file == []:
print "please provide QuickFix config file name:", "\r\n"
print " cfgReader.py example.cfg"
sys.exit(0)

print "Opening file:", file

config
= ConfigParser.RawConfigParser()
filesread
= config.read( os.path.expanduser( file ) )
if not filesread:
print "cant open file:", file, "\r\n"
sys.exit(0)

#dump file content
for section in config.sections():
print "section:", section
for i in config.items(section):
print i[0], " = ", i[1]

Nenhum comentário:

Postar um comentário