def __init__(self, project_path, command_path, user_variables=None, options=None, output_format=None, no_colour=False, ignore_dependencies=False): # project_path: absolute path to the base sceptre project folder # e.g. absolute_path/to/sceptre_directory self.project_path = normalise_path(project_path) # config_path: holds the project stack_groups # e.g {project_path}/config self.config_path = "config" # user definable later in v2 # command_path path to either stack group or stack # e.g. {project_path/config_path}/command_path self.command_path = normalise_path(command_path) self.normal_command_path = normalise_path(command_path) # config_file: stack group config. User definable later in v2 # e.g. {project_path/config/command_path}/config_file self.config_file = "config.yaml" # templates_path: holds tempaltes. User definable later in v2 # e.g. {project_path/}templates self.templates_path = "templates" self.user_variables = user_variables if user_variables else {} self.user_variables = user_variables\ if user_variables is not None else {} self.options = options if options else {} self.output_format = output_format if output_format else "" self.no_colour = no_colour if no_colour is True else False self.ignore_dependencies = ignore_dependencies if ignore_dependencies is True else False
def setup(self): """ Adds dependency to a Stack. """ dep_stack_name, self.output_key = self.argument.split("::") self.dependency_stack_name = normalise_path(dep_stack_name) self.stack.dependencies.append(self.dependency_stack_name)
def _resolve_template_path(self, template_path): """ Return the project_path joined to template_path as a string. Note that os.path.join defers to an absolute path if the input is absolute. """ return path.join(self.stack_group_config["project_path"], "templates", normalise_path(template_path))
def test_normalise_path_with_trailing_slash(self): with pytest.raises(PathConversionError): normalise_path( "this/path/is/invalid/" )
def test_normalise_path_with_trailing_backslash(self): with pytest.raises(PathConversionError): normalise_path( 'this\path\is\invalid\\' )
def test_normalise_path_with_leading_backslash(self): path = normalise_path('\\this\path\is\\valid') assert path == join("{}this".format(sep), "path", "is", "valid")
def test_normalise_path_with_leading_slash(self): path = normalise_path("/this/is/valid") assert path == join("{}this".format(sep), "is", "valid")
def test_normalise_path_with_double_backslashes_in_path(self): path = normalise_path('valid\\path') assert path == join("valid", "path")
def test_normalise_path_with_backslashes_in_path(self): path = normalise_path("valid\path") assert path == join("valid", "path")
def test_normalise_path_with_valid_path(self): path = normalise_path("valid/path") assert path == join("valid", "path")