Show More
@@ -157,9 +157,18 b' def json(obj):' | |||||
157 | else: |
|
157 | else: | |
158 | raise TypeError('cannot encode type %s' % obj.__class__.__name__) |
|
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 | filters = { |
|
168 | filters = { | |
161 | "addbreaks": nl2br, |
|
169 | "addbreaks": nl2br, | |
162 | "basename": os.path.basename, |
|
170 | "basename": os.path.basename, | |
|
171 | "stripdir": stripdir, | |||
163 | "age": age, |
|
172 | "age": age, | |
164 | "date": lambda x: util.datestr(x), |
|
173 | "date": lambda x: util.datestr(x), | |
165 | "domain": domain, |
|
174 | "domain": domain, |
General Comments 0
You need to be logged in to leave comments.
Login now