diff --git a/.gitignore b/.gitignore index 0c750bb..9b68711 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ *.pyc *.pyo *.swp +build/ +dist/ +calculate_lib.egg-info/ +.pytest_cache diff --git a/.pytest_cache/v/cache/lastfailed b/.pytest_cache/v/cache/lastfailed deleted file mode 100644 index daa1faa..0000000 --- a/.pytest_cache/v/cache/lastfailed +++ /dev/null @@ -1,46 +0,0 @@ -{ - "tests/templates/format/test_bind.py::TestParsingMethods::test_if_comment_parameter_is_set_for_template__format_object_will_parse_comments_with_comment_symbol_from_this_parameter": true, - "tests/templates/test_directory_processor.py::TestDirectoryProcessor::test_if_templates_consist_only_one_directory_with_a_calculate_directory_file_and_a_single_template_file_with_a_target_path_to_a_file_removed_by_user__the_directory_processor_creates_a_new_empty_cfg_file__joins_template_with_it_and_updates_the_CONTENTS_file": true, - "tests/templates/test_directory_processor.py::TestDirectoryProcessor::test_just_for_debug_with_package_value": true, - "tests/templates/test_directory_processor.py::TestDirectoryProcessor::test_just_for_debug_without_package_value": true, - "tests/templates/test_directory_processor.py::TestDirectoryProcessor::test_to_add": true, - "tests/templates/test_directory_processor.py::TestDirectoryProcessor::test_view_tree": true, - "tests/templates/test_parameters_processor.py::TestTemplateParameters::test_if_TemplateParameters_bla_bla": true, - "tests/templates/test_parameters_processor.py::TestTemplateParameters::test_if_TemplateParameters_object_is_initialized_using_": true, - "tests/templates/test_template_action.py": true, - "tests/templates/test_template_action.py::TestTemplateAction::test_create_directory": true, - "tests/templates/test_template_executor.py::TestTemplateAction": true, - "tests/templates/test_template_executor.py::TestTemplateAction::test_if_chown_value_is_not_correct__a_TemplateExecutor_object_throws_TemplateExecutorError_exception": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_for_the_testfiles_backup": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_clear_directory_method_s_input_is_a_template_with_a_target_path_to_an_unexisting_directory_that_does_not_belong_to_the_template_package__the_method_just_removes_the_directory_and_all_its_files_from_a_package_CONTENTS_file": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_directory_method_s_input_is_a_template_with_a_target_path_to_an_existing_directory_belongs_to_the_template_package__the_method_throws_TemplateCollisionError_error": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_an_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_and_the_unbound_parameter_is_set__the_method_joins_template_and_removes_a_target_file_path_from_a_package_CONTENTS_file": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_an_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_and_the_unbound_parameter_is_set_but_its_hash_sum_does_not_match_the_hash_from_a_CONTENTS_file__the_method_joins_template__removes_a_target_file_path_from_a_package_CONTENTS_file": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_an_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_and_the_unbound_parameter_is_set_but_its_hash_sum_does_not_match_the_hash_from_a_CONTENTS_file__the_method_joins_template__removes_a_target_file_path_from_a_package_CONTENTS_file_and_the_config_file": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_an_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_and_the_unbound_parameter_is_set_but_its_hash_sum_does_not_match_the_hash_from_a_CONTENTS_file_and_there_are_some_cfg_file__the_method_joins_template__removes_a_target_file_path_from_a_package_CONTENTS_file_and_the_config_file": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_and_its_hash_sum_matches_the_hash_from_a_CONTENTS_file__the_method_joins_an_input_file_with_a_template__changes_its_hash_in_the_CONTENTS__updates_config_archive": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_but_its_hash_sum_does_not_match_the_hash_from_a_CONTENTS_file__the_method_creates_a_cfg_file_and_adds_a_target_file_s_path_to_the_config_file": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_but_its_hash_sum_does_not_match_the_hash_from_a_CONTENTS_file_and_the_chown_and_chmod_parameters_is_set__the_method_creates_a_cfg_file_and_adds_a_target_file_s_path_to_the_config_file": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_but_its_hash_sum_does_not_match_the_hash_from_a_CONTENTS_file_and_the_chown_and_chmod_parameters_is_set__the_method_creates_a_cfg_file_and_adds_a_target_file_s_path_to_the_config_file_and_chown_and_chmod_it": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_but_its_hash_sum_does_not_match_the_hash_from_a_CONTENTS_file_and_there_is_two_cfg_files__the_method_creates_third_cfg_file_and_updates_config_file": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_but_its_hash_sum_does_not_match_the_hash_from_a_CONTENTS_file_and_there_is_two_cfg_files_and_changes_from_a_template_is_similar_to_the_last_one__the_method_does_nothing": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_its_hash_sum_matches_the_hash_from_a_CONTENTS_file_and_a_chown_and_chmod_parameters_are_set__the_method_joins_an_input_file_with_a_template__changes_its_hash_in_the_CONTENTS__updates_config_archive_and_chown_and_chmod_it": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_unexisting_file_that_should_exist__the_method_creates_new_empty_cfg_file_joins_a_template_with_them_and_adds_it_to_config_file": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_unexisting_file_that_should_exist_and_autoupdate_parameters_is_set__the_method_creates_new_empty_file_joins_a_template_with_them_and_adds_it_to_config_file": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_unexisting_file_that_should_exist_and_chown_and_chmod_parameters_are_set__the_method_creates_new_empty_cfg_file__joins_a_template_with_them__adds_it_to_config_file_and_chown_and_chmod_it": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_unexisting_file_that_should_not_exist__the_method_creates_new_empty_file_joins_a_template_with_them_adds_file_to_the_package_CONTENTS_file_and_create_an_archive_version_of_a_file": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_unexisting_file_that_should_not_exist_and_chown_and_chmod_parameters_are_set__the_method_creates_new_empty_file__joins_a_template_with_them__adds_file_to_the_package_CONTENTS_file__create_an_archive_version_of_a_file_and_chown_and_chmod_it": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_replace_directory_method_s_input_is_a_template_with_a_target_path_to_an_unexisting_directory_and_the_chown_and_the_chmod_parameters_are_set__the_method_creates_new_directory_and_add_it_to_a_package_CONTENTS_file": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_execute_template_method_s_input_is_a_template_of_the_DIR_type_with_the_append_link_parameter_a_target_path_to_an_existing_link_to_a_file_that_belongs_to_the_template_package__the_method_throws_TemplateTypeConflict_exception": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_execute_template_method_s_input_is_a_template_of_the_FILE_type_with_the_append_join_parameter_a_target_path_to_an_existing_directory_that_belongs_to_the_template_package_and_force_parameter_is_set__the_method_removes_a_directory_from_a_target_path__creates_empty_file__joins_template_with_the_created_file_and_updates_the_CONTENTS_file": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_execute_template_method_s_input_is_a_template_with_the_exec_parameter_a_target_path_to_an_existing_directory_but_interpreter_from_the_exec_parameter_does_not_exist__the_method_throws_the_TemplateExecutorError_exception": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_link_directory_method_s_input_is_a_path_to_an_existing_source_file_and_a_target_path__the_method_creates_a_link_to_a_source_file": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_link_directory_method_s_input_is_a_path_to_an_unexisting_source_directory_and_a_target_path__the_method_does_nothing": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_link_directory_method_s_input_is_a_path_to_an_unexisting_source_directory_and_a_target_path__the_method_raises_the_TemplateExecutorError_exception": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_remove_file_method_s_input_is_a_path_to_an_existing_file__the_method_raises_TemplateExecutorError_exception": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_remove_file_method_s_input_is_a_path_to_an_existing_link_to_an_existing_file__the_method_raises_TemplateExecutorError_exception": true, - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_to_add_link": true, - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_TemplateWrapper_object_successfully_initialized__the_object_can_be_used_for_an_adding_any_files_to_its_package_and_hash_will_be_calculated_automatically": true, - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_exec_parameter_is_set_for_template__no_checks_are_carried_out_while_TemplateWrapper_object_initialization": true, - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_run_parameter_is_set_for_template__no_checks_are_carried_out_while_TemplateWrapper_object_initialization": true -} \ No newline at end of file diff --git a/.pytest_cache/v/cache/nodeids b/.pytest_cache/v/cache/nodeids deleted file mode 100644 index 617661c..0000000 --- a/.pytest_cache/v/cache/nodeids +++ /dev/null @@ -1,395 +0,0 @@ -[ - "tests/templates/test_directory_processor.py::TestDirectoryProcessor::test_create_testfiles", - "tests/templates/test_directory_processor.py::TestDirectoryProcessor::test_if_templates_consist_only_one_directory_with_a_single_calculate_directory_file_with_the_append_skip_parameter__the_directory_processor_does_nothing", - "tests/templates/test_directory_processor.py::TestDirectoryProcessor::test_view_tree", - "tests/templates/test_directory_processor.py::TestDirectoryProcessor::test_for_removing_testfile", - "tests/templates/test_parameters_processor.py::TestTemplateParameters::test_if_TemplateParameters_object_is_initialized_accoding_to_dictionary_of_correct_template_parameters__the_TemplateParameters_object_contains_processed_parameters_as_its_attributes_including_default_values", - "tests/templates/test_parameters_processor.py::TestTemplateParameters::test_if_TemplateParameters_object_is_intialized_using_dictionary_with_append_parameter__a_value_of_the_parameter_will_be_checked", - "tests/templates/test_parameters_processor.py::TestTemplateParameters::test_if_TemplateParameters_object_is_intialized_using_dictionary_with_correct_source_parameter__the_object_will_be_initialized_successfully", - "tests/templates/test_parameters_processor.py::TestTemplateParameters::test_if_TemplateParameters_object_is_intialized_as_dir_parameters_object_using_correct_source_parameter_with_append_link__the_object_will_be_initialized_successfully", - "tests/templates/test_parameters_processor.py::TestTemplateParameters::test_if_TemplateParameters_object_is_intialized_using_source_parameter_with_unexisting_file_path__the_initialization_of_the_object_will_be_failed", - "tests/templates/test_parameters_processor.py::TestTemplateParameters::test_if_TemplateParameters_object_is_intialized_as_dir_parameters_object_using_source_parameter_but_without_append_link__the_initialization_of_the_object_will_be_failed", - "tests/templates/test_parameters_processor.py::TestTemplateParameters::test_if_TemplateParameters_object_is_intialized_using_dictionary_with_correct_force_parameter__the_object_will_be_initialized_successfully", - "tests/templates/test_parameters_processor.py::TestTemplateParameters::test_if_TemplateParameters_object_is_intialized_using_dictionary_with_incorrect_force_parameter__the_initialization_of_the_object_will_be_failed", - "tests/templates/test_parameters_processor.py::TestTemplateParameters::test_if_TemplateParameters_object_is_intialized_using_dictionary_with_autoupdate_parameter__a_value_of_the_parameter_will_be_checked", - "tests/templates/test_parameters_processor.py::TestTemplateParameters::test_if_TemplateParameters_object_is_intialized_using_dictionary_with_incorrect_autoupdate_parameter__the_initialization_of_the_object_will_be_failed", - "tests/templates/test_parameters_processor.py::TestTemplateParameters::test_if_TemplateParameters_object_is_intialized_using_dictionary_with_correct_chown_parameter__the_object_will_be_initialized_successfully", - "tests/templates/test_parameters_processor.py::TestTemplateParameters::test_if_TemplateParameters_object_is_initialized_using_dictionary_with_correct_chown_parameter_and_new_chroot_path__the_object_will_be_initialized_successfully", - "tests/templates/test_parameters_processor.py::TestTemplateParameters::test_if_TemplateParameters_object_is_intialized_using_dictionary_with_correct_chown_parameter_in_its_digital_form__the_object_will_be_initialized_successfully", - "tests/templates/test_parameters_processor.py::TestTemplateParameters::test_if_TemplateParameters_object_is_intialized_using_dictionary_with_incorrect_chown_parameter__the_initialization_of_the_object_will_be_failed", - "tests/templates/test_parameters_processor.py::TestTemplateParameters::test_if_TemplateParameters_object_is_intialized_using_dictionary_with_correct_chmod_parameter__the_object_will_be_initialized_successfully", - "tests/templates/test_parameters_processor.py::TestTemplateParameters::test_if_TemplateParameters_object_is_intialized_using_dictionary_with_correct_chmod_parameter_in_its_digital_form__the_object_will_be_initialized_successfully", - "tests/templates/test_template_engine.py::TestTemplateEngine::test_if_an_input_template_contains_calculate_tag_with_some_parameters__the_template_engine_object_will_collect_its_parameters", - "tests/templates/test_template_engine.py::TestTemplateEngine::test_if_an_input_template_binded_with_datavars_module__variables_available_in_a_template", - "tests/templates/test_template_engine.py::TestTemplateEngine::test_if_an_input_template_contains_env_parameter_in_which_module_name_is_assigned__the_variables_from_this_module_can_be_used_in_template_without_determining_of_their_module", - "tests/templates/test_template_engine.py::TestTemplateEngine::test_if_an_input_template_contains_condition_and_it_is_True__the_template_engine_object_will_be_initialized_without_any_exceptions", - "tests/templates/test_template_engine.py::TestTemplateEngine::test_if_an_input_template_contains_several_conditions_and_it_is_False__the_template_engine_raises_ConditionFailed_exception", - "tests/templates/test_template_engine.py::TestTemplateEngine::test_if_an_input_template_contains_several_calculate_tags__the_template_engine_will_parse_them_all_and_will_contain_all_parameters_and_result_of_all_conditions", - "tests/templates/test_template_engine.py::TestTemplateEngine::test_if_an_input_template_contains_variables_in_its_text__the_rendered_text_will_contain_values_of_this_variables", - "tests/templates/test_template_engine.py::TestTemplateEngine::test_if_value_of_variable_is_set_using_save_tag__the_new_value_of_variable_can_be_used_in_template", - "tests/templates/test_template_engine.py::TestTemplateEngine::test_if_an_input_template_contains_pkg_function_with_existing_package_as_its_argument__it_works_correctly_and_pkg_function_returns_version_value", - "tests/templates/test_template_engine.py::TestTemplateEngine::test_if_an_input_template_contains_pkg_function_with_package_that_does_not_exist_in_its_argument__it_works_correctly_and_pkg_function_returns_empty_version_value", - "tests/templates/test_template_engine.py::TestTemplateEngine::test_if_an_input_template_contains_pkg_function_without_any_arguments_but_with_package_parameter_in_calculate_tag__the_pkg_function_returns_version_value_of_the_package_from_package_parameter", - "tests/templates/test_template_engine.py::TestTemplateEngine::test_if_an_input_template_contains_pkg_function_without_any_arguments_and_without_package_parameter_in_calculate_tag__the_pkg_function_returns_empty_version_value", - "tests/templates/test_template_engine.py::TestTemplateEngine::test_if_an_input_template_calculate_tag_contains_pkg_function_with_an_existing_package_in_its_argument__the_pkg_function_returns_version_value_of_the_package_from_package_parameter_without_any_exceptions", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_function_to_copy_testfiles", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_config_file_does_not_exist__a_CalculateConfigFile_object_will_create_one_while_its_initialization", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_config_directory_is_on_the_config_path_instead_of_config_file__a_CalculateConfigFile_object_throws_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_a_CalculateConfigFile_object_is_initialized__the_object_can_be_used_for_setting_hash_sum_for_the_any_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_a_CalculateConfigFile_object_is_initialized__the_object_can_be_used_for_removing_any_file_from_config_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_a_CalculateConfigFile_object_contains_file_with_its_hash_and_the_hash_compared_with_equal_hash__the_compare_md5_method_returns_True", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_a_CalculateConfigFile_object_contains_file_with_its_hash_and_the_hash_compared_with_not_equal_hash__the_compare_md5_method_returns_False", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_a_CalculateConfigFile_object_is_used_for_comparing_a_hash_with_a_hash_of_a_file_that_is_not_in_the_config_file__the_compare_md5_method_returns_False", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_a_CalculateConfigFile_object_was_used_to_make_changes_in_the_config_file__the_save_changes_method_will_save_the_changes", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_a_TemplateExecutor_object_is_initialized__the_object_can_return_the_set_of_the_supported_values_of_the_append_parameter", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_translate_uid_gid_method_s_input_is_uid_and_gid_of_an_existing_user__the_method_returns_user_s_name_and_usser_s_groupname", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_chown_directory_method_input_is_path_to_the_existing_directory_and_correct_chown_value__the_chown_directory_method_succesfully_changes_directory_owner", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_chown_directory_method_input_is_path_to_the_unexisting_directory_and_correct_chown_value__the_chown_directory_method_does_nothing", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_chown_directory_method_input_is_a_path_to_the_directory_with_a_fat_filesystem_and_a_correct_chown_value__TemplateExecutor_object_throws_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_chown_file_method_input_is_a_path_to_an_existing_file_and_the_correct_chown_value__the_chown_file_method_succesfully_changes_file_owner", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_chown_file_method_input_is_path_to_the_unexisting_file_and_correct_chown_value__the_chown_directory_method_does_nothing", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_chown_file_method_input_is_a_path_to_the_file_from_the_fat_filesystem_and_a_correct_chown_value__TemplateExecutor_object_throws_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_chmod_directory_method_input_is_path_to_the_existing_directory_and_correct_chmod_value__the_chmod_directory_method_succesfully_changes_directory_mode", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_chmod_directory_method_input_is_path_to_the_unexisting_directory_and_correct_chmod_value__the_chmod_directory_method_does_nothing", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_chmod_directory_method_input_is_a_path_to_the_directory_with_a_fat_filesystem_and_a_correct_chmod_value__TemplateExecutor_object_throws_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_chmod_file_method_input_is_a_path_to_an_existing_file_and_the_correct_chmod_value__the_chmod_file_method_succesfully_changes_file_owner", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_chmod_file_method_input_is_path_to_the_unexisting_file_and_correct_chmod_value__the_chmod_file_method_does_nothing", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_chmod_file_method_input_is_a_path_to_the_file_with_a_fat_filesystem_and_a_correct_chmod_value__TemplateExecutor_object_throws_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_get_file_owner_method_is_called_with_a_path_to_a_directory_that_exists__the_method_returns_a_dictionary_with_its_owner_s_and_group_s_id", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_get_file_owner_method_is_called_with_a_path_to_a_directory_that_does_not_exists__the_method_throws_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_get_file_owner_method_is_called_with_a_path_to_a_file_that_exists__the_method_returns_a_dictionary_with_its_owner_s_and_group_s_id", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_get_file_owner_method_is_called_with_a_path_to_a_file_that_does_not_exists__the_method_throws_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_get_file_mode_method_is_called_with_a_path_to_a_directory_that_exists__the_method_returns_its_mode_value", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_get_file_mode_method_is_called_with_a_path_to_a_directory_that_does_not_exists__the_method_throws_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_get_file_mode_method_is_called_with_a_path_to_a_file_that_exists__the_method_returns_its_mode_value", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_get_file_mode_method_is_called_with_a_path_to_a_file_that_does_not_exists__the_method_throws_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_create_directory_method_input_is_a_template_with_a_target_path_to_an_existing_directory_and_chown_and_chmod_parameters_is_not_set__the_method_does_nothing", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_create_directory_method_input_is_a_template_with_a_target_path_to_an_existing_directory_and_chown_and_chmod_parameters_is_set__the_method_chmod_and_chown_target_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_create_directory_method_input_is_a_template_with_a_target_path_to_an_unexisting_directory_from_an_existing_directory_and_chown_and_chmod_parameters_is_not_set__the_method_creates_one_new_directory_with_a_mode_and_an_owner_of_its_parent_directory", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_create_directory_method_input_is_a_template_with_a_target_path_to_an_unexisting_directory_from_an_existing_directory_and_chown_and_chmod_parameters_is_set__the_method_one_new_directory_with_a_mode_and_an_owner_from_the_parameters", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_create_directory_method_input_is_a_template_with_a_target_path_to_an_unexisting_directory_from_an_unexisting_directory_and_chown_and_chmod_parameters_is_not_set__the_method_creates_new_directory_and_all_its_parents_with_a_mode_and_an_owner_of_its_existing_parent", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_create_directory_method_s_input_is_a_template_with_a_target_path_to_an_unexisting_directory_from_an_unexisting_directory_and_chown_and_chmod_parameters_is_set__the_method_creates_new_directory_and_all_its_parents_with_a_mode_and_an_owner_from_the_parameters", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_link_directory_method_s_input_is_a_path_to_an_existing_source_directory_and_a_target_path__the_method_creates_a_link_to_a_source_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_link_directory_method_s_input_is_a_path_to_an_existing_source_directory_and_a_target_path_to_an_existing_link__the_method_raises_the_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_remove_directory_method_s_input_is_a_path_to_an_existing_empty_directory__the_method_will_remove_the_directory", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_remove_directory_method_s_input_is_a_path_to_an_existing_directory_that_contains_a_some_files__the_method_will_remove_the_directory", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_remove_directory_method_s_input_is_a_path_to_an_existing_directory_that_contains_directories__the_method_will_remove_the_directory", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_remove_directory_method_s_input_is_a_path_to_an_existing_link_to_a_directory__the_method_will_remove_the_link_but_not_the_link_s_source_directory", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_remove_directory_method_s_input_is_a_path_to_an_unexisting_directory__the_method_throws_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_remove_directory_method_s_input_is_a_path_to_a_file__the_method_throws_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_clear_directory_method_s_input_is_a_path_to_an_existing_empty_directory__the_method_does_nothing", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_clear_directory_method_s_input_is_a_path_to_an_existing_directory_that_contains_some_files__the_method_clears_the_target_directory", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_clear_directory_method_s_input_is_a_path_to_an_existing_directory_that_contains_some_directories__the_method_clears_the_target_directory", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_clear_directory_method_s_input_is_a_path_to_an_existing_directory_that_contains_some_directories_and_files__the_method_clears_the_target_directory", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_clear_directory_method_s_input_is_a_path_to_an_unexisting_directory__the_method_raises_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_clear_directory_method_s_input_is_a_path_to_a_file__the_method_raises_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_link_file_method_s_input_is_a_path_to_an_existing_source_file_and_a_target_path__the_method_creates_a_link_to_a_source_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_link_file_method_s_input_is_a_path_to_an_existing_source_file_and_a_target_path_to_an_existing_file__the_method_throws_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_remove_file_method_s_input_is_a_path_to_an_existing_file__the_method_removes_a_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_remove_file_method_s_input_is_a_path_to_an_existing_link_to_an_existing_file__the_method_removes_a_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_remove_file_method_s_input_is_a_path_to_an_unexisting_file__the_method_raises_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_remove_file_method_s_input_is_a_path_to_an_existing_directory__the_method_raises_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_clear_file_method_s_input_is_a_path_to_an_existing_empty_file__the_method_does_nothing", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_clear_file_method_s_input_is_a_path_to_an_existing_file_with_any_content__the_method_does_nothing", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_clear_file_method_s_input_is_a_path_to_an_unexisting_file__the_method_raises_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_clear_file_method_s_input_is_a_path_to_an_existing_directory__the_method_raises_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_directory_method_s_input_is_a_template_with_a_target_path_to_an_unexisting_directory__the_method_creates_new_directory_and_adds_it_to_a_package_contents_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_directory_method_s_input_is_a_template_with_a_target_path_to_an_existing_directory_that_does_not_belong_to_any_package__the_method_just_adds_new_directory_to_a_package_contents_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_directory_method_s_input_is_a_template_with_a_target_path_to_an_existing_directory_belongs_to_the_template_package__the_method_does_nothing", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_execute_template_method_s_input_is_a_template_of_the_DIR_type_with_the_append_join_parameter_a_target_path_to_an_existing_file_that_belongs_to_the_template_package_and_force_parameter_is_set__the_method_removes_file_on_a_target_path__creates_new_directory_and_changes_target_s_type_to_the_dir_type_in_the_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_execute_template_method_s_input_is_a_template_of_the_DIR_type_with_the_append_join_parameter_a_target_path_to_an_existing_link_to_a_directory_that_belongs_to_the_template_package__the_method_changes_a_target_path_to_a_link_s_source_path_and_returns_one", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_execute_template_method_s_input_is_a_template_of_the_DIR_type_with_the_append_join_parameter_a_target_path_to_an_existing_link_to_a_directory_that_belongs_to_the_template_package_and_force_parameter_is_set__the_method_changes_a_target_path_to_a_link_s_source_path_and_returns_one", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_remove_directory_method_s_input_is_a_template_with_a_target_path_to_an_existing_directory_that_belongs_to_the_template_package__the_method_removes_a_target_directory_in_a_filesystem_and_in_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_remove_directory_method_s_input_is_a_template_with_a_target_path_to_an_unexisting_directory_that_belongs_to_the_template_package__the_method_removes_a_target_directory_in_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_remove_directory_method_s_input_is_a_template_with_a_target_path_to_an_existing_directory_that_does_not_belong_to_any_package__the_method_removes_a_target_directory_in_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_clear_directory_method_s_input_is_a_template_with_a_target_path_to_an_existing_empty_directory_that_belongs_to_the_template_package__the_method_just_removes_all_its_files_from_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_clear_directory_method_s_input_is_a_template_with_a_target_path_to_an_unexisting_directory_that_belongs_to_the_template_package__the_method_just_removes_the_directory_and_all_its_files_from_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_clear_directory_method_s_input_is_a_template_with_a_target_path_to_an_unexisting_directory_that_does_not_belong_to_the_template_package__the_method_does_nothing", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_clear_directory_method_s_input_is_a_template_with_a_target_path_to_an_existing_directory_with_some_files_that_belongs_to_the_template_package__the_method_clears_directory_and_removes_all_its_files_from_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_clear_directory_method_s_input_is_a_template_with_a_target_path_to_an_existing_directory_with_some_directories_with_files_that_belongs_to_the_template_package__the_method_clears_directory_and_removes_all_its_files_from_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_clear_directory_method_s_input_is_a_template_with_a_target_path_to_an_existing_directory_that_belongs_to_the_template_package_and_chmod_and_chown_parameters_are_set__the_method_clears_directory_removes_all_its_files_from_a_package_CONTENTS_file_and_chmod_and_chown_one", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_replace_directory_method_s_input_is_a_template_with_a_target_path_to_an_unexisting_directory__the_method_creates_new_directory_and_add_it_to_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_replace_directory_method_s_input_is_a_template_with_a_target_path_to_an_unexisting_directory_and_the_chown_and_the_chmod_parameters_are_set__the_method_creates_new_directory_adds_it_to_a_package_CONTENTS_file_and_chown_and_chmod_directory", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_replace_directory_method_s_input_is_a_template_with_a_target_path_to_an_existing_empty_directory_that_belongs_to_the_template_package__the_method_does_nothing", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_replace_directory_method_s_input_is_a_template_with_a_target_path_to_an_existing_empty_directory_that_belongs_to_the_template_package_and_the_chown_and_chmod_parameters_are_set__the_method_just_chown_and_chmod_a_target_directory", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_replace_directory_method_s_input_is_a_template_with_a_target_path_to_an_existing_directory_with_some_files_that_belongs_to_the_template_package__the_method_clears_directory_and_removes_all_its_files_from_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_replace_directory_method_s_input_is_a_template_with_a_target_path_to_an_existing_directory_with_some_directories_with_files_that_belongs_to_the_template_package__the_method_clears_directory_and_removes_all_its_files_from_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_link_directory_method_s_input_is_a_template_with_a_target_path_and_a_source_path_to_the_existing_directory__the_method_creates_a_link_to_the_source_directory_and_adds_this_link_to_the_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_link_directory_method_s_input_is_a_template_with_a_target_path_and_a_source_path_to_the_existing_directory_and_the_chown_and_chmod_parameters_are_set__the_method_creates_a_link_to_the_source_directory_and_adds_this_link_to_the_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_execute_template_method_s_input_is_a_template_of_the_DIR_type_with_the_append_link_parameter_a_target_path_to_an_existing_link_to_a_directory_that_belongs_to_the_template_package__the_method_removes_link_on_a_target_path_and_creates_new_one", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_execute_template_method_s_input_is_a_template_of_the_DIR_type_with_the_append_link_parameter_a_target_path_to_an_existing_link_to_a_file_that_belongs_to_the_template_package__the_method_throws_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_execute_template_method_s_input_is_a_template_of_the_DIR_type_with_the_append_link_parameter_a_target_path_to_an_existing_link_to_a_file_that_belongs_to_the_template_package_and_force_parameter_is_set__the_method_removes_a_link_from_a_target_path_and_creates_a_link_to_a_source_directory", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_execute_template_method_s_input_is_a_template_of_the_DIR_type_with_the_append_link_parameter_a_target_path_to_an_existing_file_that_belongs_to_the_template_package__the_method_throws_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_execute_template_method_s_input_is_a_template_of_the_DIR_type_with_the_append_link_parameter_a_target_path_to_an_existing_file_that_belongs_to_the_template_package_and_force_parameter_is_set__the_method_removes_a_file_from_a_target_path_and_creates_a_link_to_a_source_directory", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_execute_template_method_s_input_is_a_template_of_the_DIR_type_with_the_append_link_parameter_a_target_path_to_an_existing_directory_that_belongs_to_the_template_package__the_method_throws_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_execute_template_method_s_input_is_a_template_of_the_DIR_type_with_the_append_link_parameter_a_target_path_to_an_existing_directory_that_belongs_to_the_template_package_and_force_parameter_is_set__the_method_removes_a_directory_from_a_target_path_and_creates_a_link_to_a_source_directory", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_unexisting_file_that_should_not_exist__the_method_creates_new_empty_file_joins_a_template_with_them_adds_file_to_the_package_CONTENTS_file_and_create_an_archive_version_of_a_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_unexisting_file_that_should_exist__the_method_creates_new_empty_cfg_file_joins_a_template_with_them_and_adds_it_to_config_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_unexisting_file_that_should_exist_and_autoupdate_parameters_is_set__the_method_creates_new_empty_file_joins_a_template_with_them_and_adds_it_to_config_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_unexisting_file_that_should_not_exist_and_chown_and_chmod_parameters_are_set__the_method_creates_new_empty_file__joins_a_template_with_them__adds_file_to_the_package_CONTENTS_file__create_an_archive_version_of_a_file_and_chown_and_chmod_it", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_unexisting_file_that_should_exist_and_chown_and_chmod_parameters_are_set__the_method_creates_new_empty_cfg_file__joins_a_template_with_them__adds_it_to_config_file_and_chown_and_chmod_it", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_and_its_hash_sum_matches_the_hash_from_a_CONTENTS_file__the_method_joins_an_input_file_with_a_template__changes_its_hash_in_the_CONTENTS__updates_config_archive", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_its_hash_sum_matches_the_hash_from_a_CONTENTS_file_and_a_chown_and_chmod_parameters_are_set__the_method_joins_an_input_file_with_a_template__changes_its_hash_in_the_CONTENTS__updates_config_archive_and_chown_and_chmod_it", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_but_its_hash_sum_does_not_match_the_hash_from_a_CONTENTS_file__the_method_creates_a_cfg_file_and_adds_a_target_file_s_path_to_the_config_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_but_its_hash_sum_does_not_match_the_hash_from_a_CONTENTS_file_and_the_chown_and_chmod_parameters_is_set__the_method_creates_a_cfg_file_and_adds_a_target_file_s_path_to_the_config_file_and_chown_and_chmod_it", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_but_its_hash_sum_does_not_match_the_hash_from_a_CONTENTS_file_and_the_autoupdate_parameter_is_set__the_method_joins_a_target_file_and_a_template__removes_a_path_to_file_from_the_config_file_and_updates_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_but_its_hash_sum_does_not_match_the_hash_from_a_CONTENTS_file_and_there_is_some_cfg_files_and_the_autoupdate_parameter_is_set__the_method_joins_a_target_file_and_a_template__removes_a_path_to_file_from_the_config_file__removes_all_cfg_files_and_updates_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_but_its_hash_sum_does_not_match_the_hash_from_a_CONTENTS_file_and_there_is_two_cfg_files__the_method_creates_third_cfg_file_and_updates_config_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_but_its_hash_sum_does_not_match_the_hash_from_a_CONTENTS_file_and_there_is_two_cfg_files_and_changes_from_a_template_is_similar_to_the_last_one__the_method_does_nothing", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_an_unprotected_target_path_to_an_existing_file_that_belongs_to_the_template_package__the_method_just_joins_a_template_to_a_target_file_without_updating_a_CONTENTS_file_and_creating_an_archive_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_an_unprotected_target_path_to_an_existing_file_that_belongs_to_the_template_package_but_its_hash_sum_does_not_match_the_hash_from_a_CONTENTS_file__the_method_just_joins_a_template_to_a_target_file_without_updating_a_package_CONTENTS_and_the_config_files_and_creating_an_archive_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_an_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_and_the_unbound_parameter_is_set__the_method_joins_template_and_removes_a_target_file_path_from_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_an_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_and_the_unbound_parameter_is_set_but_its_hash_sum_does_not_match_the_hash_from_a_CONTENTS_file__the_method_joins_template__removes_a_target_file_path_from_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_join_file_method_s_input_is_a_template_with_an_protected_target_path_to_an_existing_file_that_belongs_to_the_template_package_and_the_unbound_parameter_is_set_but_its_hash_sum_does_not_match_the_hash_from_a_CONTENTS_file_and_there_are_some_cfg_file__the_method_joins_template__removes_a_target_file_path_from_a_package_CONTENTS_file_and_the_config_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_execute_template_method_s_input_is_a_template_of_the_FILE_type_with_the_append_join_parameter_a_target_path_to_an_existing_directory_that_belongs_to_the_template_package__the_method_throws_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_execute_template_method_s_input_is_a_template_of_the_FILE_type_with_the_append_join_parameter_a_target_path_to_an_existing_directory_that_belongs_to_the_template_package_and_force_parameter_is_set__the_method_removes_a_directory_from_a_target_path__creates_empty_file__joins_template_with_the_created_file_and_updates_the_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_append_after_file_method_s_input_is_a_not_empty_template__the_template_s_text_and_sections_joins_after_the_text_of_the_target_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_append_before_file_method_s_input_is_a_not_empty_template__the_template_s_text_and_sections_joins_before_the_text_of_the_target_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_append_replace_file_method_s_input_is_a_not_empty_template_with_a_target_path_to_an_existing_file__the_method_joins_a_template_with_the_empty_text_and_replaces_the_target_file_with_the_template_join_result", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_append_remove_file_method_s_input_is_a_template_with_a_target_path_to_an_existing_file_that_belongs_to_the_template_package__the_method_removes_a_target_file_in_a_filesystem_and_in_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_append_remove_file_method_s_input_is_a_template_with_a_target_path_to_an_unexisting_file_that_belongs_to_the_template_package__the_method_removes_a_target_file_in_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_append_remove_file_method_s_input_is_a_template_with_a_target_path_to_an_existing_file_that_does_not_belong_to_any_package__the_method_removes_a_target_file_in_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_append_clear_file_method_s_input_is_a_template_with_a_target_path_to_an_existing_empty_file_that_belongs_to_the_template_package__the_method_just_updates_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_append_clear_file_method_s_input_is_a_template_with_a_target_path_to_an_existing_not_empty_file_that_belongs_to_the_template_package__the_method_clears_a_target_file_and_updates_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_append_clear_file_method_s_input_is_a_template_with_a_target_path_to_an_existing_not_empty_file_that_belongs_to_the_template_package_and_the_chown_and_chmod_parameters_are_set__the_method_clears_a_target_file_and_updates_a_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_link_file_method_s_input_is_a_template_with_a_target_path_and_a_source_path_to_the_existing_file__the_method_creates_a_link_to_the_source_file_and_adds_this_link_to_the_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_append_link_file_method_s_input_is_a_template_with_a_target_path_and_a_source_path_to_the_existing_file_and_the_chown_and_chmod_parameters_are_set__the_method_creates_a_link_to_the_source_file_and_adds_this_link_to_the_package_CONTENTS_file", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_execute_template_method_s_input_is_a_template_with_the_run_parameter_and_a_target_path_to_an_existing_directory_and_its_text_is_empty__the_method_does_nothing", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_execute_template_method_s_input_is_a_template_with_the_run_parameter_and_a_target_path_to_an_existing_directory_and_its_text_is_correct__the_method_runs_a_template_text_in_the_target_directory_and_returns_the_object_with_its_stdout", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_execute_template_method_s_input_is_a_template_with_the_run_parameter_and_a_target_path_to_an_unexisting_directory__the_method_throws_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_execute_template_method_s_input_is_a_template_with_the_run_parameter_and_a_target_path_to_an_existing_file_and_its_text_is_correct__the_method_runs_a_template_text_in_a_directory_that_contains_a_file_from_a_target_path_and_returns_the_object_with_its_stdout", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_execute_template_method_s_input_is_a_template_with_the_run_parameter_and_a_target_path_to_an_unexisting_file__the_method_throws_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_execute_template_method_s_input_is_a_template_with_the_run_parameter_a_target_path_to_an_existing_directory_and_its_text_is_not_correct__the_method_runs_a_template_text_and_returns_the_object_with_its_stderr", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_execute_template_method_s_input_is_a_template_with_the_run_parameter_a_target_path_to_an_existing_directory_but_interpreter_from_the_run_parameter_does_not_exist__the_method_throws_the_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_execute_template_method_s_input_is_a_template_with_the_exec_parameter_and_a_target_path_to_an_existing_directory_and_its_text_is_empty__the_method_creates_an_empty_exec_file_and_saves_a_path_to_exec_file_interpreter_and_a_target_path_as_cwd_path", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_execute_template_method_s_input_is_a_template_with_the_exec_parameter_and_a_target_path_to_an_existing_directory_and_its_text_is_not_empty__the_method_creates_an_exec_file_and_saves_a_path_to_exec_file_interpreter_and_a_target_path_as_cwd_path", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_execute_template_method_s_input_is_a_template_with_the_exec_parameter_and_a_target_path_to_an_unexisting_directory__the_method_throws_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_execute_template_method_s_input_is_a_template_with_the_exec_parameter_and_a_target_path_to_an_existing_file_and_its_text_is_not_empty__the_method_creates_an_exec_file_and_saves_a_path_to_exec_file_interpreter_and_a_path_to_a_file_from_a_target_path_as_cwd_path", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_execute_template_method_s_input_is_a_template_with_the_exec_parameter_and_a_target_path_to_an_unexisting_file__the_method_throws_TemplateExecutorError_exception", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_the_execute_template_method_s_input_is_a_several_templates_with_the_exec_parameter_and_a_target_paths_to_an_existing_directories_and_files_and_its_text_is_not_empty__the_method_creates_some_exec_files_and_saves_a_paths_to_exec_files_its_interpreters_and_paths_to_a_directories_from_a_target_path_as_cwd_path", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_some_exec_files_is_saved_and_contains_correct_scripts__the_execute_file_method_can_be_used_for_executing_this_exec_files_and_the_returns_its_stdout_and_stderr", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_if_some_exec_files_is_saved_and_contains_not_correct_scripts__the_execute_file_method_can_be_used_for_executing_this_exec_files_and_returns_its_stderr_and_stdout", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_for_mirror", - "tests/templates/test_template_executor.py::TestTemplateExecutor::test_to_remove_changed_testfiles", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_the_TemplateWrapper_object_has_already_been_created__it_contains_the_correct_list_of_protected_and_unprotected_paths", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_FILE_and_target_file_does_not_exist__the_TemplateWrapper_target_type_is_None", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_DIR_and_target_file_is_DIR__the_TemplateWrapper_target_type_is_DIR", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_FILE_and_target_file_is_FILE__the_TemplateWrapper_target_type_is_FILE", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_FILE_and_target_file_is_FILE_and_force_parameter_is_set__the_TemplateWrapper_target_type_is_FILE_and_target_path_is_same", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_FILE_but_target_file_is_DIR_and_force_parameter_is_not_set__the_TemplateWrapper_throws_TemplateTypeConflict_exception", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_FILE_but_target_file_is_a_link_and_force_parameter_is_not_set__the_TemplateWrapper_throws_TemplateTypeConflict_exception", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_FILE_but_target_file_is_DIR_and_force_parameter_is_set__the_TemplateWrapper_sets_remove_original_flag", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_FILE_but_target_file_is_a_link_to_a_DIR_and_force_parameter_is_set__the_TemplateWrapper_sets_remove_original_flag", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_FILE_but_target_file_is_a_link_to_a_FILE_and_force_parameter_is_set__the_TemplateWrapper_changes_its_target_path_to_the_link_source_file", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_DIR_and_target_file_is_DIR_and_force_parameter_is_set__the_TemplateWrapper_target_type_is_DIR_and_target_path_is_the_same", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_DIR_and_target_file_is_a_link_to_a_DIR_and_force_parameter_is_not_set__the_TemplateWrapper_changes_its_target_path_to_the_link_source_file", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_DIR_but_target_file_is_FILE_and_force_parameter_is_not_set__the_TemplateWrapper_throws_TemplateTypeConflict_exception", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_DIR_and_target_file_is_a_link_to_a_file_and_force_parameter_is_not_set__the_TemplateWrapper_throws_TemplateTypeConflict_exception", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_DIR_and_target_file_is_FILE_and_force_parameter_is_set__the_TemplateWrapper_sets_remove_original_flag", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_DIR_and_target_file_is_the_link_to_a_FILE_and_force_parameter_is_set__the_TemplateWrapper_sets_remove_original_flag", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_DIR_and_target_file_is_the_link_to_a_DIR_and_force_parameter_is_set__the_TemplateWrapper_sets_remove_original_flag", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_FILE_with_the_append_link_parameter_and_target_file_is_the_link_to_a_FILE__the_TemplateWrapper_sets_remove_original_flag", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_FILE_with_the_append_link_parameter_and_target_file_is_the_link_to_a_DIR__the_TemplateWrapper_sets_remove_original_flag", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_DIR_with_the_append_link_parameter_and_target_file_is_the_link_to_a_FILE__the_TemplateWrapper_sets_remove_original_flag", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_DIR_with_the_append_link_parameter_and_target_file_is_the_link_to_a_DIR__the_TemplateWrapper_sets_remove_original_flag", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_FILE_with_the_append_link_parameter_and_target_file_is_FILE_and_force_parameter_is_not_set__the_TemplateWrapper_throws_TemplateTypeConflict_exception", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_FILE_with_the_append_link_parameter_and_target_file_is_DIR_and_force_parameter_is_not_set__the_TemplateWrapper_throws_TemplateTypeConflict_exception", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_DIR_with_the_append_link_parameter_and_target_file_is_FILE_and_force_parameter_is_not_set__the_TemplateWrapper_throws_TemplateTypeConflict_exception", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_DIR_with_the_append_link_parameter_and_target_file_is_DIR_and_force_parameter_is_not_set__the_TemplateWrapper_throws_TemplateTypeConflict_exception", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_FILE_with_the_append_link_parameter_and_target_file_is_FILE_and_force_parameter_is_set__the_TemplateWrapper_sets_remove_original_flag", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_FILE_with_the_append_link_parameter_and_target_file_is_DIR_and_force_parameter_is_set__the_TemplateWrapper_sets_remove_original_flag", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_DIR_with_the_append_link_parameter_and_target_file_is_FILE_and_force_parameter_is_set__the_TemplateWrapper_sets_remove_original_flag", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_type_is_DIR_with_the_append_link_parameter_and_target_file_is_DIR_and_force_parameter_is_set__the_TemplateWrapper_sets_remove_original_flag", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_contains_append_parameters_but_does_not_have_package_parameter_and_target_file_does_not_belong_to_any_package__the_TemplateWrapper_throws_TemplateCollisionError_exception", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_contains_package_parameter_and_target_file_does_not_belong_to_any_package__the_TemplateWrapper_uses_package_from_parameter_and_sets_target_without_package_flag", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_does_not_have_package_parameter_but_target_file_belongs_to_the_package__the_TemplateWrapper_uses_package_from_parameter", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_contains_package_parameter_and_target_file_belongs_to_the_package_from_package_parameter__the_TemplateWrapper_uses_package_from_them", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_template_contains_package_parameter_but_target_file_belongs_to_the_other_package__the_TemplateWrapper_throws_TemplateCollisionError", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_TemplateWrapper_object_contains_package_value__the_wrapper_can_use_Package_object_for_changing_CONTENTS_file_of_the_package", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_target_file_directory_contains_no_cfg_files_but_it_is_necessary_to_create_one__the_first_cfg_file_should_be_named_cfg0001_file", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_target_file_directory_contains_some_cfg_files_including_the_first_one__the_next_cfg_file_should_be_named_with_the_number_following_the_number_of_the_last_one", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_target_file_directory_contains_some_cfg_files_but_some_of_them_are_missed__the_next_cfg_file_should_be_named_with_the_number_following_the_number_of_the_last_one", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_get_archive_path_method_has_the_file_path_as_its_argument__it_returns_the_path_to_the_archive_version_of_the_input_file", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_target_file_is_located_in_a_protected_directory__the_TemplateWrapper_object_sets_the_protected_flag_as_True", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_target_file_is_located_in_a_directory_that_is_not_protected__the_TemplateWrapper_object_sets_the_protected_flag_as_False", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_target_file_is_located_in_a_directory_from_the_protected_mask__the_TemplateWrapper_object_sets_the_protected_flag_as_False", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_target_file_is_not_protected__the_TemplateWrapper_sets_the_md5_matching_flag_as_True", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_template_contains_the_unbound_parameter__the_TemplateWrapper_sets_the_md5_matching_flag_as_True", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_target_file_does_not_exist_and_CONTENTS_file_of_the_file_s_package_does_not_contain_this_file__the_TemplateWrapper_sets_the_md5_matching_flag_as_True", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_target_file_was_deleted_by_a_user__the_TemplateWrapper_object_sets_the_md5_matching_flag_as_False", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_target_file_does_not_belong_to_any_package__the_TemplateWrapper_object_sets_the_md5_matching_flag_as_False", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_template_contains_the_autoupdate_parameter__the_TemplateWrapper_sets_the_md5_matching_flag_as_True", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_template_contains_the_autoupdate_parameter_and_a_target_file_does_not_belong_to_any_package__the_TemplateWrapper_sets_the_md5_matching_flag_as_True", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_target_file_s_hash_matches_the_hash_from_the_package_s_CONTENTS_file__the_TemplateWrapper_object_sets_the_md5_matching_flag_as_True", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_target_file_s_hash_does_not_match_the_hash_from_the_package_s_CONTENTS_file__the_TemplateWrapper_object_sets_the_md5_matching_flag_as_False", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_after_the_target_file_check_md5_matching_flag_is_set_as_True_and_a_template_does_not_contain_source_parameter__the_output_and_the_input_paths_for_the_TemplateExecutor_is_the_same_and_it_is_target_path", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_after_the_target_file_check_md5_matching_flag_is_set_as_False_and_a_template_does_not_contain_source_parameter__the_output_path_is_the_cfg_file_path_and_the_input_path_is_the_calculate_archive_path", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_after_the_target_file_check_md5_matching_flag_is_set_as_True_and_a_template_contains_source_parameter__the_output_and_the_input_paths_for_the_TemplateExecutor_is_the_same_and_it_is_target_path", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_after_the_target_file_check_md5_matching_flag_is_set_as_False_and_a_template_contains_source_parameter__the_output_path_is_the_cfg_file_path_and_the_input_path_is_the_calculate_archive_path", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_target_path_is_FILE_and_a_template_is_executable__the_target_path_is_replaced_with_the_path_to_the_cwd_directory_and_there_is_no_package_type_conflicts_and_other_checks", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_target_path_is_DIR_and_a_template_is_executable__the_target_path_is_the_same_and_there_is_no_package_type_conflicts_and_other_checks", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_template_is_executable_and_contains_package_parameter__the_template_updates_the_CONTENTS_file_for_package_from_parameter", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_TemplateWrapper_object_successfully_initialized_as_FILE__the_object_can_be_used_for_an_adding_the_current_file_to_its_package_and_hash_will_be_calculated_automatically", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_TemplateWrapper_object_successfully_initialized_as_FILE__the_object_can_be_used_for_an_adding_the_current_file_to_its_package_with_specified_hash", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_TemplateWrapper_object_successfully_initialized__the_object_can_be_used_for_a_removing_current_file_from_its_package", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_TemplateWrapper_object_successfully_initialized_as_DIR__the_object_can_be_used_for_a_removing_current_directory_and_all_its_contents_from_its_package", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_TemplateWrapper_object_successfully_initialized_with_DIR_type__the_object_can_be_used_for_a_removing_all_directory_files_from_its_package", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_TemplateWrapper_object_successfully_initialized__the_object_can_be_used_for_changing_CONTENTS_using_list_of_changed_files", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_a_TemplateWrapper_was_used_to_change_CONTENTS__it_should_be_saved_using_save_changes_method", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_after_removing_some_files_thought_TemplateWrapper_some_directories_become_empty__empty_directories_will_be_removed_saving_changes", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_mirror_parameter_is_set_and_target_file_does_not_exist__a_TemplateWrapper_object_throws_TemplateExecutorError", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_mirror_parameter_is_set_and_file_from_the_source_parameter_does_not_exist__a_TemplateWrapper_object_sets_remove_original_flag_as_True", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_run_parameter_is_set_for_template__no_checks_are_carried_out_while_a_TemplateWrapper_object_initialization", - "tests/templates/test_template_wrapper.py::TestTemplateWrapper::test_if_exec_parameter_is_set_for_template__no_checks_are_carried_out_while_a_TemplateWrapper_object_initialization", - "tests/templates/format/test_base.py::TestJoinMethod::test_if_inputs_are_dictionaries_with_string_keys_without_any_action_marks__the_dictionaties_just_merged", - "tests/templates/format/test_base.py::TestJoinMethod::test_if_inputs_are_dictionaries_with_tuple_keys_without_any_action_marks_as_their_keys__the_dictionaries_just_merged", - "tests/templates/format/test_base.py::TestJoinMethod::test_if_inputs_are_dictionaries_with_same_sections_which_contain_different_parameters__a_section_from_the_template_added_to_the_same_section_of_original_dictionary", - "tests/templates/format/test_base.py::TestJoinMethod::test_if_inputs_are_dictionaries_with_parameters_with_same_name_in_same_section__parameters_values_in_original_dictionary_changed_to_values_from_template", - "tests/templates/format/test_base.py::TestJoinMethod::test_if_input_template_dictionary_has_delete_mark_for_section__section_will_be_deleted", - "tests/templates/format/test_base.py::TestJoinMethod::test_if_input_template_dictionary_has_replace_mark_for_section__section_will_be_deleted", - "tests/templates/format/test_base.py::TestJoinMethod::test_if_input_template_dictionary_has_delete_mark_for_parameter__parameter_will_be_deleted", - "tests/templates/format/test_base.py::TestJoinMethod::test_if_input_dictionaries_have_no_sections_and_have_only_parameter_lines__it_will_be_processed_correctly", - "tests/templates/format/test_base.py::TestLogicLinesMethod::test_if_input_is_text_document_the_method_returns_list_of_its_lines", - "tests/templates/format/test_base.py::TestLogicLinesMethod::test_if_lines_in_document_divided_using_backslash_as_continuation_symbol__method_returns_list_of_full_lines", - "tests/templates/format/test_bind.py::TestParsingMethods::test_if_input_document_contains_just_few_parameter_lines__the_initialised_object_contains_correct_dictionary", - "tests/templates/format/test_bind.py::TestParsingMethods::test_if_input_document_contains_some_block_of_parameters__the_initialised_object_contains_correct_dictionary", - "tests/templates/format/test_bind.py::TestParsingMethods::test_if_input_document_contains_some_blocks_with_similar_names__the_blocks_join_recursively", - "tests/templates/format/test_bind.py::TestParsingMethods::test_if_input_document_contains_blocks_and_parameters_with_action_marks__the_key_tuples_of_object_s_dictionary_have_it_as_its_first_element", - "tests/templates/format/test_bind.py::TestParsingMethods::test_if_parameters_and_blocks_in_input_document_has_some_comments__the_comments_will_be_collected_in_the_list_of_parameter_value_or_with_special_key_in_block_dictionary", - "tests/templates/format/test_bind.py::TestParsingMethods::test_if_the_IgnoreComments_flag_is_set__the_parser_ignores_all_comments", - "tests/templates/format/test_bind.py::TestParsingMethods::test_join_before", - "tests/templates/format/test_bind.py::TestParsingMethods::test_if_input_document_contains_parameters_to_delete_without_values_or_with_empty_block__the_document_object_contains_dictionary_with_item_to_delete", - "tests/templates/format/test_bind.py::TestParsingMethods::test_joining_documents_1", - "tests/templates/format/test_bind.py::TestParsingMethods::test_make_template", - "tests/templates/format/test_compiz.py::TestParsingMethods::test_if_input_document_contains_just_few_parameter_lines__the_initialised_object_contains_correct_dictionary", - "tests/templates/format/test_compiz.py::TestParsingMethods::test_if_input_document_contains_few_parameter_lines_and_some_empty_lines__the_initialized_object_contains_correct_dictionary", - "tests/templates/format/test_compiz.py::TestParsingMethods::test_if_input_document_contains_sections_with_different_names_but_different_parameters__the_parameters_merged_in_one_section", - "tests/templates/format/test_compiz.py::TestParsingMethods::test_if_input_document_contains_sections_with_parameters_with_action_marks__the_key_tuples_of_object_s_dictionary_have_it_as_its_first_element", - "tests/templates/format/test_compiz.py::TestParsingMethods::test_if_parameter_in_input_document_has_some_comments__the_comments_will_be_collected_in_the_list_of_parameter_value", - "tests/templates/format/test_compiz.py::TestParsingMethods::test_if_the_ignore_comments_flag_is_set__the_parser_ignores_all_comments", - "tests/templates/format/test_compiz.py::TestParsingMethods::test_if_input_document_contains_parameters_to_delete_without_assign_symbol_and_any_values_and_sections_to_delete__the_document_object_contains_dictionary_with_item_to_delete", - "tests/templates/format/test_compiz.py::TestParsingMethods::test_joining_documents_1", - "tests/templates/format/test_compiz.py::TestParsingMethods::test_make_template", - "tests/templates/format/test_contents.py::TestParsingMethods::test_if_input_document_contains_a_few_lines_without_any_action_symbols__the_initialised_object_contains_correct_dictionary", - "tests/templates/format/test_contents.py::TestParsingMethods::test_if_input_document_contains_a_few_lines_with_some_action_symbols__the_initialised_object_contains_correct_dictionary", - "tests/templates/format/test_contents.py::TestParsingMethods::test_if_template_parser_flag_is_set_False__the_initialized_object_contains_correct_dictionary_for_contents_util_module", - "tests/templates/format/test_contents.py::TestParsingMethods::test_joining_documents_1", - "tests/templates/format/test_diff.py::TestExecuteMethods::test_if_diff_patch_used_for_patching_of_several_files__it_changes_patched_file_correctly", - "tests/templates/format/test_diff.py::TestExecuteMethods::test_if_diff_patch_used_for_patching_of_directories__it_changes_files_in_directories_and_adds_ones", - "tests/templates/format/test_dovecot.py::TestParsingMethods::test_if_input_document_contains_just_few_parameter_lines__the_initialised_object_contains_correct_dictionary", - "tests/templates/format/test_dovecot.py::TestParsingMethods::test_if_input_document_contains_some_block_of_parameters__the_initialised_object_contains_correct_dictionary", - "tests/templates/format/test_dovecot.py::TestParsingMethods::test_if_input_document_contains_some_blocks_with_similar_names__the_blocks_join_recursively", - "tests/templates/format/test_dovecot.py::TestParsingMethods::test_if_input_document_contains_blocks_and_parameters_with_action_marks__the_key_tuples_of_object_s_dictionary_have_it_as_its_first_element", - "tests/templates/format/test_dovecot.py::TestParsingMethods::test_if_parameters_and_blocks_in_input_document_has_some_comments__the_comments_will_be_collected_in_the_list_of_parameter_value_or_with_special_key_in_block_dictionary", - "tests/templates/format/test_dovecot.py::TestParsingMethods::test_if_the_IgnoreComments_flag_is_set__the_parser_ignores_all_comments", - "tests/templates/format/test_dovecot.py::TestParsingMethods::test_if_input_document_contains_parameters_to_delete_without_values_or_with_empty_block__the_document_object_contains_dictionary_with_item_to_delete", - "tests/templates/format/test_dovecot.py::TestParsingMethods::test_joining_documents_1", - "tests/templates/format/test_dovecot.py::TestParsingMethods::test_make_template", - "tests/templates/format/test_json.py::TestParsingMethods::test_if_input_document_contains_just_few_parameters_and_parameter_blocks__the_initialised_object_contains_correct_dictionary", - "tests/templates/format/test_json.py::TestParsingMethods::test_joining_documents_1", - "tests/templates/format/test_json.py::TestParsingMethods::test_make_template", - "tests/templates/format/test_kde.py::TestParsingMethods::test_if_input_document_contains_just_few_parameter_lines__the_initialised_object_contains_correct_dictionary", - "tests/templates/format/test_kde.py::TestParsingMethods::test_if_input_document_contains_parameters_with_values_with_unicode_symbols__the_initialized_object_contains_correct_dictionary", - "tests/templates/format/test_kde.py::TestParsingMethods::test_if_input_document_contains_few_parameter_lines_and_some_empty_lines__the_initialized_object_contains_correct_dictionary", - "tests/templates/format/test_kde.py::TestParsingMethods::test_if_input_document_contains_sections_with_different_names_but_different_parameters__the_parameters_merged_in_one_section", - "tests/templates/format/test_kde.py::TestParsingMethods::test_if_input_document_contains_sections_with_parameters_with_action_marks__the_key_tuples_of_object_s_dictionary_have_it_as_its_first_element", - "tests/templates/format/test_kde.py::TestParsingMethods::test_if_parameter_in_input_document_has_some_comments__the_comments_will_be_collected_in_the_list_of_parameter_value", - "tests/templates/format/test_kde.py::TestParsingMethods::test_if_the_IgnoreComments_flag_is_set__the_parser_ignores_all_comments", - "tests/templates/format/test_kde.py::TestParsingMethods::test_if_input_document_contains_parameters_to_delete_without_assign_symbol_and_any_values_and_sections_to_delete__the_document_object_contains_dictionary_with_item_to_delete", - "tests/templates/format/test_kde.py::TestParsingMethods::test_joining_documents_1", - "tests/templates/format/test_kde.py::TestParsingMethods::test_make_template", - "tests/templates/format/test_kernel.py::TestParsingMethods::test_if_input_document_contains_just_few_parameter_lines__the_initialised_object_contains_correct_dictionary", - "tests/templates/format/test_kernel.py::TestParsingMethods::test_if_input_document_contains_few_parameter_lines_and_some_empty_lines__the_initialized_object_contains_correct_dictionary", - "tests/templates/format/test_kernel.py::TestParsingMethods::test_if_input_document_contains_parameters_with_action_marks__the_key_tuples_of_object_s_dictionary_have_it_as_its_first_element", - "tests/templates/format/test_kernel.py::TestParsingMethods::test_if_parameter_in_input_document_has_some_comments__the_comments_will_be_collected_in_the_list_of_parameter_value", - "tests/templates/format/test_kernel.py::TestParsingMethods::test_if_input_document_contains_parameters_to_delete_without_assign_symbol_and_any_values__the_document_object_contains_dictionary_with_item_to_delete", - "tests/templates/format/test_kernel.py::TestParsingMethods::test_joining_documents_1", - "tests/templates/format/test_kernel.py::TestParsingMethods::test_make_template", - "tests/templates/format/test_ldap.py::TestParsingMethods::test_if_logiclines_method_takes_text_with_lines_that_starts_whit_space_symbols__it_returns_joined_lines", - "tests/templates/format/test_ldap.py::TestParsingMethods::test_if_input_doc_contains_some_type_sections_with_plain_directives__object_dictionary_contains_correct_dictionary_with_directives_values_and_comments", - "tests/templates/format/test_ldap.py::TestParsingMethods::test_if_input_document_contains_access_to_directive__the_object_s_dictionary_contains_correct_dictionary_with_list_of_access_to_parameters_and_comments", - "tests/templates/format/test_ldap.py::TestParsingMethods::test_if_input_document_contains_syncrepl_directive__the_object_s_dictionary_contains_correct_dictionary_with_list_of_syncrepl_parameters_and_comments", - "tests/templates/format/test_ldap.py::TestParsingMethods::test_if_input_document_contains_index_directives__the_object_s_dictionary_contains_correct_dictionary_with_index_elements_and_comments", - "tests/templates/format/test_ldap.py::TestParsingMethods::test_if_input_document_contains_comments_to_type_sections__the_object_s_dictionary_collect_them", - "tests/templates/format/test_ldap.py::TestParsingMethods::test_if_input_doc_contains_some_type_sections_with_plain_directives_and_action_marks__object_dictionary_contains_correct_dictionary_with_directives_values_and_comments", - "tests/templates/format/test_ldap.py::TestParsingMethods::test_if_template_text_contains_some_access_to_constuctions_with_same_what_value_and_without_action_marks_for_whole_constructions__they_join_in_one_access_to_construction", - "tests/templates/format/test_ldap.py::TestParsingMethods::test_if_input_document_contains_syncrepl_and_access_to_constructions_with_action_marks__object_dictionary_contains_correct_dictionary_with_action_marks", - "tests/templates/format/test_ldap.py::TestParsingMethods::test_joining_documents_1", - "tests/templates/format/test_openrc.py::TestParsingMethods::test_if_input_document_contains_just_few_parameter_lines__the_initialised_object_contains_correct_dictionary", - "tests/templates/format/test_openrc.py::TestParsingMethods::test_if_input_document_contains_few_parameter_lines_and_some_empty_lines__the_initialized_object_contains_correct_dictionary", - "tests/templates/format/test_openrc.py::TestParsingMethods::test_if_input_document_contains_parameters_with_action_marks__the_key_tuples_of_object_s_dictionary_have_it_as_its_first_element", - "tests/templates/format/test_openrc.py::TestParsingMethods::test_if_parameter_in_input_document_has_some_comments__the_comments_will_be_collected_in_the_list_of_parameter_value", - "tests/templates/format/test_openrc.py::TestParsingMethods::test_if_the_IgnoreComments_flag_is_set__the_parser_ignores_all_comments", - "tests/templates/format/test_openrc.py::TestParsingMethods::test_if_input_document_contains_parameters_to_delete_without_assign_symbol_and_any_values__the_document_object_contains_dictionary_with_item_to_delete", - "tests/templates/format/test_openrc.py::TestParsingMethods::test_joining_documents_1", - "tests/templates/format/test_openrc.py::TestParsingMethods::test_make_template", - "tests/templates/format/test_postfix.py::TestParsingMethods::test_if_input_document_contains_just_few_parameter_lines__the_initialised_object_contains_correct_dictionary", - "tests/templates/format/test_postfix.py::TestParsingMethods::test_if_input_document_contains_few_parameter_lines_and_some_empty_lines__the_initialized_object_contains_correct_dictionary", - "tests/templates/format/test_postfix.py::TestParsingMethods::test_if_input_document_contains_parameters_with_action_marks__the_key_tuples_of_object_s_dictionary_have_it_as_its_first_element", - "tests/templates/format/test_postfix.py::TestParsingMethods::test_if_parameter_in_input_document_has_some_comments__the_comments_will_be_collected_in_the_list_of_parameter_value", - "tests/templates/format/test_postfix.py::TestParsingMethods::test_if_the_IgnoreComments_flag_is_set__the_parser_ignores_all_comments", - "tests/templates/format/test_postfix.py::TestParsingMethods::test_if_input_document_contains_parameters_to_delete_without_assign_symbol_and_any_values__the_document_object_contains_dictionary_with_item_to_delete", - "tests/templates/format/test_postfix.py::TestParsingMethods::test_joining_documents_1", - "tests/templates/format/test_postfix.py::TestParsingMethods::test_make_template", - "tests/templates/format/test_procmail.py::TestParsingMethods::test_if_input_document_contains_just_few_parameter_lines__the_initialised_object_contains_correct_dictionary", - "tests/templates/format/test_procmail.py::TestParsingMethods::test_if_input_document_contains_few_parameter_lines_and_some_empty_lines__the_initialized_object_contains_correct_dictionary", - "tests/templates/format/test_procmail.py::TestParsingMethods::test_if_input_document_contains_parameters_with_action_marks__the_key_tuples_of_object_s_dictionary_have_it_as_its_first_element", - "tests/templates/format/test_procmail.py::TestParsingMethods::test_if_parameter_in_input_document_has_some_comments__the_comments_will_be_collected_in_the_list_of_parameter_value", - "tests/templates/format/test_procmail.py::TestParsingMethods::test_if_the_IgnoreComments_flag_is_set__the_parser_ignores_all_comments", - "tests/templates/format/test_procmail.py::TestParsingMethods::test_if_input_document_contains_parameters_to_delete_without_assign_symbol_and_any_values__the_document_object_contains_dictionary_with_item_to_delete", - "tests/templates/format/test_procmail.py::TestParsingMethods::test_joining_documents_1", - "tests/templates/format/test_procmail.py::TestParsingMethods::test_make_template", - "tests/templates/format/test_proftpd.py::TestParsingMethods::test_if_input_document_contains_just_few_parameter_lines__the_initialised_object_contains_correct_dictionary", - "tests/templates/format/test_proftpd.py::TestParsingMethods::test_if_input_document_contains_some_block_of_parameters__the_initialised_object_contains_correct_dictionary", - "tests/templates/format/test_proftpd.py::TestParsingMethods::test_if_input_document_contains_blocks_and_parameters_with_action_marks__the_key_tuples_of_parameters_s_have_it_as_its_first_element_inherited", - "tests/templates/format/test_proftpd.py::TestParsingMethods::test_if_parameters_and_blocks_in_input_document_has_some_comments__the_comments_will_be_collected_in_the_list_of_parameter_value_or_with_special_key_in_block_dictionary", - "tests/templates/format/test_proftpd.py::TestParsingMethods::test_if_the_ignoreComments_flag_is_set__the_parser_ignores_all_comments", - "tests/templates/format/test_proftpd.py::TestParsingMethods::test_if_input_document_contains_parameters_to_delete_without_any_values_the_document_object_contains_dictionary_with_this_items_to_delete", - "tests/templates/format/test_proftpd.py::TestParsingMethods::test_joining_documents_1", - "tests/templates/format/test_regex.py::TestParsingMethods::test_if_input_patch_document_contains_only_regular_expressions_without_any_regex_flags__it_correctly_patches_input_document", - "tests/templates/format/test_regex.py::TestParsingMethods::test_if_input_patch_document_contains_regular_expressions_with_global_regex_flags_and_flags_as_attributes__it_correctly_patches_input_document_using_regex_flags", - "tests/templates/format/test_samba.py::TestParsingMethods::test_if_input_document_contains_just_few_parameter_lines__the_initialised_object_contains_correct_dictionary", - "tests/templates/format/test_samba.py::TestParsingMethods::test_if_input_document_contains_few_parameter_lines_and_some_empty_lines__the_initialized_object_contains_correct_dictionary", - "tests/templates/format/test_samba.py::TestParsingMethods::test_if_input_document_contains_sections_with_similar_names_but_different_parameters__the_parameters_merged_in_one_section", - "tests/templates/format/test_samba.py::TestParsingMethods::test_if_input_document_contains_sections_with_parameters_with_action_marks__the_key_tuples_of_object_s_dictionary_have_it_as_its_first_element", - "tests/templates/format/test_samba.py::TestParsingMethods::test_if_parameter_in_input_document_has_some_comments__the_comments_will_be_collected_in_the_list_of_parameter_value", - "tests/templates/format/test_samba.py::TestParsingMethods::test_if_the_IgnoreComments_flag_is_set__the_parser_ignores_all_comments", - "tests/templates/format/test_samba.py::TestParsingMethods::test_if_input_document_contains_parameters_to_delete_without_assign_symbol_and_any_values_and_sections_to_delete__the_document_object_contains_dictionary_with_item_to_delete", - "tests/templates/format/test_samba.py::TestParsingMethods::test_if_joinBefore_flag_is_set__the_document_object_contains_dictionary_with_sections_added_in_the_top_of_it", - "tests/templates/format/test_samba.py::TestParsingMethods::test_if_input_document_parameters_contains_upper_case_symbols__it_becomes_lower_case", - "tests/templates/format/test_samba.py::TestParsingMethods::test_joining_documents_1", - "tests/templates/format/test_samba.py::TestParsingMethods::test_make_template", - "tests/templates/format/test_xml_gconf.py::TestParsingMethods::test_if_input_document_is_simple_gconf_tree__the_format_object_contains_correct_dictionary", - "tests/templates/format/test_xml_gconf.py::TestParsingMethods::test_if_input_document_is_simple_gconf__the_format_object_contains_correct_dictionary", - "tests/templates/format/test_xml_gconf.py::TestParsingMethods::test_joining_documents_1", - "tests/templates/format/test_xml_xfce.py::TestParsingMethods::test_if_input_document_contains_just_few_parameter_lines__the_initialised_object_contains_correct_dictionary", - "tests/templates/format/test_xml_xfce.py::TestParsingMethods::test_joining_documents_1", - "tests/utils/test_files.py::TestUtils::test_if_single_correct_command_executed_using_Process_object__it_successfully_executes", - "tests/utils/test_files.py::TestUtils::test_if_pipe_is_executed_using_Process_object__it_has_successfully_executed", - "tests/utils/test_files.py::TestUtils::test_if_a_pipe_Process_object_uses_for_several_writes_without_readings__it_successfully_executes", - "tests/utils/test_files.py::TestUtils::test_if_a_pipe_Process_object_uses_for_several_writes__it_successfully_executes_even_after_read", - "tests/utils/test_package.py::TestContents::test_if_two_Version_objects_compared_using_lt_operation_and_the_left_version_value_is_less_than_the_right_version__the_result_of_the_comparing_would_be_True", - "tests/utils/test_package.py::TestContents::test_if_two_Version_objects_compared_using_le_operation_and_the_left_version_value_is_less_than_or_equal_to_the_right_version__the_result_of_the_comparing_would_be_True", - "tests/utils/test_package.py::TestContents::test_if_two_Version_objects_compared_using_gt_operation_and_the_left_version_value_is_less_than_the_right_version__the_result_of_the_comparing_would_be_True", - "tests/utils/test_package.py::TestContents::test_if_two_Version_objects_compared_using_ge_operation_and_the_left_version_value_is_less_than_or_equal_to_the_right_version__the_result_of_the_comparing_would_be_True", - "tests/utils/test_package.py::TestContents::test_if_two_Version_objects_compared_using_ne_operation_and_the_left_version_value_is_less_than_or_equal_to_the_right_version__the_result_of_the_comparing_would_be_True", - "tests/utils/test_package.py::TestContents::test_if_two_Version_objects_compared_using_eq_operation_and_the_left_version_value_is_less_than_or_equal_to_the_right_version__the_result_of_the_comparing_would_be_True", - "tests/utils/test_package.py::TestContents::test_if_PackageContents_object_initialized_by_existing_package__it_contains_dictionary_of_items_from_contents_file", - "tests/utils/test_package.py::TestContents::test_if_PackageContents_object_contains_contents_dictionary__it_renders_CONTENTS_file_correctly", - "tests/utils/test_package.py::TestContents::test_if_new_directory_is_added_in_contents_file_using_add_dir_method__the_PackageContents_object_renders_the_contents_file_with_new_dir", - "tests/utils/test_package.py::TestContents::test_if_new_object_is_added_in_contents_file_using_add_obj_method__the_PackageContents_object_renders_the_contents_file_with_new_obj", - "tests/utils/test_package.py::TestContents::test_if_new_link_is_added_in_contents_file_using_add_sym_method__the_PackageContents_object_renders_the_contents_file_with_new_sym", - "tests/utils/test_package.py::TestContents::test_if_the_PackageAtom_object_parsed_a_correct_package_atom_name_but_without_a_slot_and_use_flags__the_PackageAtom_object_returns_atom_name_of_package", - "tests/utils/test_package.py::TestContents::test_if_the_PackageAtom_object_parsed_a_correct_package_atom_name_with_a_slot_value__the_PackageAtom_returns_atom_name_of_package_with_this_slot", - "tests/utils/test_package.py::TestContents::test_if_the_PackageAtom_object_parsed_a_correct_package_atom_name_with_an_empty_slot_value__the_PackageAtom_object_returns_atom_name_of_package", - "tests/utils/test_package.py::TestContents::test_if_the_PackageAtom_object_parsed_a_correct_package_atom_name_with_a_uses_value__the_PackageAtom_object_returns_atom_name_of_package_with_this_use_flags", - "tests/utils/test_package.py::TestContents::test_if_the_PackageAtom_object_parses_a_correct_package_atom_name_without_version_value_but_with_slot_value__the_PackageAtom_object_looks_for_package_with_assigned_slot_value", - "tests/utils/test_package.py::TestContents::test_if_the_PackageAtom_object_parses_a_correct_package_atom_name_without_version_value_but_with_use_flags_value__the_PackageAtom_object_looks_for_package_with_assigned_use_flags", - "tests/utils/test_package.py::TestContents::test_if_the_PackageAtom_object_tried_to_parse_an_incorrect_package_atom_name__the_PackageAtom_object_throws_the_PackageAtomError_exception", - "tests/utils/test_package.py::TestContents::test_if_the_PackageAtom_object_tried_to_parse_an_package_atom_name_with_incorrect_use_flags__the_PackageAtom_object_throws_the_PackageAtomError_exception", - "tests/utils/test_package.py::TestContents::test_if_the_PackageAtom_object_tried_to_parse_an_correct_package_atom_name_that_matches_multiple_packages__the_PackageAtom_object_gets_info_for_package_with_older_version", - "tests/utils/test_package.py::TestContents::test_if_the_get_file_package_method_of_the_PackageAtom_object_is_called_with_a_name_of_a_file_that_belongs_to_any_package__the_PackageAtom_object_contains_dictionary_with_an_owner_package", - "tests/utils/test_package.py::TestContents::test_if_the_get_file_package_method_of_the_PackageAtom_object_is_called_with_a_name_of_a_file_that_does_not_belong_to_any_package__the_PackageAtom_object_throws_the_PackageAtomError_exception", - "tests/vars/test_namespace.py::TestNamespace::test_init_empty_namespace", - "tests/vars/test_namespace.py::TestNamespace::test_init_default_path" -] \ No newline at end of file diff --git a/.pytest_cache/v/cache/stepwise b/.pytest_cache/v/cache/stepwise deleted file mode 100644 index 0637a08..0000000 --- a/.pytest_cache/v/cache/stepwise +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/calculate/utils/calculateini.py b/calculate/utils/calculateini.py new file mode 100644 index 0000000..bb0e5a3 --- /dev/null +++ b/calculate/utils/calculateini.py @@ -0,0 +1,104 @@ +from pyparsing import (Literal, Word, ZeroOrMore, Group, Dict, Optional, + restOfLine, empty, printables, OneOrMore, oneOf, nums, lineno, line, col, + Keyword, SkipTo, LineEnd, Combine) + +from enum import Enum + +class CalculateIniParser: + """ + ΠŸΠ°Ρ€ΡΠ΅Ρ€ Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π° calculate.ini + """ + class Define(Enum): + Assign = 0 + Append = 1 + Remove = 2 + + def __init__(self): + lbrack = Literal("[").suppress() + rbrack = Literal("]").suppress() + + comma = Literal(",").suppress() + commentStart = oneOf("; #") + Define = self.Define + valueOp = Literal("=") | Combine( + Literal("+") + Literal("=")) | Combine( + Literal("-") + Literal("=")) + + comment = commentStart + Optional( restOfLine) + + nonrbrack = "".join( [c for c in printables if c != "]" ]) + " \t" + nonvalueop = "".join( [c for c in printables if c not in {"=","-","+"} ]) + " \t" + noncomma = "".join( [c for c in printables if c != "," ]) + clearsection = lbrack + Group(empty) + rbrack + + sectionDef = Group(OneOrMore(lbrack + Word(nonrbrack) + rbrack) + + (clearsection | ~lbrack ) + LineEnd().suppress()) + + unexpected = Group(~sectionDef + SkipTo(LineEnd(), include=True))("error") + unexpected.setParseAction(self._unexpected_token) + + keyDef = ~lbrack + Word(nonvalueop) + valueOp + empty + restOfLine + LineEnd().suppress() + + def stripKeyValue(tokens): + tokens[0] = tokens[0].strip() + tokens[1] = tokens[1].strip() + + keyDef.setParseAction(stripKeyValue) + + self.inibnf = sectionDef + Group(ZeroOrMore(Group(keyDef | unexpected))) | unexpected + self.inibnf.ignore( comment ) + + def _unexpected_token(self, st, locn, tokString): + erline = line(locn,st).strip() + if erline: + self.parseError(erline, + lineno(locn,st), + col(locn,st)) + + def parse(self, data): + for tokens,start,end in self.inibnf.scanString(data): + if tokens.getName() == "error": + continue + section, defkeys = tokens + sectionList = section.asList() + if sectionList[-1] == []: + self.clearSection(sectionList[:-1]) + continue + self.startSection(section.asList()) + for defkey in defkeys: + if defkey.getName() == "error": + continue + mapOp = {"=": self.Define.Assign, + "+=": self.Define.Append, + "-=": self.Define.Remove } + self.defineKey(section.asList(), + defkey[0], defkey[2], + mapOp[defkey[1]]) + + def startSection(self, section): + """ + Начало сСкции + """ + + def clearSection(self, section): + """ + ΠžΡ‡ΠΈΡΡ‚ΠΊΠ° Π·Π½Π°Ρ‡Π΅Π½ΠΈΠΉ сСкции + """ + + def defineKey(self, section, defkey, defval, deftype): + """ + ΠžΠΏΡ€Π΅Π΄Π΅Π»Π΅Π½ΠΈΠ΅ ΠΊΠ»ΡŽΡ‡Π° + + ['section','block'] 'varname', 'varval', Define.Assign + """ + pass + + def parseError(self, line, lineno, col): + """ + Ошибка Π² Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π΅ + + line - ΠΏΡ€ΠΈΠΌΠ΅Ρ€ строки + lineno - Π½ΠΎΠΌΠ΅Ρ€ строки + col - Π½ΠΎΠΌΠ΅Ρ€ символа + """ + pass diff --git a/calculate/utils/files.py b/calculate/utils/files.py index 6d5f5b2..1086299 100644 --- a/calculate/utils/files.py +++ b/calculate/utils/files.py @@ -7,6 +7,15 @@ from .tools import GenericFS, get_traceback_caller from glob import glob import os import sys +import contextlib + +def listDirectory(dn, fullpath=False): + if path.exists(dn): + if fullpath: + return [path.join(dn,x) for x in os.listdir(dn)] + else: + return os.listdir(dn) + return [] class FilesError(Exception): @@ -551,3 +560,12 @@ def get_run_commands(not_chroot=False, chroot=None, uid=None, with_pid=False): else: output.append(cmdline) return output + +@contextlib.contextmanager +def stderr_devnull(): + oldstderr = sys.stderr + sys.stderr = open(os.devnull, 'w') + try: + yield + finally: + sys.stderr = oldstderr diff --git a/calculate/utils/fs.py b/calculate/utils/fs.py new file mode 100644 index 0000000..51fe70b --- /dev/null +++ b/calculate/utils/fs.py @@ -0,0 +1,19 @@ +import os +from os.path import exists + +def readlink(path): + try: + return os.readlink(path) + except FileNotFoundError: + return None + +def readFileLines(path): + if exists(path): + with open(path, 'r') as f: + for line in f: + yield line.rstrip("\n") + +def readFile(path): + if exists(path): + with open(path, 'r') as f: + return f.read() diff --git a/calculate/utils/gentoo.py b/calculate/utils/gentoo.py new file mode 100644 index 0000000..8c9f993 --- /dev/null +++ b/calculate/utils/gentoo.py @@ -0,0 +1,28 @@ +import os +import re +import calculate.utils.fs as fs + +class ProfileWalker: + """ + ΠžΠ±ΡŠΠ΅ΠΊΡ‚ обходящий всС Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΎΡ€ΠΈΠΈ профиля Ρ‡Π΅Ρ€Π΅Π· parent Ρ„Π°ΠΉΠ»Ρ‹ + """ + def __init__(self, filename, repositories): + self.repositories = repositories + self.filename = filename + self.reReppath = re.compile("^(%s)+:"%"|".join(self.repositories.keys())) + + def interpolate(self, path): + def subfunc(m): + return "%s/profiles/" % self.repositories.get(m.group(1)) + return self.reReppath.sub(subfunc, path) + + def find(self, directory): + parent = os.path.join(directory, "parent") + for line in (x for x in fs.readFileLines(parent) if x.strip()): + parentdir = os.path.normpath( + os.path.join(directory, self.interpolate(line))) + if fs.exists(parentdir): + yield from self.find(parentdir) + findfile = os.path.normpath(os.path.join(directory, self.filename)) + if fs.exists(findfile): + yield findfile diff --git a/calculate/vars/datavars.py b/calculate/vars/datavars.py index 972a523..e81eb85 100644 --- a/calculate/vars/datavars.py +++ b/calculate/vars/datavars.py @@ -1,51 +1,528 @@ import site import os +import re +import sys +import types +import functools +from contextlib import contextmanager +_ = lambda x:x -class Variable: - def __init__(self): - pass + +class BaseClass: + BASE_CLASS = "BaseClass" + + @classmethod + def isImplementation(cls, check_class): + """ + ΠŸΡ€ΠΎΠ²Π΅Ρ€ΠΈΡ‚ΡŒ, Ρ‡Ρ‚ΠΎ класс являСтся ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄Π½Ρ‹ΠΌ Π±Π°Π·ΠΎΠ²ΠΎΠ³ΠΎ класса, Π° + Π½Π΅ самим Π±Π°Π·ΠΎΠ²Ρ‹ΠΌ, ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅Ρ‚ΡΡ Π² Π°Π²Ρ‚ΠΎΠ·Π°Π³Ρ€ΡƒΠ·ΠΊΠ΅ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹Ρ… ΠΈΠ· ΠΌΠΎΠ΄ΡƒΠ»Π΅ΠΉ + """ + if isinstance(check_class, type) and issubclass(check_class, cls): + if check_class.BASE_CLASS == cls.BASE_CLASS and \ + check_class.__name__ != cls.BASE_CLASS: + return True + return False + +class VariableError(Exception): + pass + +class VariableNotFoundError(VariableError): + pass + +class CyclicVariableError(VariableError): + def __init__(self, *queue): + self.queue = queue + + def __str__(self): + return _("Cyclic dependence in variables: %s") % ", ".join(self.queue[:-1]) + + +class VariableProperty: + def __init__(self, parent): + self.parent = parent + +class StringVariable(VariableProperty): + pass + +class ListVariable(VariableProperty): + def setValue(self, value, force=False): + if isinstance(value, (list, tuple)): + return value + elif isinstance(value, str): + return value.split(",") + else: + raise VariableError( + _("The value of variable '{varname}' must be list").format( + varname=self.parent.name)) + + def post_get(self, value): + return value + +class ReadonlyVariable(VariableProperty): + def setValue(self, value, force=False): + if not force: + raise VariableError( + _("Attempting to rewrite readonly variable %s")%self.parent.name) + return value + +class IntegerVariable(VariableProperty): + reMatch = re.compile(r"^-?\d+$") + + def check(self, value): + if value and not self.reMatch.match(value): + raise VariableError( + _("The value of variable '{varname}' must be integer").format( + varname=self.parent.name)) + + def post_get(self, value): + return int(value) + +class BooleanVariable(VariableProperty): + def post_get(self, value): + return value == "true" + +class ChoiceVariable(VariableProperty): + def check(self, value): + choices = self.parent.choice() + if value and value not in choices: + raise VariableError( + _("The value for variable '{varname}' may be " + "{vartype}").format( + varname=self.parent.name, + vartype=",".join(choices))) + + def choice(self): + if self.parent.__class__.choice == Variable.choice and \ + self.parent.__class__.choiceComment == Variable.choiceComment: + raise VariableError(_("Wrong choice variable %s") + % self.parent.name) + return [x[0] for x in self.parent.choiceComment()] + + def choiceComment(self): + return [(x,x) for x in self.parent.choice()] + +class DefaultValue(VariableProperty): + def __init__(self, value): + self.value = value + self.parent = None + + def getValue(self, invalidate_subs=None): + if self.parent._value is None: + self.parent._unsubscribe_depends() + self.parent._value = self.value + +class IniCreated(DefaultValue): + pass + +class Variable(BaseClass): + BASE_CLASS = "Variable" + + On = "on" + Off = "off" + value = "" + + class Type: + Bool = "bool" + List = "list" + String = "string" + Integer = "int" + Choice = "choice" + + properties = (StringVariable,) + + def __init__(self, name): + self.name = name + self._value = None + self.vars = None + self.invalidate_subs = set() + self.depends = set() + self.calculating = False + self._properties = [x(self) for x in self.properties] + # вСрсия значСния ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΠΎΠΉ, Ссли пСрСмСнная со Π²Ρ€Π΅ΠΌΠ΅Π½ получСния + # значСния успСла ΠΎΠ±Π½ΠΎΠ²ΠΈΡ‚ΡŒΡΡ, ΠΈΡΠΊΠ»ΡŽΡ‡ΠΈΡ‚ΡŒ сброс Π΅Π΅ значСния + + @property + def fullname(self): + return "%s.%s" % (self.vars.getFullname(), self.name) + + def addProperty(self, prop): + prop.parent = self + self._properties.insert(0, prop) + + def findProperty(self, propclass): + for prop in self._properties: + if isinstance(prop, propclass): + return prop + else: + return None + + def _emit_invalidate(self, slots): + for f in slots: + f() + + def _unsubscribe_depends(self): + for dependvar in self.depends: + dependvar.update_unsubscribe(self.invalidate) + self.depends = set() + + def update_subscribe(self, f_or_var): + if isinstance(f_or_var, Variable): + f_or_var.depends.add(self) + self.invalidate_subs.add(f_or_var.invalidate) + else: + self.invalidate_subs.add(f_or_var) + + def update_unsubscribe(self, f): + if f in self.invalidate_subs: + self.invalidate_subs.remove(f) + + def invalidate(self): + self._value = None + if self.invalidate_subs: + slots = self.invalidate_subs + self.invalidate_subs = set() + self._emit_invalidate(slots) + + def setParent(self, namespace): + self.vars = namespace + + @contextmanager + def _start_calculate(self): + try: + self.calculating = True + yield self + finally: + self.calculating = False + + def getValue(self, invalidate_sub=None): + for f in self.callProperties("getValue"): + f(invalidate_sub) + if self.calculating: + raise CyclicVariableError(self.name) + if self._value is None: + with self._start_calculate(): + try: + self._unsubscribe_depends() + self._value = self.get() + if isinstance(self._value, types.GeneratorType): + self._value = list(self._value) + except CyclicVariableError as e: + raise CyclicVariableError(self.name, *e.queue) + + if invalidate_sub is not None: + self.update_subscribe(invalidate_sub) + return self.post_get(self._value) + + def post_get(self, value): + for f in self.callProperties("post_get"): + ret = f(value) + if ret is not None: + return ret + return value + + def callProperties(self, fname, *args): + for prop in self._properties: + f = getattr(prop, fname, None) + if f: + yield f + + def setValue(self, value, force=False): + for f in self.callProperties("setValue"): + value = f(value, force) + value = self.set(value) + self.check(value) + self.invalidate() + self._value = value + self._unsubscribe_depends() + + def check(self, value): + """ + Ѐункция ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠΈ значСния устанавливаСмого значСния + """ + for f in self.callProperties("check"): + f(value) def get(self): """ Ѐункция заполнСния ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΠΎΠΉ """ - pass + return self.value + + def getCommentValue(self, invalidate_sub=None): + """ + Π­Ρ‚ΠΎΡ‚ ΠΌΠ΅Ρ‚ΠΎΠ΄ вызываСтся Π²Π½ΡƒΡ‚Ρ€ΠΈ ΠΌΠ΅Ρ‚ΠΎΠ΄ΠΎΠ² get + """ + val = self.getComment() + if invalidate_sub is not None: + self.update_subscribe(invalidate_sub) + return val + + def getComment(self): + """ + ΠšΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ ΠΊ Π·Π½Π°Ρ‡Π΅Π½ΠΈΡŽ + """ + for f in self.callProperties("getComment"): + return f() + return self.getValue() def set(self, value): """ Ѐункция ΠΌΠΎΠ΄ΠΈΡ„ΠΈΠΊΠ°Ρ†ΠΈΠΈ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΠΎΠΉ """ - pass + return value def choice(self): """ Ѐункция Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π΅Ρ‚ список доступных Π·Π½Π°Ρ‡Π΅Π½ΠΈΠΉ для ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΠΎΠΉ """ - pass + for f in self.callProperties("choice"): + return f() + return [] + + def choiceComment(self): + for f in self.callProperties("choiceComment"): + return f() + return [] - def check(self, value): - """ - Ѐункция ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠΈ значСния устанавливаСмого значСния - """ class NamespaceError(Exception): pass -class Namespace: - DefaultPath = "[default_path]" - def __init__(self, varPath=DefaultPath): - if varPath is Namespace.DefaultPath: - self.varPath = self._getMainPackage() + +class Namespace(BaseClass): + BASE_CLASS = "Namespace" + + def __init__(self, name="", parent=None): + self._name = name + self.variables = {} + self.childs = {} + self.parent = parent or self + self.root = self + self._nextns = 0 + + def getFullname(self): + if self.parent is not self and self.parent.parent is not self.parent: + return "%s.%s" % (self.parent.getFullname(), self._name) else: - self.varPath = varPath - self.childs = [] - - def _getMainPackage(self): - site_dirs = [os.path.normpath(x) for x in site.getsitepackages()] - for site_dir in site_dirs: - calculate_dir = os.path.join(site_dir, "calculate/vars") - if os.path.exists(calculate_dir): - return calculate_dir - - def findVariablePackages(self, dirPath): - pass + return self._name + + def __getattr__(self, name): + if name in self.childs: + return self.childs[name] + elif name in self.variables: + return self.variables[name] + else: + raise VariableNotFoundError( + _("Variable or namespace {varname} not found").format( + varname="%s.%s" % (self.getFullname(), name))) + + def clearChilds(self): + for child in self.childs.values(): + child.clearChilds() + self.childs = {} + + def __getitem__(self, name): + return getattr(self, str(name)) + + def __setitem__(self, name, value): + return getattr(self, str(name)).setValue(value) + + def __iter__(self): + """ + Π‘ΠΎΡ€Ρ‚ΠΈΡ€ΠΎΠ²ΠΊΠ°: Π²Π½Π°Ρ‡Π°Π»Π΅ числовыС ΠΊΠ»ΡŽΡ‡ΠΈ ΠΏΠΎΡ‚ΠΎΠΌ ΠΏΡ€ΠΎΡ‡ΠΈΠ΅ + """ + def sortkey(x): + k,v = x + if k.isdigit(): + return (0,int(k),k) + else: + return (1,0,k) + for k,v in sorted(self.childs.items(), key=sortkey): + yield v + + def __contains__(self, name): + return name in self.childs or name in self.variables + + def addStringVariable(self, varname, value): + var = Variable(varname) + var.value = value + var.setParent(self) + self.variables[varname] = var + + def addVariable(self, variable): + self.variables[variable.name] = variable + variable.setParent(self) + + def _getNextNamespaceName(self): + name = str(self._nextns) + while name in self.childs: + self._nextns += 1 + name = str(self._nextns) + return name + + def addNamespace(self, namespace=None, name=None): + if name is None: + if namespace is None: + name = self._getNextNamespaceName() + else: + name = namespace._name + if namespace is None: + namespace = Namespace(name) + self.childs[name] = namespace + namespace.parent = self + namespace.root = self.root + return namespace + +class HashVariable(Namespace): + """ + ΠŸΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Π°Ρ прСдставляСт собой ΡΠ»ΠΎΠ²Π°Ρ€ΡŒ + """ + BASE_CLASS = "HashVariable" + + class HashValue(Variable): + BASE_CLASS = "HashValue" + + def __init__(self, name, master_variable): + super().__init__(name) + self.parent = None + self.master_variable = master_variable + + def getValue(self, invalidate_sub=None): + return self.master_variable.getHashValue(self.name, invalidate_sub) + + def setValue(self, value, force=False): + return self.master_variable.setHashValue(self.name, value, force) + + def invalidate(self): + self.master_variable.invalidate() + + class Data(Variable): + BASE_CLASS = "Data" + def getHashValue(self, name, invalidate_sub=None): + return self.getValue(invalidate_sub)[name] + + def setHashValue(self, name, value, force): + if name in self.readonly_vars and not force: + raise VariableError( + _("Attempting to rewrite readonly variable %s")%name) + data = self.getValue().copy() + data[name] = value + self.setValue(data, force) + + def getValue(self, invalidate_sub=None): + return self.master_variable.getValue(invalidate_sub) + + hash_vars = [] + readonly_vars = [] + + def __init__(self, name, parent=None, hash_vars=None): + super().__init__(name) + if hash_vars is not None: + self.hash_vars = hash_vars + + self.parent = parent + if not self.hash_vars: + raise VariableError( + _("Missed '{attrname}' attribute for hash variable {varname}" + ).format(attrname = "hash_vars", + varname=self.getFullname())) + self.master_variable = self.Data(name) + self.master_variable.setParent(parent) + self.master_variable.readonly_vars = self.readonly_vars + for varname in self.hash_vars: + var = self.HashValue(varname, self.master_variable) + self.addVariable(var) + + def invalidate(self): + self.master_variable.invalidate() + + def getValue(self, invalidate_sub=None): + return self.master_variable.getValue(invalidate_sub) + + +class TableVariable(Namespace): + """ + ΠŸΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Π°Ρ прСдставляСт собой список словарСй + """ + BASE_CLASS = "TableVariable" + + class TableHashVariable(HashVariable): + BASE_CLASS = "TableHashVariable" + + def __init__(self, name, parent=None, hash_vars=None, + master_variable=None, index=None): + super().__init__(name, parent, hash_vars) + self.master_variable._index = index + + class Data(HashVariable.Data): + def getHashValue(self, name, invalidate_sub=None): + return self.vars.master_variable.getTableValue(name, self._index, + invalidate_sub) + + def setHashValue(self, name, value, force): + self.vars.master_variable.setTableValue(name, self._index, value, force) + + class Data(Variable): + BASE_CLASS = "Data" + + def getTableValue(self, name, index, invalidate_sub=None): + data = self.getValue(invalidate_sub) + return data[index][name] + + def setTableValue(self, name, index, value, force): + if name in self.readonly_vars and not force: + raise VariableError( + _("Attempting to rewrite readonly variable %s")%name) + data = [x.copy() for x in self.getValue()] + rowdata = data[index] + rowdata[name] = value + self.setValue(data, force) + + @property + def childs(self): + if self._childs is None: + value = self.master_variable.getValue() + self._childs = {} + for i, row in enumerate(value): + hashvar = self.TableHashVariable(self.master_variable.name, + self, self.hash_vars, self.master_variable, i) + self._childs[str(i)] = hashvar + return self._childs + + @childs.setter + def childs(self, value): + self._childs = value + + def getValue(self, invalidate_sub=None): + return self.master_variable.getValue(invalidate_sub) + + def setValue(self, value, force=False): + self.master_variable.setValue(value, force) + + def invalidate(self): + self.master_variable.invalidate() + + hash_vars = [] + readonly_vars = [] + + def _drop_childs(self): + self._childs = None + self.master_variable.update_subscribe(self._drop_childs) + + def clearChilds(self): + super().clearChilds() + self._drop_childs() + + def __init__(self, name, parent=None): + super().__init__(name) + self._childs = None + self.parent = parent + if not self.hash_vars: + raise VariableError( + _("Missed '{attrname}' attribute for table variable {varname}" + ).format(attrname = "hash_vars", + varname=self.getFullname())) + self.master_variable = self.Data(name) + self.master_variable.setParent(parent) + self.master_variable.readonly_vars = self.readonly_vars + self.master_variable.update_subscribe(self._drop_childs) diff --git a/calculate/vars/main/__init__.py b/calculate/vars/main/__init__.py new file mode 100644 index 0000000..820eb0c --- /dev/null +++ b/calculate/vars/main/__init__.py @@ -0,0 +1,5 @@ +from calculate.vars.datavars import Variable, ReadonlyVariable + +class Chroot(Variable): + properties = [ReadonlyVariable] + value = "/" diff --git a/calculate/vars/os/gentoo/__init__.py b/calculate/vars/os/gentoo/__init__.py index d3c252f..e3dfe00 100644 --- a/calculate/vars/os/gentoo/__init__.py +++ b/calculate/vars/os/gentoo/__init__.py @@ -1,4 +1,88 @@ -from calculate.vars.datavars import Variable +from calculate.vars.datavars import Variable, ChoiceVariable, HashVariable, TableVariable, Namespace +from calculate.utils.files import stderr_devnull +import calculate.utils.fs as fs +import os -class Profile(Variable): - pass +""" +gentoo + make_profile + profile.path + profile.name + repositories[*].name + repositories[*].path + config +""" + +class MakeProfile(Variable): + """ + ΠŸΡƒΡ‚ΡŒ Π΄ΠΎ Ρ„Π°ΠΉΠ»Π°, ΡƒΠΊΠ°Π·Ρ‹Π²Π°ΡŽΡ‰Π΅Π³ΠΎ Π½Π° Π°ΠΊΡ‚ΠΈΠ²Π½Ρ‹ΠΉ ΠΏΡ€ΠΎΡ„ΠΈΠ»ΡŒ + """ + value = '/etc/portage/make.profile' + +class Profile(Namespace): + """ + ΠŸΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹ Ρ‚Π΅ΠΊΡƒΡ‰Π΅Π³ΠΎ профиля + """ + class Path(Variable): + """ + ΠΠ±ΡΠΎΠ»ΡŽΡ‚Π½Ρ‹ΠΉ ΠΏΡƒΡ‚ΡŒ Π΄ΠΎ профиля + """ + def get(self): + make_profile = self.vars.parent.make_profile.getValue(self) + make_profile_dir = os.path.dirname(make_profile) + profileLink = fs.readlink(make_profile) + if profileLink: + profileLink = os.path.normpath( + os.path.join(make_profile_dir,profileLink)) + return profileLink + else: + return "" + + class Name(Variable): + """ + НазваниС профиля + """ + def get(self): + profile_path = self.vars.path.getValue(self) + if not profile_path: + return "" + repositories = self.vars.parent.repositories + for rep in repositories: + reppath = rep.path.getValue(self) + repname = rep.name.getValue(self) + removepart = os.path.normpath(os.path.join(reppath,"profiles")) + if profile_path.startswith(removepart): + return "%s:%s"%( + repname, + profile_path[len(removepart)+1:]) + return profile_path + +class Repositories(TableVariable): + """ + Π˜Π½Ρ„ΠΎΡ€ΠΌΠ°Ρ†ΠΈΡ ΠΎ рСпозиториях + + name: имя рСпозитория + path: ΠΏΠΎΠ»Π½Ρ‹ΠΉ ΠΏΡƒΡ‚ΡŒ Π΄ΠΎ рСпозитория + """ + class Data(TableVariable.Data): + def get(self): + config = self.vars.config.getValue(self) + return [ + { + 'name': name, + 'path': path + } + for path, name in config.repositories.location_map.items() + ] + hash_vars = ["name", "path"] + +class Config(Variable): + """ + ΠžΠ±ΡŠΠ΅ΠΊΡ‚ Ρ‚Π΅ΠΊΡƒΡ‰Π΅ΠΉ ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΠΈ Portage + """ + def get(self): + from portage.package.ebuild.config import config + chroot_path = self.vars.root.main.chroot.getValue(self) + if chroot_path == '/': + with stderr_devnull(): + return config() diff --git a/calculate/vars/vars_loader.py b/calculate/vars/vars_loader.py new file mode 100644 index 0000000..5752a39 --- /dev/null +++ b/calculate/vars/vars_loader.py @@ -0,0 +1,217 @@ +from calculate.utils.calculateini import CalculateIniParser +import re +import sys +import os +import importlib +import importlib.util +import site +from calculate.vars.datavars import Variable, Namespace, HashVariable, TableVariable, IniCreated, DefaultValue +from calculate.utils.gentoo import ProfileWalker +from calculate.utils.fs import readFile +from calculate.utils.files import listDirectory + +class NamespaceIniFiller(CalculateIniParser): + """ + ΠžΠ±ΡŠΠ΅ΠΊΡ‚ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅ΠΌΡ‹ΠΉ для наполСния Namespace ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π° ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹ΠΌΠΈ + ΠΈΠ· calculate.ini Ρ„Π°ΠΉΠ»Π° + """ + def error(self, lineno, s): + self.errors.append(lineno, s) + + def fill(self, ns, data): + self.ns = ns + self.curns = self.ns + self.errors = [] + self.parse(data) + + def startSection(self, sections): + self.curns = self.ns + for section in sections: + if section not in self.curns.childs: + self.curns.addNamespace(Namespace(section)) + self.curns = self.curns[section] + + def clearSection(self, sections): + curns = self.ns + for section in sections: + if section not in curns.childs: + return + curns = curns[section] + curns.clearChilds() + + def changeValue(self, key, value): + self.curns[key].setValue(value) + + def defineVariable(self, key, value): + self.curns.addStringVariable(key, value) + + def appendValue(self, key, value): + l = self.curns[key].getValue().split(",") + vlist = value.split(",") + for v in vlist: + if v not in l: + l.append(v) + self.changeValue(key,",".join(l)) + + def removeValue(self, key, value): + l = self.curns[key].getValue().split(",") + vlist = value.split(",") + for v in vlist: + if v in l: + l.remove(v) + self.changeValue(key,",".join(l)) + + def defineKey(self, section, key, value, optype): + Define = CalculateIniParser.Define + if optype == Define.Assign: + if key not in self.curns: + self.defineVariable(key, value) + else: + self.changeValue(key, value) + elif optype == Define.Append: + if key not in self.curns: + self.defineVariable(key, value) + else: + self.appendValue(key, value) + elif optype == Define.Remove: + if key not in self.curns: + self.defineVariable(key, value) + else: + self.removeValue(key, value) + + def parseError(self, line, lineno, col): + self.error(lineno, _("Syntax error: %s") % line) + +class NamespaceIniFillerStrict(NamespaceIniFiller): + """ + ΠžΠ±ΡŠΠ΅ΠΊΡ‚ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅ΠΌΡ‹ΠΉ для наполСния Namespace ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π° ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹ΠΌΠΈ + ΠΈΠ· calculate.ini Ρ„Π°ΠΉΠ»Π°, с Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡ‚ΡŒ ΠΎΠΏΡ€Π΅Π΄Π΅Π»ΡΡ‚ΡŒ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ + """ + availableSection = ["custom"] + + def fill(self, ns, data): + self.canCreate = False + for newns in self.availableSection: + if newns not in ns: + ns.addNamespace(Namespace(newns)) + super().fill(ns, data) + + def startSection(self, sections): + self.curns = self.ns + self.canCreate = sections[0] in self.availableSection + for section in sections: + if section not in self.curns.childs: + if isinstance(self.curns, TableVariable) or self.canCreate: + self.curns.addNamespace(Namespace(section)) + else: + self.curns = None + self.curns = self.curns[section] + + #def clearSection(self, sections): + # curns = self.ns + # self.canCreate = sections[0] in self.availableSection + # for section in sections: + # if section not in curns.childs: + # return + # curns = curns[section] + # curns.clearChilds() + + + def defineVariable(self, key, value): + if not self.canCreate: + pass + var = Variable(key) + var.addProperty(IniCreated(value)) + self.curns.addVariable(var) + + def changeValue(self, key, value): + var = self.curns[key] + var.setValue(value) + + if isinstance(var, HashVariable.HashValue): + var = var.master_variable + value = var.getValue() + + prop = var.findProperty(DefaultValue) + if prop: + prop.value = value + else: + var.addProperty(DefaultValue(value)) + var.invalidate() + +class VariableLoader: + """ + ΠžΠ±ΡŠΠ΅ΠΊΡ‚ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅ΠΌΡ‹ΠΉ для Π·Π°Π³Ρ€ΡƒΠ·ΠΊΠΈ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹Ρ… ΠΈΠ· python модуля + """ + reUpper = re.compile("(.)([A-Z])") + + def _getVarlikeAttrs(self, obj): + """ + ΠŸΠΎΠ»ΡƒΡ‡ΠΈΡ‚ΡŒ список Π°Ρ‚Ρ‚Ρ€ΠΈΠ±ΡƒΡ‚ΠΎΠ² ΠΏΠΎΡ…ΠΎΠΆΠΈΡ… Π½Π° ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹Π΅ + """ + for attrname in (x for x in dir(obj) if x[:1].isupper()): + yield self.reUpper.sub(r"\1_\2", attrname).lower(), \ + getattr(obj, attrname) + + def fill(self, ns, dirpath, package): + """ + Π—Π°Π³Ρ€ΡƒΠ·ΠΈΡ‚ΡŒ Π² namespace ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹Π΅ ΠΈΠ· ΡƒΠΊΠ°Π·Π°Π½Π½Ρ‹Ρ… ΠΌΠΎΠ΄ΡƒΠ»Π΅ΠΉ + """ + for fullfn in listDirectory(dirpath, fullpath=True): + dn, fn = os.path.split(fullfn) + if os.path.isdir(fullfn): + newns = ns.addNamespace(Namespace(fn)) + self.fill(newns, fullfn, "%s.%s"%(package,fn)) + elif fn.endswith(".py"): + module = self._load_module_source(package, fn, fullfn) + for varname, cls in self._getVarlikeAttrs(module): + if Variable.isImplementation(cls): + ns.addVariable(cls(varname)) + elif HashVariable.isImplementation(cls) or \ + TableVariable.isImplementation(cls) or \ + Namespace.isImplementation(cls): + _newns = ns.addNamespace(cls(varname,ns)) + for _varname, _cls in self._getVarlikeAttrs(cls): + if Variable.isImplementation(_cls): + _newns.addVariable(_cls(_varname)) + + @classmethod + def default(cls): + site_dirs = [os.path.normpath(x) for x in site.getsitepackages()] + for site_dir in site_dirs: + calculate_dir = os.path.join(site_dir, "calculate/vars") + if os.path.exists(calculate_dir): + return (calculate_dir, "calculate.vars") + + def _load_module_source(self, package, name, path): + if name.startswith('calculate.vars.'): + full_name = name + else: + full_name = '.'.join([package, name]) + + if full_name in sys.modules: + return sys.modules[full_name] + + spec = importlib.util.spec_from_file_location(full_name, path) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + sys.modules[full_name] = module + return module + + +class ProfileFiller: + """ + Π—Π°ΠΏΠΎΠ»Π½ΠΈΡ‚Π΅Π»ΡŒ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠΉ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹Ρ… ΠΈΠ· Ρ„Π°ΠΉΠ»ΠΎΠ² calculate.ini Π² профилях + """ + basename = "calculate.ini" + def getRepositoryMap(self, ns): + return { + x.name.getValue(): x.path.getValue() + for x in ns.os.gentoo.repositories + } + + def fill(self, ns, profile_path): + nif = NamespaceIniFillerStrict() + pw = ProfileWalker(self.basename, self.getRepositoryMap(ns)) + for fn in pw.find(profile_path): + nif.fill(ns, readFile(fn)) diff --git a/pytest.ini b/pytest.ini index 95421ae..aa69364 100644 --- a/pytest.ini +++ b/pytest.ini @@ -25,6 +25,8 @@ markers = package_utils: marker for running tests for calculate.utils.contents module. vars: marker for running tests for datavars + gentoo: marker for running tests for utils.gentoo + calculateini: marker for running tests for utils.calculateini template_engine: marker for running tests for TemplateEngine. directory_processor: marker for running tests for DirectoryProcessor. template_executor: marker for running tests for TemplateAction. diff --git a/tests/utils/gentoo/portage/calculate.ini b/tests/utils/gentoo/portage/calculate.ini new file mode 100644 index 0000000..e69de29 diff --git a/tests/utils/gentoo/portage/profiles/calculate.ini b/tests/utils/gentoo/portage/profiles/calculate.ini new file mode 100644 index 0000000..e69de29 diff --git a/tests/utils/gentoo/portage/profiles/main/calculate.ini b/tests/utils/gentoo/portage/profiles/main/calculate.ini new file mode 100644 index 0000000..e69de29 diff --git a/tests/utils/gentoo/repos/calculate/profiles/calculate.ini b/tests/utils/gentoo/repos/calculate/profiles/calculate.ini new file mode 100644 index 0000000..e69de29 diff --git a/tests/utils/gentoo/repos/calculate/profiles/default/20/calculate.ini b/tests/utils/gentoo/repos/calculate/profiles/default/20/calculate.ini new file mode 100644 index 0000000..e69de29 diff --git a/tests/utils/gentoo/repos/calculate/profiles/default/amd64/20/calculate.ini b/tests/utils/gentoo/repos/calculate/profiles/default/amd64/20/calculate.ini new file mode 100644 index 0000000..e69de29 diff --git a/tests/utils/gentoo/repos/calculate/profiles/default/amd64/20/desktop/calculate.ini b/tests/utils/gentoo/repos/calculate/profiles/default/amd64/20/desktop/calculate.ini new file mode 100644 index 0000000..e69de29 diff --git a/tests/utils/gentoo/repos/calculate/profiles/default/amd64/20/desktop/parent b/tests/utils/gentoo/repos/calculate/profiles/default/amd64/20/desktop/parent new file mode 100644 index 0000000..08bf1a2 --- /dev/null +++ b/tests/utils/gentoo/repos/calculate/profiles/default/amd64/20/desktop/parent @@ -0,0 +1,3 @@ +gentoo:main +.. +../../../desktop diff --git a/tests/utils/gentoo/repos/calculate/profiles/default/amd64/20/parent b/tests/utils/gentoo/repos/calculate/profiles/default/amd64/20/parent new file mode 100644 index 0000000..0c34ef3 --- /dev/null +++ b/tests/utils/gentoo/repos/calculate/profiles/default/amd64/20/parent @@ -0,0 +1,2 @@ +.. +../../20 diff --git a/tests/utils/gentoo/repos/calculate/profiles/default/amd64/calculate.ini b/tests/utils/gentoo/repos/calculate/profiles/default/amd64/calculate.ini new file mode 100644 index 0000000..e69de29 diff --git a/tests/utils/gentoo/repos/calculate/profiles/default/amd64/parent b/tests/utils/gentoo/repos/calculate/profiles/default/amd64/parent new file mode 100644 index 0000000..f3229c5 --- /dev/null +++ b/tests/utils/gentoo/repos/calculate/profiles/default/amd64/parent @@ -0,0 +1 @@ +.. diff --git a/tests/utils/gentoo/repos/calculate/profiles/default/calculate.ini b/tests/utils/gentoo/repos/calculate/profiles/default/calculate.ini new file mode 100644 index 0000000..e69de29 diff --git a/tests/utils/gentoo/repos/calculate/profiles/default/desktop/calculate.ini b/tests/utils/gentoo/repos/calculate/profiles/default/desktop/calculate.ini new file mode 100644 index 0000000..e69de29 diff --git a/tests/utils/gentoo/repos/calculate/profiles/default/parent b/tests/utils/gentoo/repos/calculate/profiles/default/parent new file mode 100644 index 0000000..f3229c5 --- /dev/null +++ b/tests/utils/gentoo/repos/calculate/profiles/default/parent @@ -0,0 +1 @@ +.. diff --git a/tests/utils/gentoo/repos/distros/profiles/CLD/amd64/calculate.ini b/tests/utils/gentoo/repos/distros/profiles/CLD/amd64/calculate.ini new file mode 100644 index 0000000..ae500d1 --- /dev/null +++ b/tests/utils/gentoo/repos/distros/profiles/CLD/amd64/calculate.ini @@ -0,0 +1,2 @@ +[os][linux] +arch = amd64 diff --git a/tests/utils/gentoo/repos/distros/profiles/CLD/amd64/parent b/tests/utils/gentoo/repos/distros/profiles/CLD/amd64/parent new file mode 100644 index 0000000..06dfeaf --- /dev/null +++ b/tests/utils/gentoo/repos/distros/profiles/CLD/amd64/parent @@ -0,0 +1,2 @@ +calculate:default/amd64/20/desktop +.. diff --git a/tests/utils/gentoo/repos/distros/profiles/CLD/calculate.ini b/tests/utils/gentoo/repos/distros/profiles/CLD/calculate.ini new file mode 100644 index 0000000..ec50aa7 --- /dev/null +++ b/tests/utils/gentoo/repos/distros/profiles/CLD/calculate.ini @@ -0,0 +1,21 @@ +[os][linux] +ver = 20 +shortname = CLD +fullname = Calculate Linux Desktop +subname = KDE + +[os][hashvar] +value1 = 20 +value2 = 30 + +[os][tablevar][0] +dev = /dev/sda1 +mount = swap + +[os][tablevar][1] +dev = /dev/sda2 +mount = / + +[os][tablevar][2] +dev = /dev/sda5 +mount = /var/calculate diff --git a/tests/utils/gentoo/repos/distros/profiles/CLD/parent b/tests/utils/gentoo/repos/distros/profiles/CLD/parent new file mode 100644 index 0000000..f3229c5 --- /dev/null +++ b/tests/utils/gentoo/repos/distros/profiles/CLD/parent @@ -0,0 +1 @@ +.. diff --git a/tests/utils/gentoo/repos/distros/profiles/CLDX/amd64/calculate.ini b/tests/utils/gentoo/repos/distros/profiles/CLDX/amd64/calculate.ini new file mode 100644 index 0000000..e69de29 diff --git a/tests/utils/gentoo/repos/distros/profiles/CLDX/amd64/parent b/tests/utils/gentoo/repos/distros/profiles/CLDX/amd64/parent new file mode 100644 index 0000000..06dfeaf --- /dev/null +++ b/tests/utils/gentoo/repos/distros/profiles/CLDX/amd64/parent @@ -0,0 +1,2 @@ +calculate:default/amd64/20/desktop +.. diff --git a/tests/utils/gentoo/repos/distros/profiles/CLDX/calculate.ini b/tests/utils/gentoo/repos/distros/profiles/CLDX/calculate.ini new file mode 100644 index 0000000..e69de29 diff --git a/tests/utils/gentoo/repos/distros/profiles/CLDX/parent b/tests/utils/gentoo/repos/distros/profiles/CLDX/parent new file mode 100644 index 0000000..f3229c5 --- /dev/null +++ b/tests/utils/gentoo/repos/distros/profiles/CLDX/parent @@ -0,0 +1 @@ +.. diff --git a/tests/utils/gentoo/repos/distros/profiles/calculate.ini b/tests/utils/gentoo/repos/distros/profiles/calculate.ini new file mode 100644 index 0000000..fab3c3c --- /dev/null +++ b/tests/utils/gentoo/repos/distros/profiles/calculate.ini @@ -0,0 +1,3 @@ +[os][linux] +shortname = Calculate +test = test diff --git a/tests/utils/test_calculateini.py b/tests/utils/test_calculateini.py new file mode 100644 index 0000000..64576c5 --- /dev/null +++ b/tests/utils/test_calculateini.py @@ -0,0 +1,130 @@ +import pytest +from mock import call +from calculate.utils.calculateini import CalculateIniParser +Define = CalculateIniParser.Define + + +@pytest.mark.calculateini +class TestCalculateIni: + def test_empty_calculate_ini(self): + pass + #ns = Namespace(varPath=None) + #assert ns.varPath is None + + def test_section_values(self, mocker): + cip = CalculateIniParser() + spy_section = mocker.spy(cip, 'startSection') + spy_def_key = mocker.spy(cip, 'defineKey') + spy_error = mocker.spy(cip, 'parseError') + + cip.parse("[section]\n" + "varval1 = value1\n") + + spy_error.assert_not_called() + spy_section.assert_has_calls([call(['section'])]) + spy_def_key.assert_has_calls([ + call(['section'],'varval1', 'value1', Define.Assign),]) + + def test_simple_calculate_ini_with_comments(self, mocker): + cip = CalculateIniParser() + spy_section = mocker.spy(cip, 'startSection') + spy_def_key = mocker.spy(cip, 'defineKey') + spy_error = mocker.spy(cip, 'parseError') + + cip.parse("[section]\n" + "varval1 = value1\n" + "# some comment\n" + "varval2 += value2\n" + "varval3 -= value3\n") + spy_error.assert_not_called() + spy_section.assert_has_calls([call(['section'])]) + spy_def_key.assert_has_calls([ + call(['section'],'varval1', 'value1', Define.Assign), + call(['section'],'varval2', 'value2', Define.Append), + call(['section'],'varval3', 'value3', Define.Remove), + ]) + + + def test_some_complex_section_calculate_ini(self, mocker): + cip = CalculateIniParser() + spy_section = mocker.spy(cip, 'startSection') + spy_def_key = mocker.spy(cip, 'defineKey') + spy_error = mocker.spy(cip, 'parseError') + + cip.parse("[section][sub]\n" + "varval1 = value1\n" + "varval2 = value2\n" + "[section][sub2]\n" + "varval1 = value1\n" + "\n" + "[section2]\n" + "varval1 = value1\n" + ) + + spy_error.assert_not_called() + spy_section.assert_has_calls([call(['section','sub'])]) + spy_section.assert_has_calls([call(['section','sub2'])]) + spy_section.assert_has_calls([call(['section2'])]) + spy_def_key.assert_has_calls([ + call(['section', 'sub'],'varval1','value1', Define.Assign), + call(['section', 'sub'],'varval2','value2', Define.Assign), + call(['section', 'sub2'],'varval1','value1', Define.Assign), + call(['section2'],'varval1','value1', Define.Assign), + ]) + + def test_error(self, mocker): + cip = CalculateIniParser() + spy_section = mocker.spy(cip, 'startSection') + spy_def_key = mocker.spy(cip, 'defineKey') + spy_error = mocker.spy(cip, 'parseError') + + cip.parse("[section\n" + "varval1 = value1\n" + "varval2 = value2\n" + "[section][sub2]\n" + "varval1 = value1\n" + "eee\n" + "\n" + "[section2\n" + "varval4 = value4\n" + "[section][]\n" + "[section][][sub]\n" + "[section][][sub][]\n" + ) + # провСряСм, Ρ‡Ρ‚ΠΎ Ρ€Π°ΡΠΎΠ·Π½Π°Π»Π°ΡΡŒ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ ΠΎΠ΄Π½Π° сСкция + spy_section.assert_has_calls([call(['section','sub2'])]) + # провСряСм, Ρ‡Ρ‚ΠΎ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ ΠΈΠ· ΠΊΡ€ΠΈΠ²ΠΎ ΠΎΠΏΡ€Π΅Π΄Π΅Π»Ρ‘Π½Π½ΠΎΠΉ section2 ΠΏΠΎΠΏΠ°Π»ΠΎ + # Π² section.sub2 + spy_def_key.assert_has_calls([ + call(['section', 'sub2'],'varval1','value1', Define.Assign), + call(['section', 'sub2'],'varval4','value4', Define.Assign), + ]) + # провСряСм, всС нСраспознанныС строки ΠΏΠΎΠΏΠ°Π»ΠΈ Π² ошибки + # ΠΊΡ€ΠΈΠ²ΠΎ объявлСнная пСрвая сСкция + # Π΅Ρ‘ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹Π΅ + # кривая пСрСмСнная eee + # ΠΊΡ€ΠΈΠ²ΠΎ объявлСнная section2 + spy_error.assert_has_calls([ + call('[section', 1, 1), + call('varval1 = value1', 2, 1), + call('varval2 = value2', 3, 1), + call('eee', 6, 1), + call('[section2', 8, 1), + call('[section][][sub]', 11, 1), + call('[section][][sub][]', 12, 1) + ]) + + def test_clear_section(self, mocker): + cip = CalculateIniParser() + spy_section = mocker.spy(cip, 'startSection') + spy_def_key = mocker.spy(cip, 'defineKey') + spy_error = mocker.spy(cip, 'parseError') + spy_clear_sec = mocker.spy(cip, 'clearSection') + + cip.parse("[section][test][]\n") + + spy_error.assert_not_called() + spy_def_key.assert_not_called() + spy_section.assert_not_called() + + spy_clear_sec.assert_has_calls([call(['section','test'])]) diff --git a/tests/vars/test_namespace.py b/tests/vars/test_namespace.py index 05cd0cf..dc7b3e7 100644 --- a/tests/vars/test_namespace.py +++ b/tests/vars/test_namespace.py @@ -1,12 +1,751 @@ import pytest -from calculate.vars.datavars import Namespace - +import os +from calculate.vars.datavars import Namespace, Variable, CyclicVariableError, VariableError, ReadonlyVariable, ChoiceVariable, IntegerVariable, StringVariable, DefaultValue, TableVariable, HashVariable, VariableNotFoundError +from calculate.vars.vars_loader import NamespaceIniFiller, VariableLoader, ProfileFiller, NamespaceIniFillerStrict @pytest.mark.vars class TestNamespace: def test_init_empty_namespace(self): - ns = Namespace(varPath=None) - assert ns.varPath is None + ns = Namespace() + assert ns.childs == {} + assert ns.variables == {} + + def test_create_variable(self): + ns = Namespace() + ns.addStringVariable("test", "12345") + assert ns.test.getValue() == "12345" + ns.addStringVariable("zxcv", "23456") + assert ns.zxcv.getValue() == "23456" + + def test_create_ns_with_vars(self): + ns = Namespace() + ns.addNamespace(Namespace("os")) + ns.os.addStringVariable("test", "123") + ns.os.addNamespace(Namespace("linux")) + ns.os.linux.addStringVariable("shortname", "CLD") + assert ns.os.test.getValue() == "123" + assert ns.os["test"].getValue() == "123" + assert ns.os.linux.shortname.getValue() == "CLD" + assert ns.os.root == ns + + def test_fill_namespace_simple(self): + ns = Namespace() + nsif = NamespaceIniFiller() + nsif.fill(ns, """ + [os] + test = 123 + + [os][linux] + shortname = CLD + fullname = Calculate Linux Desktop + """) + + assert ns.os.test.getValue() == "123" + assert ns.os.linux.shortname.getValue() == "CLD" + assert ns.os.linux.fullname.getValue() == "Calculate Linux Desktop" + assert ns.os.linux.root == ns + + nsif.fill(ns,""" + [os][linux] + shortname = CLDX + """) + + assert ns.os.linux.shortname.getValue() == "CLDX" + assert ns.os.linux.fullname.getValue() == "Calculate Linux Desktop" + + def test_fill_namespace_append_and_remove(self): + ns = Namespace() + nsif = NamespaceIniFiller() + nsif.fill(ns, """ + [os] + test = 123 + + [os] + test += 345 + """) + + assert ns.os.test.getValue() == "123,345" + + nsif.fill(ns, """ + [os] + test -= 123 + """) + + assert ns.os.test.getValue() == "345" + + nsif.fill(ns, """ + [os] + test += asdf,qwer,zxcv + """) + + assert ns.os.test.getValue() == "345,asdf,qwer,zxcv" + + nsif.fill(ns, """ + [os] + test -= asdf,zxcv + """) + + assert ns.os.test.getValue() == "345,qwer" + + def test_fill_namespace_clear_namespaces(self): + ns = Namespace() + nsif = NamespaceIniFiller() + nsif.fill(ns, """ + [test][0] + dev = /dev/sda1 + mount = swap + + [test][1] + dev = /dev/sda2 + mount = / + + [test][2] + dev = /dev/sda5 + mount = /var/calculate + """) + + assert [x.dev.getValue() for x in ns.test] == ['/dev/sda1', '/dev/sda2', '/dev/sda5'] + + nsif.fill(ns, """ + [test][0] + dev = /dev/sdb1 + mount = swap + + [test][1] + dev = /dev/sdb2 + mount = / + """) + + assert [x.dev.getValue() for x in ns.test] == ['/dev/sdb1', '/dev/sdb2', '/dev/sda5'] + + nsif.fill(ns, """ + [test][] + + [test][0] + dev = /dev/sdb1 + mount = swap + + [test][1] + dev = /dev/sdb2 + mount = / + """) + + assert [x.dev.getValue() for x in ns.test] == ['/dev/sdb1', '/dev/sdb2'] + + def test_fill_namespace_strict_clear(self): + ns = Namespace() + nsif = NamespaceIniFiller() + nsif.fill(ns, """ + [os][test][0] + dev = /dev/sda1 + mount = swap + + [os][test][1] + dev = /dev/sda2 + mount = / + + [os][test][2] + dev = /dev/sda5 + mount = /var/calculate + + [custom][test] + zxcv = 1 + + [custom][test2] + zxcv = 2 + """) + + assert ns.custom.test.zxcv.getValue() == "1" + assert ns.custom.test2.zxcv.getValue() == "2" + + nsifs = NamespaceIniFillerStrict() + nsifs.fill(ns, """ + [os][test][] + + [custom][] + """) + + assert [x for x in ns.custom ] == [] + + + + + def test_get_namespace_attrs(self): + ns = Namespace() + os = Namespace("os") + os.addStringVariable("test","zxcv") + ns.addNamespace(os) + + assert ns.os.test.getValue() == "zxcv" + assert ns.os["test"].getValue() == "zxcv" + assert "test" in ns.os + ns.os.test.setValue("123") + assert ns.os.test.getValue() == "123" + ns.os["test"].setValue("234") + assert ns.os.test.getValue() == "234" + + def test_variable_get_value(self): + class TestVar(Variable): + def get(self): + return "A" + + var = TestVar("test") + + assert var.getValue() == "A" + + def test_namespace_lookup(self): + ns = Namespace() + os = Namespace("os") + device = Namespace("device") + linux = Namespace("linux") + ns.addNamespace(os) + os.addNamespace(linux) + os.addNamespace(device) + device1 = device.addNamespace() + device1.addStringVariable("dev","/dev/sda") + device2 = device.addNamespace() + device2.addStringVariable("dev","/dev/sdb") + device3 = device.addNamespace() + device3.addStringVariable("dev","/dev/sdc") + + ns.addStringVariable("first", "first") + os.addStringVariable("second", "second") + linux.addStringVariable("third", "third") + + assert ns.first.getValue() == "first" + assert ns.root.os.second.getValue() == "second" + assert ns.os.second.getValue() == "second" + assert os.root.os.second.getValue() == "second" + assert os.second.getValue() == "second" + assert linux.third.getValue() == "third" + assert linux.root.os.second.getValue() == "second" + + with pytest.raises(VariableNotFoundError): + z = os.third + + assert ns.os.device[0].dev.getValue() == "/dev/sda" + assert ns.os.device["0"].dev.getValue() == "/dev/sda" + assert ns.os.device[1].dev.getValue() == "/dev/sdb" + assert ns.os.device[2].dev.getValue() == "/dev/sdc" + + assert ns.os.device.parent.second.getValue() == "second" + assert ns.os.device.parent.parent.os.second.getValue() == "second" + assert ns.os.device.parent.parent.parent.os.second.getValue() == "second" + + def test_variable_get_value_by_variable(self): + class TestVar1(Variable): + def get(self): + return "%s,B" % self.vars.test2.getValue(self) + + class TestVar2(Variable): + def get(self): + return "A" + + ns = Namespace() + ns.addVariable(TestVar1("test1")) + ns.addVariable(TestVar2("test2")) + + assert ns.test1.getValue() == "A,B" + + def test_variable_get_value_by_changed_variable(self): + class TestVar1(Variable): + counter = 0 + + def get(self): + self.counter += 1 + return "%s,B" % self.vars.test2.getValue(self) + + ns = Namespace() + test1 = TestVar1("test1") + ns.addVariable(test1) + ns.addStringVariable("test2", "A") + + assert ns.test1.getValue() == "A,B" + + assert test1.counter == 1 + # test for get cached variable value + assert ns.test1.getValue() == "A,B" + assert test1.counter == 1 + + # change value of test2 for recalculate test1 + ns.test2.setValue("C") + assert ns.test1.getValue() == "C,B" + assert test1.counter == 2 + + # change value of test2 for recalculate test1 + ns.test2.setValue("D") + assert ns.test1.getValue() == "D,B" + assert test1.counter == 3 + + def test_cyclic_variable(self): + + class TestVar1(Variable): + def get(self): + return "%s,test1" % self.vars.test2.getValue(self) + + class TestVar2(Variable): + def get(self): + return "%s,test2" % self.vars.test3.getValue(self) + + class TestVar3(Variable): + def get(self): + return "%s,test3" % self.vars.test1.getValue(self) + + test1 = TestVar1("test1") + test2 = TestVar2("test2") + test3 = TestVar3("test3") + + ns = Namespace() + ns.addVariable(test1) + ns.addVariable(test2) + ns.addVariable(test3) + + with pytest.raises(CyclicVariableError) as e: + z = ns.test1.getValue() + assert e.value.queue[:-1] == ("test1","test2","test3") + with pytest.raises(VariableError) as e: + z = ns.test1.getValue() + + def test_drop_invalidate_after_set_value(self): + class TestVar1(Variable): + counter = 0 + + def get(self): + self.counter += 1 + return "%s,test1" % self.vars.test2.getValue(self) + + class TestVar2(Variable): + def get(self): + return "ZZZZ" + + test1 = TestVar1("test1") + test2 = TestVar2("test2") + ns = Namespace() + ns.addVariable(test1) + ns.addVariable(test2) + + assert test1.getValue() == "ZZZZ,test1" + + test1.setValue("VVVV") + + assert test1.getValue() == "VVVV" + assert test1.counter == 1 + + test2.setValue("XXXX") + + assert test1.getValue() == "VVVV" + assert test1.counter == 1 + + test1.invalidate() + + assert test1.getValue() == "XXXX,test1" + assert test1.counter == 2 + + def test_change_invalidator_variable(self): + class VarTest(Variable): + counter = 0 + def get(self): + self.counter += 1 + + if self.vars.ifvar.getValue(self): + return "%s,test1" % self.vars.vara.getValue(self) + else: + return "%s,test1" % self.vars.varb.getValue(self) + + vartest = VarTest("vartest") + ns = Namespace() + ns.addVariable(vartest) + ns.addStringVariable("vara", "vara") + ns.addStringVariable("varb", "varb") + ns.addStringVariable("ifvar", "true") + + assert vartest.getValue() == "vara,test1" + assert vartest.counter == 1 + + ns.vara.setValue("varc") + assert vartest.getValue() == "varc,test1" + assert vartest.counter == 2 + + ns.ifvar.setValue("") + assert vartest.getValue() == "varb,test1" + assert vartest.counter == 3 + + ns.vara.setValue("vard") + assert vartest.getValue() == "varb,test1" + assert vartest.counter == 3 + + def test_readonly_varaible(self): + class TestVar1(Variable): + properties = [ReadonlyVariable, StringVariable] + + def get(self): + return "test1" + + test1 = TestVar1("test1") + assert test1.getValue() == "test1" + + with pytest.raises(VariableError) as e: + test1.setValue("test2") + + assert test1.getValue() == "test1" + test1.setValue("test2", force=True) + assert test1.getValue() == "test2" + + def test_choice_variable(self): + class TestVar1(Variable): + properties = [ChoiceVariable] + + def choice(self): + return ["test1", "test2"] + + test1 = TestVar1("test1") + with pytest.raises(VariableError) as e: + test1.setValue("test3") + test1.setValue("test2") + assert test1.getValue() == "test2" + + def test_integer_variable(self): + class TestVar1(Variable): + properties = [IntegerVariable] + + test1 = TestVar1("test1") + with pytest.raises(VariableError) as e: + test1.setValue("test3") + test1.setValue("33") + assert test1.getValue() == 33 + test1.setValue("-33") + assert test1.getValue() == -33 + + def test_default_value_property(self): + class TestVar1(Variable): + def get(self): + return "123" + + test1 = TestVar1("test1") + assert test1.getValue() == "123" + + test1.setValue("987") + test1.addProperty(DefaultValue("567")) + + assert test1.getValue() == "987" + test1.invalidate() + assert test1.getValue() == "567" + + def test_get_comment(self): + class TestVar1(Variable): + def get(self): + return "123" + + class TestVar2(Variable): + def get(self): + return "234" + + def getComment(self): + return "[%s]" % self.getValue() + + class TestVar3(Variable): + def get(self): + return "ZXC %s" % self.vars.test2.getCommentValue(self) + + + ns = Namespace() + test1 = TestVar1("test1") + assert test1.getValue() == "123" + assert test1.getComment() == "123" + + test2 = TestVar2("test2") + assert test2.getValue() == "234" + assert test2.getComment() == "[234]" + + test3 = TestVar3("test3") + ns.addVariable(test1) + ns.addVariable(test2) + ns.addVariable(test3) + + assert test3.getValue() == "ZXC [234]" + test2.setValue("567") + assert test3.getValue() == "ZXC [567]" + + def test_wrong_choice_varaible(self): + class TestVar1(Variable): + properties = [ChoiceVariable] + + class TestVar2(Variable): + properties = [ChoiceVariable] + + def choice(self): + return ["test1","test2"] + + class TestVar3(Variable): + properties = [ChoiceVariable] + + def choiceComment(self): + return [("test1", "Test1"), + ("test2", "Test2")] + + test1 = TestVar1("test1") + test2 = TestVar2("test2") + test3 = TestVar3("test3") + + with pytest.raises(VariableError) as e: + test1.choice() + with pytest.raises(VariableError) as e: + test1.choiceComment() + + assert test2.choice() == ["test1","test2"] + assert test2.choiceComment() == [("test1","test1"),("test2","test2")] + + assert test3.choice() == ["test1","test2"] + assert test3.choiceComment() == [("test1","Test1"),("test2","Test2")] + + def test_loading_test_variable_module(self): + ns = Namespace() + vl = VariableLoader() + vl.fill(ns, "tests/vars/variables", "testvars") + + assert ns.level.simple.getValue() == "simple value" + assert ns.level.uselocalsimple.getValue() == "Using simple value" + assert ns.level.usefullsimple.getValue() == "Using simple value" + + with pytest.raises(VariableError) as e: + ns.level.badchoice.choice() + + with pytest.raises(VariableError) as e: + ns.level.badchoice.choiceComment() + + assert ns.level.simple_choice.choice() == ["/dev/sda1", "/dev/sda2", "/dev/sda3"] + assert ns.level.comment_choice.choice() == ["/dev/sda1", "/dev/sda2", "/dev/sda3"] + assert ns.level.comment_choice.choiceComment() == [("/dev/sda1", "SWAP"), ("/dev/sda2","ROOT"), ("/dev/sda3","DATA")] + + ns.level.disks.setValue(["/dev/sda2", "/dev/sda1"]) + + assert ns.level.disks.getValue() == ["/dev/sda2", "/dev/sda1"] + + assert ns.level.comment_choice.choice() == ["/dev/sda2", "/dev/sda1"] + assert ns.level.comment_choice.choiceComment() == [("/dev/sda2","ROOT"), + ("/dev/sda1","SWAP")] + + assert ns.level is not ns.level.level2.root + assert ns is ns.level.level2.root + assert ns.level.level2.vargetter.getValue() == "/ test" + + def test_hash_variable(self): + # hash variable + ns = Namespace() + vl = VariableLoader() + vl.fill(ns, "tests/vars/variables", "testvars") + + + assert ns.level.linux.getFullname() == "level.linux" + assert ns.level.linux.ver.fullname == "level.linux.ver" + + assert ns.level.linux.ver.getValue() == "1.0" + assert ns.level.linux.shortname.getValue() == "CLD" + + # ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ° обновлСния значСния hash ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΠΎΠΉ ΠΏΡ€ΠΈ ΠΎΠ±Π½ΠΎΠ²Π»Π΅Π½ΠΈΠΈ + # значСния Ρƒ зависимой ΠΏΠ΅Ρ€Π΅ΠΌΠ½Π½ΠΎΠΉ + ns.level.version.setValue("2.0") + assert ns.level.linux.ver.getValue() == "2.0" + + # ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ° установки значСния hash ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΠΎΠΉ + ns.level.linux.ver.setValue("3.0") + assert ns.level.linux.ver.getValue() == "3.0" + + # послС установки хотя Π±Ρ‹ ΠΎΠ΄Π½ΠΎΠ³ΠΎ значСния Π² hash ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΠΎΠΉ + # ΠΎΠ±Π½ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΎΡΡ‚Π°Π»ΡŒΠ½Ρ‹Ρ… ΠΏΡ€Π΅ΠΊΡ€Π°Ρ‰Π°ΡŽΡ‚ΡΡ Π΄ΠΎ ΠΈΠ½Π²Π°Π»ΠΈΠ΄Π°Ρ†ΠΈΠΈ (Ρ‚Π°ΠΊ ΠΊΠ°ΠΊ + # значСния Ρ€Π°ΡΡΠΌΠ°Ρ‚Ρ€ΠΈΠ²Π°ΡŽΡ‚ΡΡ комплСксно) + ns.level.myshortname.setValue("CLDG") + assert ns.level.linux.shortname.getValue() == "CLD" + + # ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ° ΠΏΠΎΠΏΡ‹Ρ‚ΠΊΠΈ ΠΈΠ·ΠΌΠ΅Π½ΠΈΡ‚ΡŒ readonly ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΡƒΡŽ + with pytest.raises(VariableError) as e: + ns.level.linux.shortname.setValue("CLDX") + + # ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ° сбора значСния hash ΠΏΠ΅Ρ€Π΅ΠΌΠ½Π½ΠΎΠΉ + ns.level.linux.invalidate() + assert ns.level.linux.ver.getValue() == "2.0" + assert ns.level.linux.shortname.getValue() == "CLDG" + + assert ns.level.linux.test.getValue() == "my test - 2.0" + + # ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ° обновлСния значСния ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΠΎΠΉ, ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅ΡŽΡ‰Π΅ΠΉ ΠΎΠ΄Π½ΠΎ + # ΠΈΠ· Π·Π½Π°Ρ‡Π΅Π½ΠΈΠΉ hash ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΠΎΠΉ + assert ns.level.shortname_test.getValue() == "CLDG test" + ns.level.linux.shortname.setValue("CLDX",force=True) + assert ns.level.shortname_test.getValue() == "CLDX test" + + + def test_table_variable(self): + # table variable + ns = Namespace() + vl = VariableLoader() + vl.fill(ns, "tests/vars/variables", "testvars") + + assert ns.level.device[0].dev.getValue() == "/dev/sda" + assert ns.level.device[1].dev.getValue() == "/dev/sdb" + assert ns.level.device.getValue() == [ + {"dev":"/dev/sda", + "type":"hdd", + "name":"Samsung SSD" + }, + {"dev":"/dev/sdb", + "type":"flash", + "name":"Transcend 64GB" + }, + ] + assert ns.level.device[1].type.getValue() == "flash" + + # ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ° обновлСния списка пространства ΠΈΠΌΡ‘Π½ Ρƒ Ρ‚Π°Π±Π»ΠΈΡ‡Π½ΠΎΠΉ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΠΎΠΉ + ns.level.devicelist.setValue(["/dev/sda","/dev/sdb","/dev/sdc"]) + assert ns.level.device[2].type.getValue() == "usbhdd" + assert [x.type.getValue() for x in ns.level.device] == ["hdd", "flash", "usbhdd"] + + assert ns.level.device_child.getValue() == "hdd" + ns.level.devicelist.setValue(["/dev/sda","/dev/sdb"]) + ns.level.device[0].type.setValue("flash") + assert ns.level.device.getValue() == [ + {"dev":"/dev/sda", + "type":"flash", + "name":"Samsung SSD" + }, + {"dev":"/dev/sdb", + "type":"flash", + "name":"Transcend 64GB" + }, + ] + assert ns.level.device_child.getValue() == "flash" + + # послС установки хотя Π±Ρ‹ ΠΎΠ΄Π½ΠΎΠ³ΠΎ значСния Π² table ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΠΎΠΉ + # ΠΎΠ±Π½ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΎΡΡ‚Π°Π»ΡŒΠ½Ρ‹Ρ… ΠΏΡ€Π΅ΠΊΡ€Π°Ρ‰Π°ΡŽΡ‚ΡΡ Π΄ΠΎ ΠΈΠ½Π²Π°Π»ΠΈΠ΄Π°Ρ†ΠΈΠΈ (Ρ‚Π°ΠΊ ΠΊΠ°ΠΊ + # значСния Ρ€Π°ΡΡΠΌΠ°Ρ‚Ρ€ΠΈΠ²Π°ΡŽΡ‚ΡΡ комплСксно) + ns.level.devicelist.setValue(["/dev/sda","/dev/sdb","/dev/sdc"]) + assert [x.dev.getValue() for x in ns.level.device] == ["/dev/sda","/dev/sdb"] + ns.level.device.invalidate() + assert [x.dev.getValue() for x in ns.level.device] == ["/dev/sda","/dev/sdb","/dev/sdc"] + # ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΈΡ‚ΡŒ Π½Π° ΠΏΠΎΠ²Ρ‚ΠΎΡ€Π½ΠΎΠ΅ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠ΅, убСдится, Ρ‡Ρ‚ΠΎ _drop_child ΠΎΡ‚Ρ€Π°Π±Π°Ρ‚Ρ‹Π²Π°Π΅Ρ‚ + ns.level.devicelist.setValue(["/dev/sda","/dev/sdb","/dev/sdc", "/dev/sdd"]) + ns.level.device.invalidate() + assert [x.dev.getValue() for x in ns.level.device] == ["/dev/sda","/dev/sdb","/dev/sdc", "/dev/sdd"] + + def test_wrong_table_variable(self): + class Testtable(TableVariable): + class Data(TableVariable.Data): + def get(self): + return [{'dev':'123','name':'098'}] + + ns = Namespace() + ns.addNamespace(Namespace("test")) + ns.test.addNamespace(Namespace("test2")) + + with pytest.raises(VariableError) as e: + ns.test.test2.addNamespace(Testtable("testtable", ns.test.test2)) + assert str(e.value) == "Missed 'hash_vars' attribute for table variable test.test2.testtable" + + def test_wrong_hash_variable(self): + class Testhash(HashVariable): + class Data(HashVariable.Data): + def get(self): + return {'dev':'123','name':'098'} + + ns = Namespace() + ns.addNamespace(Namespace("test")) + ns.test.addNamespace(Namespace("test2")) + + with pytest.raises(VariableError) as e: + ns.test.test2.addNamespace(Testhash("testhash", ns.test.test2)) + assert str(e.value) == "Missed 'hash_vars' attribute for hash variable test.test2.testhash" + + def test_namespace_iteration(self): + ns = Namespace() + ns0 = ns.addNamespace() + ns0.addStringVariable("test", "123") + ns1 = ns.addNamespace() + ns1.addStringVariable("test", "234") + ns2 = ns.addNamespace() + ns2.addStringVariable("test", "456") + + assert [x.test.getValue() for x in ns] == ["123","234","456"] + + def test_subnamespace(self): + ns = Namespace() + vl = VariableLoader() + vl.fill(ns, "tests/vars/variables", "testvars") + + assert ns.level.level3.my_var1.getValue() == "testing" + assert ns.level.level3.myvar2.getValue() == "testing2" + + def test_variable_not_found(self): + ns = Namespace() + vl = VariableLoader() + vl.fill(ns, "tests/vars/variables", "testvars") + + with pytest.raises(VariableError) as e: + z = ns.level.level3.myvar3.getValue() + assert str(e.value) == "Variable or namespace level.level3.myvar3 not found" + + # TODO: тСст ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅Ρ‚ значСния Π½Π° ΠΊΠΎΠ½ΠΊΡ€Π΅Ρ‚Π½ΠΎΠΉ машинС + #def test_simple(self): + # ns = Namespace() + # vl = VariableLoader() + # vl.fill(ns, *VariableLoader.default()) + # # Π½ΡƒΠΆΠ½ΠΎ ΠΈΡΠΏΡ€Π°Π²ΠΈΡ‚ΡŒ тСст, Ρ‚Π°ΠΊ + # # assert [x.name.getValue() for x in ns.os.gentoo.repositories] == ["gentoo","distros","calculate","custom"] + # assert ns.os.gentoo.make_profile.getValue() == "/etc/portage/make.profile" + # assert ns.os.gentoo.profile.path.getValue() == "/var/db/repos/distros/profiles/CLD/amd64/20" + # assert ns.os.gentoo.profile.name.getValue() == "distros:CLD/amd64/20" + + def test_profile_filler(self): + ns = Namespace() + vl = VariableLoader() + vl.fill(ns, "tests/vars/variables", "testvars") + + class ProfileFillerTest(ProfileFiller): + def getRepositoryMap(self, ns): + curdir = os.getcwd() + return { + 'distros': os.path.join(curdir,"tests/utils/gentoo/repos/distros"), + 'calculate': os.path.join(curdir,"tests/utils/gentoo/repos/calculate"), + 'gentoo': os.path.join(curdir,"tests/utils/gentoo/portage"), + } + + assert ns.os.hashvar.value1.getValue() == "test1" + assert ns.os.hashvar.value2.getValue() == "test2" + + assert ns.os.tablevar[0].dev.getValue() == "/dev/sdb1" + assert ns.os.tablevar[1].dev.getValue() == "/dev/sdb2" + + pf = ProfileFillerTest() + pf.fill(ns, "tests/utils/gentoo/repos/distros/profiles/CLD/amd64") + + assert ns.os.linux.test.getValue() == "test" + assert ns.os.linux.arch.getValue() == "amd64" + + assert ns.os.linux.title.getValue() == "Calculate Linux Desktop KDE 20" + + # Hash + assert ns.os.hashvar.value1.getValue() == "20" + assert ns.os.hashvar.value2.getValue() == "30" + + ns.os.hashvar.value1.setValue("40") + assert ns.os.hashvar.value1.getValue() == "40" + ns.os.hashvar.value1.invalidate() + assert ns.os.hashvar.value1.getValue() == "20" + + # Table + assert ns.os.tablevar[0].dev.getValue() == "/dev/sda1" + assert ns.os.tablevar[1].dev.getValue() == "/dev/sda2" + assert ns.os.tablevar[2].dev.getValue() == "/dev/sda5" + ns.os.tablevar[0].dev.invalidate() + assert ns.os.tablevar[0].dev.getValue() == "/dev/sda1" + assert ns.os.tablevar[1].dev.getValue() == "/dev/sda2" + assert ns.os.tablevar[2].dev.getValue() == "/dev/sda5" + - def test_init_default_path(self): + def test_fill_namespace_by_module(self): ns = Namespace() + vl = VariableLoader() + vl.fill(ns, *VariableLoader.default()) + assert "os" in ns + assert "config" in ns.os.gentoo + assert "main" in ns + assert ns.os.gentoo.config.getValue() is not None diff --git a/tests/vars/variables/__init__.py b/tests/vars/variables/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/vars/variables/level/__init__.py b/tests/vars/variables/level/__init__.py new file mode 100644 index 0000000..0a0cc42 --- /dev/null +++ b/tests/vars/variables/level/__init__.py @@ -0,0 +1,102 @@ +from calculate.vars.datavars import Namespace, Variable, ChoiceVariable, ReadonlyVariable, ListVariable, HashVariable, TableVariable, ListVariable + +class Simple(Variable): + def get(self): + return "simple value" + +class Uselocalsimple(Variable): + def get(self): + return "Using %s" % self.vars.simple.getValue(self) + +class Usefullsimple(Variable): + def get(self): + return "Using %s" % self.vars.root.level.simple.getValue(self) + +class Badchoice(Variable): + properties = [ChoiceVariable] + +class Disks(Variable): + properties = [ListVariable] + + def get(self): + return ["/dev/sda1", "/dev/sda2", "/dev/sda3"] + + def getComment(self): + mymap = {'/dev/sda1':'SWAP', + '/dev/sda2':'ROOT', + '/dev/sda3':'DATA'} + return [mymap.get(x) for x in self.getValue()] + +class SimpleChoice(Variable): + properties = [ChoiceVariable] + + def choice(self): + return self.vars.disks.getValue(self) + +class CommentChoice(Variable): + properties = [ChoiceVariable] + + def choiceComment(self): + return list(zip(self.vars.disks.getValue(), + self.vars.disks.getComment())) + + +class Version(Variable): + value = "1.0" + +class Myshortname(Variable): + value = "CLD" + +class Linux(HashVariable): + class Data(HashVariable.Data): + def get(self): + return { + 'ver':self.vars.version.getValue(self), + 'shortname':self.vars.myshortname.getValue(self) + } + + class Test(Variable): + def get(self): + return "my test - %s" % self.vars.ver.getValue(self) + + readonly_vars = ['shortname'] + hash_vars = ["ver", "shortname"] + +class ShortnameTest(Variable): + def get(self): + return "{} test".format(self.vars.linux.shortname.getValue(self)) + +class Devicelist(Variable): + properties = [ListVariable] + def get(self): + return ["/dev/sda","/dev/sdb"] + +class Device(TableVariable): + class Data(TableVariable.Data): + def get(self): + mapData = {'/dev/sda': ["hdd", "Samsung SSD"], + '/dev/sdb': ["flash", "Transcend 64GB"], + '/dev/sdc': ["usbhdd", "WD 1TB"]} + defaultValue = ["hdd", "Unknown"] + return [ + {"dev":x, + "type":mapData.get(x,defaultValue)[0], + "name":mapData.get(x,defaultValue)[1]} + for x in self.vars.devicelist.getValue(self) + ] + + hash_vars = ["dev","type","name"] + readonly_vars = ["name"] + +class DeviceChild(Variable): + def get(self): + return self.vars.device[0].type.getValue(self) + +class Level3(Namespace): + class MyVar1(Variable): + def get(self): + return "testing" + + class Myvar2(Variable): + def get(self): + return "testing2" diff --git a/tests/vars/variables/level/level2/__init__.py b/tests/vars/variables/level/level2/__init__.py new file mode 100644 index 0000000..f7df888 --- /dev/null +++ b/tests/vars/variables/level/level2/__init__.py @@ -0,0 +1,5 @@ +from calculate.vars.datavars import Variable + +class Vargetter(Variable): + def get(self): + return "%s test" % self.vars.root.main.chroot.getValue(self) diff --git a/tests/vars/variables/main/__init__.py b/tests/vars/variables/main/__init__.py new file mode 100644 index 0000000..820eb0c --- /dev/null +++ b/tests/vars/variables/main/__init__.py @@ -0,0 +1,5 @@ +from calculate.vars.datavars import Variable, ReadonlyVariable + +class Chroot(Variable): + properties = [ReadonlyVariable] + value = "/" diff --git a/tests/vars/variables/os/__init__.py b/tests/vars/variables/os/__init__.py new file mode 100644 index 0000000..59b46cf --- /dev/null +++ b/tests/vars/variables/os/__init__.py @@ -0,0 +1,63 @@ +from calculate.vars.datavars import Variable, Namespace, HashVariable, TableVariable + + +class Linux(Namespace): + class Shortname(Variable): + value = "" + + class Ver(Variable): + value = "" + + class Fullname(Variable): + value = "" + + class Subname(Variable): + value = "" + + class Arch(Variable): + value = "" + + class Test(Variable): + value = "" + + class Title(Variable): + def get(self): + subname = self.vars.subname.getValue(self) + fullname = self.vars.fullname.getValue(self) + ver = self.vars.ver.getValue(self) + if subname: + return "%s %s %s" % (fullname, subname, ver) + else: + return "%s %s" % (fullname, ver) + +class Hashvar(HashVariable): + class Data(HashVariable.Data): + def get(self): + return { + 'value1': 'test1', + 'value2': 'test2', + } + + class Calculate(Variable): + def get(self): + return "%s %s" % ( + self.vars.value1.getValue(self), + self.vars.value2.getValue(self) + ) + + hash_vars = ["value1", "value2"] + +class Tablevar(TableVariable): + class Data(TableVariable.Data): + def get(self): + return [ + { + "dev": "/dev/sdb1", + "mount": "/", + }, + { + "dev": "/dev/sdb2", + "mount": "/var/calculate", + } + ] + hash_vars = ["dev", "mount"]