Changeset 164
- Timestamp:
- 17.04.2008 02:57:10 (9 months ago)
- Files:
-
- trunk/pycawm/dotdesktop.py (modified) (2 diffs)
- trunk/pycawm/patterns.py (modified) (1 diff)
- trunk/tests/dotdesktop.test (added)
- trunk/tests/patterns.test (modified) (1 diff)
- trunk/tests/test1.desktop (added)
- trunk/tests/test2.desktop (added)
- trunk/tests/test3.desktop (added)
- trunk/tests/test4.desktop (added)
- trunk/tests/test5.deskto (added)
- trunk/tests/test6.desktop (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/pycawm/dotdesktop.py
r163 r164 38 38 raise ImportError('dotdesktop module needs at least Python 2.5!') 39 39 40 from ConfigParser import RawConfigParser40 from ConfigParser import MissingSectionHeaderError, RawConfigParser 41 41 from dircache import listdir 42 42 from operator import itemgetter … … 55 55 return None 56 56 config = RawConfigParser() 57 config.read(filepath) 57 try: 58 config.read(filepath) 59 except MissingSectionHeaderError: 60 return None 58 61 # Type, Name, Exec options are required and Type must be "Application" 59 62 if not (config.has_option('Desktop Entry', 'Type') and trunk/pycawm/patterns.py
r140 r164 114 114 return '%s(%s)' % (self.__class__, repr(self._data)) 115 115 116 def __nonzero__(self): 117 return True if len(self._data) else False 118 119 def __len__(self): 120 return len(self._data) 121 116 122 def __cmp__(self, other): 117 123 if isinstance(other, DictWrapper): trunk/tests/patterns.test
r58 r164 58 58 59 59 >>> if a: print "nonzero!" 60 61 3) The DictWrapper 62 63 >>> from pycawm.patterns import DictWrapper 64 >>> a = DictWrapper() 65 >>> if a: print "nonzero!" 66 >>> len(a) 67 0 68 >>> a.foo 69 Traceback (most recent call last): 70 File "...", line 1, in ... 71 File "...", line ..., in __getattr__ 72 raise AttributeError(attr) 73 AttributeError: foo 74 >>> a.foo = 42 75 >>> a.foo 76 42 77 >>> a['foo'] 78 42 79 >>> a['bar'] = 21 80 >>> a.bar 81 21 82 >>> if a: print "nonzero!" 83 nonzero! 84 >>> len(a) 85 2 86 87 >>> b = DictWrapper() 88 >>> a is b 89 False 90 >>> a == b 91 False 92 >>> b.foo = 42 93 >>> b.bar = 21 94 >>> a is b 95 False 96 >>> a == b 97 True 98 99 >>> c = DictWrapper(recursive=True) 100 >>> if c: print "nonzero!" 101 >>> len(c) 102 0 103 >>> c.foo 104 <class 'pycawm.patterns.DictWrapper'>({}) 105 >>> c.foo == c.bar.foo 106 True 107 >>> c.foo is c.bar.foo 108 False 109 >>> c.baz.foo.bar.foobar.barbaz.marvin 110 <class 'pycawm.patterns.DictWrapper'>({}) 111 >>> c.baz['foo'].bar['foobar'].barbaz['marvin'] = 42 112 >>> c['baz'].foo['bar'].foobar['barbaz'].marvin 113 42 114 >>> if c: print "nonzero!" 115 nonzero! 116 >>> len(c) 117 3 118 119 >>> d = DictWrapper(recursive=True) 120 >>> d.baz.foo.bar.foobar.barbaz.marvin = 42 121 >>> c == d 122 False 123 >>> d.foo 124 <class 'pycawm.patterns.DictWrapper'>({}) 125 >>> d.bar.foo 126 <class 'pycawm.patterns.DictWrapper'>({}) 127 >>> c == d 128 True 129
