Show More
@@ -313,11 +313,34 b' def size(mctx, x):' | |||||
313 |
|
313 | |||
314 | return [f for f in mctx.subset if m(mctx.ctx[f].size())] |
|
314 | return [f for f in mctx.subset if m(mctx.ctx[f].size())] | |
315 |
|
315 | |||
|
316 | def encoding(mctx, x): | |||
|
317 | """``encoding(name)`` | |||
|
318 | File can be successfully decoded with the given character | |||
|
319 | encoding. May not be useful for encodings other than ASCII and | |||
|
320 | UTF-8. | |||
|
321 | """ | |||
|
322 | ||||
|
323 | enc = getstring(x, _("encoding requires an encoding name")) | |||
|
324 | ||||
|
325 | s = [] | |||
|
326 | for f in mctx.subset: | |||
|
327 | d = mctx.ctx[f].data() | |||
|
328 | try: | |||
|
329 | d.decode(enc) | |||
|
330 | except LookupError: | |||
|
331 | raise util.Abort(_("unknown encoding '%s'") % enc) | |||
|
332 | except UnicodeDecodeError: | |||
|
333 | continue | |||
|
334 | s.append(f) | |||
|
335 | ||||
|
336 | return s | |||
|
337 | ||||
316 | symbols = { |
|
338 | symbols = { | |
317 | 'added': added, |
|
339 | 'added': added, | |
318 | 'binary': binary, |
|
340 | 'binary': binary, | |
319 | 'clean': clean, |
|
341 | 'clean': clean, | |
320 | 'deleted': deleted, |
|
342 | 'deleted': deleted, | |
|
343 | 'encoding': encoding, | |||
321 | 'exec': exec_, |
|
344 | 'exec': exec_, | |
322 | 'grep': grep, |
|
345 | 'grep': grep, | |
323 | 'ignored': ignored, |
|
346 | 'ignored': ignored, |
General Comments 0
You need to be logged in to leave comments.
Login now