Beispiel #1
0
 def rec_walk(root):
     """
     Recursively list subdirectories and filenames from the root.
     :param root: unicode  the root path
     :type root: unicode
     """
     dirnames = []
     filenames = []
     for name in pkg_resources.resource_listdir(module_name, root):
         fullname = root + '/' + name
         isdir = pkg_resources.resource_isdir(module_name, fullname)
         if isdir:
             dirnames.append(name)
             if not topdown:
                 # noinspection PyTypeChecker
                 rec_walk(fullname)
         else:
             filenames.append(name)
     yield root, dirnames, filenames
     if topdown:
         for name in dirnames:
             # noinspection PyTypeChecker
             for values in rec_walk(root + '/' + name):
                 yield values
Beispiel #2
0
 def run(self):
     module = self.__class__.__module__
     if pkg_resources.resource_isdir(module, 'templates/%s' % self.name):
         self.write_files(module, 'templates/%s' % self.name, context=self.get_template_values(), destination_root='/', dry_run=self.dry_run)