comparison python/hgrc.py @ 827:a5a339b7fd82

python 3.5
author Jeff Hammel <k0scist@gmail.com>
date Sun, 19 Feb 2017 17:48:52 -0800
parents bb6e21338c5c
children 34e2b07d8cc7
comparison
equal deleted inserted replaced
826:aa9a3850ed56 827:a5a339b7fd82
167 167
168 # raise errors if encountered 168 # raise errors if encountered
169 if filter(None, errors.values()): 169 if filter(None, errors.values()):
170 for key, value in errors.items(): 170 for key, value in errors.items():
171 if value: 171 if value:
172 print '%s: %s' % (key, ', '.join(value)) 172 print ('%s: %s' % (key, ', '.join(value)))
173 parser.exit(1) 173 parser.exit(1)
174 174
175 # construct ConfigParser objects and 175 # construct ConfigParser objects and
176 # ensure that all the files are parseable 176 # ensure that all the files are parseable
177 config = {} 177 config = {}
184 if 'default' not in actions: 184 if 'default' not in actions:
185 set_default(config[path], path) 185 set_default(config[path], path)
186 186
187 # print the chosen hgrc paths 187 # print the chosen hgrc paths
188 if 'list_hgrc' in actions: 188 if 'list_hgrc' in actions:
189 print '\n'.join(hgrc) 189 print ('\n'.join(hgrc))
190 190
191 # remove from actions list 191 # remove from actions list
192 actions.pop('list_hgrc', None) 192 actions.pop('list_hgrc', None)
193 193
194 # map of actions -> functions; 194 # map of actions -> functions;
227 value = _buffer.getvalue().strip() 227 value = _buffer.getvalue().strip()
228 if len(config) == 1: 228 if len(config) == 1:
229 values = [value] 229 values = [value]
230 else: 230 else:
231 values.append('+++ %s\n%s' % (path, value)) 231 values.append('+++ %s\n%s' % (path, value))
232 print '\n'.join(values) 232 print ('\n'.join(values))
233 233
234 # write .ini files 234 # write .ini files
235 for path, ini in config.items(): 235 for path, ini in config.items():
236 if path in urls: 236 if path in urls:
237 continue 237 continue
238 with file(path, 'w') as f: 238 with open(path, 'w') as f:
239 ini.write(f) 239 ini.write(f)
240 240
241 if __name__ == '__main__': 241 if __name__ == '__main__':
242 main() 242 main()