|
|
|
@ -4,6 +4,7 @@ import shutil
|
|
|
|
|
import hashlib
|
|
|
|
|
from pprint import pprint
|
|
|
|
|
from stat import ST_MODE
|
|
|
|
|
from typing import Optional, List
|
|
|
|
|
from calculate.templates.template_processor import DirectoryProcessor,\
|
|
|
|
|
TemplateWrapper
|
|
|
|
|
from calculate.utils.package import PackageAtomName, Version, Package,\
|
|
|
|
@ -90,15 +91,29 @@ datavars = Variables({'install': install,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_tree(dir_path: str, indent: int = 0,
|
|
|
|
|
files_only: bool = False) -> None:
|
|
|
|
|
test_names: Optional[List[str]] = None) -> None:
|
|
|
|
|
last_names = dict()
|
|
|
|
|
if test_names is not None:
|
|
|
|
|
for name in test_names:
|
|
|
|
|
last_names[name] = 0
|
|
|
|
|
|
|
|
|
|
print('{}{}/'.format(' ' * 4 * indent, os.path.basename(dir_path)))
|
|
|
|
|
indent += 1
|
|
|
|
|
for node in os.scandir(dir_path):
|
|
|
|
|
if node.is_dir():
|
|
|
|
|
if not files_only:
|
|
|
|
|
show_tree(node.path, indent=indent)
|
|
|
|
|
show_tree(node.path, indent=indent)
|
|
|
|
|
else:
|
|
|
|
|
print('{}{}'.format(' ' * 4 * indent, node.name))
|
|
|
|
|
print('{}{}'.format(' ' * indent, node.name))
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
if last_names:
|
|
|
|
|
for name in test_names:
|
|
|
|
|
if node.name.startswith(name):
|
|
|
|
|
number = int(node.name[len(name) + 1:])
|
|
|
|
|
if number > last_names[name]:
|
|
|
|
|
last_names[name] = number
|
|
|
|
|
break
|
|
|
|
|
return [f"{name}_{number}" for name, number in last_names.items()]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.directory_processor
|
|
|
|
@ -1820,9 +1835,27 @@ class TestDirectoryProcessor:
|
|
|
|
|
assert os.path.exists(join_paths(CHROOT_PATH, '/etc/file_21'))
|
|
|
|
|
assert os.path.exists(join_paths(CHROOT_PATH, '/etc/file_22'))
|
|
|
|
|
|
|
|
|
|
def test_autoupdate_for_symlink(self):
|
|
|
|
|
datavars.main['cl_template_path'] = os.path.join(CHROOT_PATH,
|
|
|
|
|
'templates_63')
|
|
|
|
|
|
|
|
|
|
directory_processor = DirectoryProcessor('install',
|
|
|
|
|
datavars_module=datavars)
|
|
|
|
|
directory_processor.process_template_directories()
|
|
|
|
|
assert os.path.lexists(join_paths(CHROOT_PATH, '/etc/link_4'))
|
|
|
|
|
assert os.path.lexists(join_paths(CHROOT_PATH,
|
|
|
|
|
'/etc/._cfg0000_link_5'))
|
|
|
|
|
|
|
|
|
|
def test_view_tree(self):
|
|
|
|
|
list_path = join_paths(CHROOT_PATH, '/etc')
|
|
|
|
|
show_tree(list_path)
|
|
|
|
|
test_names = ['dir', 'file', 'link']
|
|
|
|
|
last_names = show_tree(list_path,
|
|
|
|
|
test_names=test_names)
|
|
|
|
|
if last_names:
|
|
|
|
|
print('last names:')
|
|
|
|
|
print("\n".join(
|
|
|
|
|
[f"{name}: {last}" for name, last in zip(test_names,
|
|
|
|
|
last_names)]))
|
|
|
|
|
assert True
|
|
|
|
|
|
|
|
|
|
def test_for_removing_testfile(self):
|
|
|
|
|