Show More
@@ -157,9 +157,18 b' def json(obj):' | |||
|
157 | 157 | else: |
|
158 | 158 | raise TypeError('cannot encode type %s' % obj.__class__.__name__) |
|
159 | 159 | |
|
160 | def stripdir(text): | |
|
161 | '''Treat the text as path and strip a directory level, if possible.''' | |
|
162 | dir = os.path.dirname(text) | |
|
163 | if dir == "": | |
|
164 | return os.path.basename(text) | |
|
165 | else: | |
|
166 | return dir | |
|
167 | ||
|
160 | 168 | filters = { |
|
161 | 169 | "addbreaks": nl2br, |
|
162 | 170 | "basename": os.path.basename, |
|
171 | "stripdir": stripdir, | |
|
163 | 172 | "age": age, |
|
164 | 173 | "date": lambda x: util.datestr(x), |
|
165 | 174 | "domain": domain, |
General Comments 0
You need to be logged in to leave comments.
Login now