Mercurial > p > roundup > code
annotate roundup/support.py @ 3069:4ef775d2c8d1
handle NotModified for non-static files (patch [SF#1095790])
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 05 Jan 2005 22:00:39 +0000 |
| parents | 293a17149765 |
| children | a2ae11191968 |
| rev | line source |
|---|---|
| 2984 | 1 """Implements various support classes and functions used in a number of |
| 2 places in Roundup code. | |
| 3 """ | |
| 4 | |
| 5 __docformat__ = 'restructuredtext' | |
| 6 | |
|
3019
293a17149765
First cut at exporting/importing file content from and to the hyperdb.
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
2984
diff
changeset
|
7 import os |
|
293a17149765
First cut at exporting/importing file content from and to the hyperdb.
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
2984
diff
changeset
|
8 |
| 2984 | 9 class TruthDict: |
| 10 '''Returns True for valid keys, False for others. | |
| 11 ''' | |
| 12 def __init__(self, keys): | |
| 13 if keys: | |
| 14 self.keys = {} | |
| 15 for col in keys: | |
| 16 self.keys[col] = 1 | |
| 17 else: | |
| 18 self.__getitem__ = lambda name: 1 | |
| 19 | |
| 20 def __getitem__(self, name): | |
| 21 return self.keys.has_key(name) | |
| 22 | |
|
3019
293a17149765
First cut at exporting/importing file content from and to the hyperdb.
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
2984
diff
changeset
|
23 def ensureParentsExist(dest): |
|
293a17149765
First cut at exporting/importing file content from and to the hyperdb.
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
2984
diff
changeset
|
24 if not os.path.exists(os.path.dirname(dest)): |
|
293a17149765
First cut at exporting/importing file content from and to the hyperdb.
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
2984
diff
changeset
|
25 os.makedirs(os.path.dirname(dest)) |
|
293a17149765
First cut at exporting/importing file content from and to the hyperdb.
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
2984
diff
changeset
|
26 |
| 2984 | 27 # vim: set et sts=4 sw=4 : |
