Mercurial > python-cmd2
comparison cmd2.py @ 340:43569db3ebdb
detect lists with __reversed__ not __getslice__
author | catherine@Drou |
---|---|
date | Tue, 16 Feb 2010 12:36:14 -0500 |
parents | 6c397f0865c7 |
children | 9e593c480782 |
comparison
equal
deleted
inserted
replaced
339:6c397f0865c7 | 340:43569db3ebdb |
---|---|
304 @classmethod | 304 @classmethod |
305 def to_dict(cls, arg): | 305 def to_dict(cls, arg): |
306 'Generates dictionary from string or list of strings' | 306 'Generates dictionary from string or list of strings' |
307 if hasattr(arg, 'splitlines'): | 307 if hasattr(arg, 'splitlines'): |
308 arg = arg.splitlines() | 308 arg = arg.splitlines() |
309 if hasattr(arg, '__getslice__'): | 309 if hasattr(arg, '__reversed__'): |
310 result = {} | 310 result = {} |
311 for a in arg: | 311 for a in arg: |
312 a = a.strip() | 312 a = a.strip() |
313 if a: | 313 if a: |
314 key_val = a.split(None, 1) | 314 key_val = a.split(None, 1) |