- commit
- 6a5b8f5bbbb150ce3b6bf68236f5c540b2242ce9
- parent
- e820676a8df7d07f7bcc31385ec39a074b575e72
- Author
- Tobias Bengfort <tobias.bengfort@gmx.net>
- Date
- 2015-05-08 13:21
py3 compatibility
Diffstat
| M | cctool.py | 15 | +++++++++++---- |
1 files changed, 11 insertions, 4 deletions
diff --git a/cctool.py b/cctool.py
@@ -57,6 +57,13 @@ except ImportError as err: 57 57 NOTSET = object() 58 58 59 59 -1 60 def _str(x): -1 61 try: -1 62 return unicode(x) -1 63 except NameError: -1 64 return str(x) -1 65 -1 66 60 67 def formats(): 61 68 informats = { 62 69 'abook': ABook, @@ -293,7 +300,7 @@ class ABook(Format): 293 300 cp = ConfigParser() 294 301 i = 0 295 302 for item in data:296 -1 section = str(i)-1 303 section = _str(i) 297 304 cp.add_section(section) 298 305 for key in item: 299 306 if key == 'bday': @@ -337,7 +344,7 @@ class LDIF(Format): 337 344 except ValueError as err: 338 345 log.warning("ValueError after reading %i records: %s", 339 346 parser.records_read, err)340 -1 for entry in parser.entries.itervalues():-1 347 for entry in parser.entries.values(): 341 348 yield MultiDict(entry) 342 349 343 350 @classmethod @@ -381,9 +388,9 @@ def parse_args(argv=None): 381 388 informats, outformats = formats() 382 389 383 390 parser = argparse.ArgumentParser(description=__doc__)384 -1 parser.add_argument('--from', '-f', choices=informats.keys(),-1 391 parser.add_argument('--from', '-f', choices=list(informats.keys()), 385 392 metavar='FORMAT', dest='informat')386 -1 parser.add_argument('--to', '-t', choices=outformats.keys(),-1 393 parser.add_argument('--to', '-t', choices=list(outformats.keys()), 387 394 metavar='FORMAT', dest='outformat') 388 395 parser.add_argument('input', nargs='*', default=['-'], metavar='FILE') 389 396 parser.add_argument('--output', '-o', metavar='FILENAME')