Closed GoogleCodeExporter closed 9 years ago
Instead of bloating the library, I've built in a flexible solution based on the
oncept of functional programming.
To perform a complex filtering you should use callbacks (predicates).
Predicate is a simple function that processes a given value (RarInfo record) and
returns boolean True (ok to extract the file) or False (skip it).
Your problem can be resolved in several ways.
# simpliest way, not very scalable
archive.extract(lambda x:x.filename.endswith('.py') or
x.filename.endswith('.txt'))
# nice way if you care only about extensions (i.e. "file types")
import os.path
archive.extract(lambda x:os.path.splitext(x.filename)[1] in ['txt','py'])
# some powerful functional magic to aggregate several similar predicates
archive.extract(lambda x:any(x.filename.endswith(y) for y in ['.txt','.py']))
Original comment by yk4e...@gmail.com
on 24 Jan 2010 at 9:15
Original issue reported on code.google.com by
tal...@gmail.com
on 21 Jan 2010 at 9:38