diff --git a/calculate/templates/format/base_format.py b/calculate/templates/format/base_format.py index ecd585e..ba249cc 100644 --- a/calculate/templates/format/base_format.py +++ b/calculate/templates/format/base_format.py @@ -366,11 +366,9 @@ class Format: if check_shebang: # Удаление #! - print("FIND SHEBANG") shebang_regex = re.compile(self.SHEBANG_PATTERN) shebang_result = shebang_regex.search(input_text) if shebang_result is not None: - print("SHEBANG WAS FOUND") shebang = shebang_result.groupdict()['shebang'] input_text = shebang_regex.sub("", input_text) else: diff --git a/calculate/templates/template_processor.py b/calculate/templates/template_processor.py index 3bec3db..5d17fa4 100644 --- a/calculate/templates/template_processor.py +++ b/calculate/templates/template_processor.py @@ -524,7 +524,6 @@ class TemplateWrapper: self.contents_matching = (self.parameters.autoupdate or self.parameters.force) - print(f'contents_matching: {self.contents_matching}') if not self.protected: self.contents_matching = True diff --git a/calculate/utils/package.py b/calculate/utils/package.py index f8829f9..3e3aa83 100644 --- a/calculate/utils/package.py +++ b/calculate/utils/package.py @@ -587,10 +587,12 @@ class PackageAtomParser: '''Метод для разбора значения package, после разбора инициирует проверку полученных значений. Возвращает объект PackageAtomName.''' self.package_atom = package_atom + print(f'value: {package_atom}') if isinstance(package_atom, str): atom_dictionary = self.parse_atom_name(package_atom) atom_dictionary['package_atom'] = package_atom + print(f'atom_dict: {atom_dictionary}') elif isinstance(package_atom, dict): atom_dictionary = package_atom if 'package_atom' not in atom_dictionary: @@ -615,10 +617,11 @@ class PackageAtomParser: '''Метод для проверки существования пакета. Существование пакета определяется наличием соответствующего CONTENTS файла.''' # Используем glob-паттерн для поиска. - glob_result = glob.glob(r'{0}/{1}/{2}*/CONTENTS'.format( + glob_pattern = r'{0}/{1}/{2}-[0-9]*/CONTENTS'.format( self.pkg_path, atom_dictionary['category'], - atom_dictionary['name'])) + atom_dictionary['name']) + glob_result = glob.glob(glob_pattern) if not glob_result: # Если ничего не нашлось. diff --git a/tests/templates/test_directory_processor.py b/tests/templates/test_directory_processor.py index 7bfe3e4..87e5bb0 100644 --- a/tests/templates/test_directory_processor.py +++ b/tests/templates/test_directory_processor.py @@ -8,7 +8,8 @@ from typing import Optional, List from calculate.templates.template_processor import DirectoryProcessor,\ TemplateWrapper from calculate.utils.package import PackageAtomName, Version, Package,\ - NonePackage, PackageCreator + NonePackage, PackageCreator,\ + PackageAtomParser from calculate.utils.files import join_paths from calculate.utils.io_module import IOModule from calculate.templates.template_engine import Variables @@ -91,7 +92,8 @@ datavars = Variables({'install': install, def show_tree(dir_path: str, indent: int = 0, - test_names: Optional[List[str]] = None) -> None: + test_names: Optional[List[str]] = None, + check_cfg: bool = False) -> None: last_names = dict() if test_names is not None: for name in test_names: @@ -107,9 +109,12 @@ def show_tree(dir_path: str, indent: int = 0, pass if last_names: + node_name = node.name + if node_name.startswith("._cfg") and check_cfg: + node_name = node.name[len("._cfg0000_"):] for name in test_names: - if node.name.startswith(name): - number = int(node.name[len(name) + 1:]) + if node_name.startswith(name): + number = int(node_name[len(name) + 1:]) if number > last_names[name]: last_names[name] = number break @@ -1846,11 +1851,30 @@ class TestDirectoryProcessor: assert os.path.lexists(join_paths(CHROOT_PATH, '/etc/._cfg0000_link_5')) + def test_for_debug_packages_error(self): + datavars.main['cl_template_path'] = os.path.join(CHROOT_PATH, + 'templates_64') + + directory_processor = DirectoryProcessor('install', + datavars_module=datavars) + directory_processor.process_template_directories() + + atom_parser = PackageAtomParser(chroot_path=CHROOT_PATH) + vim_pkg = Package( + atom_parser.parse_package_parameter(">app-editors/vim-8.0"), + chroot_path=CHROOT_PATH) + vim_core_pkg = Package( + atom_parser.parse_package_parameter("app-editors/vim-core"), + chroot_path=CHROOT_PATH) + assert '/etc/file_26' in vim_pkg + assert '/etc/file_26' not in vim_core_pkg + def test_view_tree(self): list_path = join_paths(CHROOT_PATH, '/etc') test_names = ['dir', 'file', 'link'] last_names = show_tree(list_path, - test_names=test_names) + test_names=test_names, + check_cfg=True) if last_names: print('last names:') print("\n".join( diff --git a/tests/templates/testfiles/test_dir_processor_root/etc.backup/file_26 b/tests/templates/testfiles/test_dir_processor_root/etc.backup/file_26 new file mode 100644 index 0000000..c25f317 --- /dev/null +++ b/tests/templates/testfiles/test_dir_processor_root/etc.backup/file_26 @@ -0,0 +1 @@ +salem -- we make it good diff --git a/tests/templates/testfiles/test_dir_processor_root/templates_48/install/dir_66/.calculate_directory b/tests/templates/testfiles/test_dir_processor_root/templates_48/install/dir_66/.calculate_directory index e6945f5..86e1540 100644 --- a/tests/templates/testfiles/test_dir_processor_root/templates_48/install/dir_66/.calculate_directory +++ b/tests/templates/testfiles/test_dir_processor_root/templates_48/install/dir_66/.calculate_directory @@ -1,2 +1,2 @@ {% calculate package = "test-category/test-package", -merge = "test-category/new/package" %} +merge = "test-category/new-package" %} diff --git a/tests/templates/testfiles/test_dir_processor_root/templates_64/install/.calculate_directory b/tests/templates/testfiles/test_dir_processor_root/templates_64/install/.calculate_directory new file mode 100644 index 0000000..6b4ced9 --- /dev/null +++ b/tests/templates/testfiles/test_dir_processor_root/templates_64/install/.calculate_directory @@ -0,0 +1,2 @@ +{% calculate append = "skip", action = "install", +package = "app-editors/vim" %} diff --git a/tests/templates/testfiles/test_dir_processor_root/templates_64/install/file_26 b/tests/templates/testfiles/test_dir_processor_root/templates_64/install/file_26 new file mode 100644 index 0000000..aaa90d2 --- /dev/null +++ b/tests/templates/testfiles/test_dir_processor_root/templates_64/install/file_26 @@ -0,0 +1,2 @@ +{% calculate append = "join" %} +salem -- onagainoffagain diff --git a/tests/templates/testfiles/test_dir_processor_root/var.backup/db/pkg/app-editors/vim-8.2.0360/CONTENTS b/tests/templates/testfiles/test_dir_processor_root/var.backup/db/pkg/app-editors/vim-8.2.0360/CONTENTS new file mode 100644 index 0000000..48bc135 --- /dev/null +++ b/tests/templates/testfiles/test_dir_processor_root/var.backup/db/pkg/app-editors/vim-8.2.0360/CONTENTS @@ -0,0 +1,2 @@ +dir /etc +obj /etc/file_26 23163aa36018dd607a3cc3487108439a 1611822287 diff --git a/tests/templates/testfiles/test_dir_processor_root/var.backup/db/pkg/app-editors/vim-8.2.0360/SLOT b/tests/templates/testfiles/test_dir_processor_root/var.backup/db/pkg/app-editors/vim-8.2.0360/SLOT new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/templates/testfiles/test_dir_processor_root/var.backup/db/pkg/app-editors/vim-8.2.0360/SLOT @@ -0,0 +1 @@ +0 diff --git a/tests/templates/testfiles/test_dir_processor_root/var.backup/db/pkg/app-editors/vim-core-8.2.0360/CONTENTS b/tests/templates/testfiles/test_dir_processor_root/var.backup/db/pkg/app-editors/vim-core-8.2.0360/CONTENTS new file mode 100644 index 0000000..e69de29 diff --git a/tests/templates/testfiles/test_dir_processor_root/var.backup/db/pkg/app-editors/vim-core-8.2.0360/SLOT b/tests/templates/testfiles/test_dir_processor_root/var.backup/db/pkg/app-editors/vim-core-8.2.0360/SLOT new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/templates/testfiles/test_dir_processor_root/var.backup/db/pkg/app-editors/vim-core-8.2.0360/SLOT @@ -0,0 +1 @@ +0