Пример #1
0
 async def render_tree(self, tree_path: str) -> None:
     await asyncio.gather(
         *[
             self.render_file(file_path)
             async for file_path in iterfiles(tree_path)
             if file_path.endswith('.j2')
         ], )
Пример #2
0
 def test_iterfiles(self):
     with TemporaryDirectory() as path:
         subdirpath = join(path, 'subdir')
         mkdir(subdirpath)
         open(join(path, 'rootfile'), 'a').close()
         open(join(path, '.hiddenrootfile'), 'a').close()
         open(join(subdirpath, 'subdirfile'), 'a').close()
         actual = [
             actualpath[len(path) + 1:] for actualpath in iterfiles(path)
         ]
     expected = [
         '.hiddenrootfile',
         'rootfile',
         'subdir/subdirfile',
     ]
     self.assertCountEqual(expected, actual)
Пример #3
0
 async def test_iterfiles(self):
     with TemporaryDirectory() as working_directory_path:
         working_subdirectory_path = path.join(working_directory_path,
                                               'subdir')
         mkdir(working_subdirectory_path)
         open(path.join(working_directory_path, 'rootfile'), 'a').close()
         open(path.join(working_directory_path, '.hiddenrootfile'),
              'a').close()
         open(path.join(working_subdirectory_path, 'subdirfile'),
              'a').close()
         actual = [
             actualpath[len(working_directory_path) + 1:]
             async for actualpath in iterfiles(working_directory_path)
         ]
     expected = [
         '.hiddenrootfile',
         'rootfile',
         path.join('subdir', 'subdirfile'),
     ]
     self.assertCountEqual(expected, actual)
Пример #4
0
def render_tree(path: str,
                environment: Environment,
                www_directory_path: str = None) -> None:
    for file_source_path in iterfiles(path):
        if file_source_path.endswith('.j2'):
            render_file(file_source_path, environment, www_directory_path)
Пример #5
0
 async def test_iterfiles(self):
     with TemporaryDirectory() as working_directory_path:
         working_subdirectory_path = Path(working_directory_path) / 'subdir'
         working_subdirectory_path.mkdir()
         open(Path(working_directory_path) / 'rootfile', 'a').close()
         open(Path(working_directory_path) / '.hiddenrootfile', 'a').close()
         open(Path(working_subdirectory_path) / 'subdirfile', 'a').close()
         actual = [str(actualpath)[len(working_directory_path) + 1:] async for actualpath in iterfiles(working_directory_path)]
     expected = [
         '.hiddenrootfile',
         'rootfile',
         str(Path('subdir') / 'subdirfile'),
     ]
     self.assertCountEqual(expected, actual)
Пример #6
0
def render_tree(path: str,
                environment: Environment,
                configuration: Optional[Configuration] = None) -> None:
    for file_source_path in iterfiles(path):
        if file_source_path.endswith('.j2'):
            render_file(file_source_path, environment, configuration)