6 def add_prefix(target):
7 def wrapper(self, *args):
9 return map(lambda x: prefix + x, target(self, *args))
14 def __init__(self, rootdev, ghandler):
19 def ls(self, directory):
20 return self.g.ls(directory)
23 def find(self, directory):
24 return self.g.find(directory)
26 def foreach_file(self, directory, action, **kargs):
28 maxdepth = None if 'maxdepth' not in kargs else kargs['maxdepth']
33 maxdepth = None if maxdepth is None else maxdepth - 1
34 kargs['maxdepth'] = maxdepth
36 exclude = None if 'exclude' not in kargs else kargs['exclude']
37 ftype = None if 'ftype' not in kargs else kargs['ftype']
38 has_ftype = lambda x, y: y is None and True or x['ftyp'] == y
40 for f in self.g.readdir(directory):
41 if f['name'] in ('.', '..'):
44 full_path = "%s/%s" % (directory, f['name'])
46 if exclude and re.match(exclude, full_path):
50 self.foreach_file(full_path, action, **kargs)
52 if has_ftype(f, ftype):
55 def get_metadata(self):
57 meta["OSFAMILY"] = self.g.inspect_get_type(self.root)
58 meta["OS"] = self.g.inspect_get_distro(self.root)
59 meta["description"] = self.g.inspect_get_product_name(self.root)
63 def data_cleanup(self):
64 raise NotImplementedError
66 # vim: set sta sts=4 shiftwidth=4 sw=4 et ai :