comparison martini/config.py @ 15:5de4f7d434de

py3
author Jeff Hammel <k0scist@gmail.com>
date Mon, 20 Feb 2017 14:50:23 -0800
parents 904bb82c3308
children 8ae3a7fd466a
comparison
equal deleted inserted replaced
14:904bb82c3308 15:5de4f7d434de
128 sections = self.sections() 128 sections = self.sections()
129 if sorted: 129 if sorted:
130 sections.sort() 130 sections.sort()
131 131
132 for section in sections: 132 for section in sections:
133 print >> fp, '[%s]' % section 133 fp.write('[%s]\n' % section)
134 options = self.options(section) 134 options = self.options(section)
135 if sorted: 135 if sorted:
136 options.sort() 136 options.sort()
137 for option in options: 137 for option in options:
138 print >> fp, "%s = %s" % (option, self.get(section, option, raw=raw, vars=vars)) 138 fp.write("%s = %s\n" % (option, self.get(section, option, raw=raw, vars=vars)))
139 if section != sections[-1]: 139 if section != sections[-1]:
140 print >> fp 140 fp.write('\n')
141 141
142 if __name__ == '__main__': 142 if __name__ == '__main__':
143 import sys 143 import sys
144 from optparse import OptionParser 144 from optparse import OptionParser
145 parser = OptionParser() 145 parser = OptionParser()
148 munger = ConfigMunger() 148 munger = ConfigMunger()
149 options, args = parser.parse_args() 149 options, args = parser.parse_args()
150 munger.read(*args) 150 munger.read(*args)
151 if options.missing: 151 if options.missing:
152 for missing in munger.missing(): 152 for missing in munger.missing():
153 print missing 153 print(missing)
154 else: 154 else:
155 munger.write(sys.stdout) 155 munger.write(sys.stdout)