From 0df1b6f03719cbbab31b1251b289f5d9c2bb6fef Mon Sep 17 00:00:00 2001 From: Eric Pellegrini Date: Fri, 17 Jan 2020 16:08:33 +0100 Subject: [PATCH] added static type to Packman module --- src/packme/PackerTemplate.py | 8 ++++---- src/packme/Packman.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/packme/PackerTemplate.py b/src/packme/PackerTemplate.py index 5c10f65..c2abc51 100644 --- a/src/packme/PackerTemplate.py +++ b/src/packme/PackerTemplate.py @@ -18,7 +18,7 @@ class PackerTemplate: - processors: a list of dictionaries where each dictionary defines actions to be run after the image is built """ - def __init__(self, name: str, yaml_node: yaml.Node, packages: List[str]) -> None: + def __init__(self, name: str, yaml_node: dict, packages: List[str]) -> None: """Constructor """ @@ -132,7 +132,7 @@ class PackerTemplate: parent_builder["iso_url"] = "./builds/{}-{}".format(parent_template.name, builder_name) parent_builder["iso_checksum_type"] = "none" parent_builder["iso_checksum_url"] = "none" - parent_builder["output_directory"] = os.path.join(self._templates_dir,self._name) + parent_builder["output_directory"] = os.path.join(self._templates_dir, self._name) self._builders.insert(0,parent_builder) # If the builder is also defined in the child config, use the child config one and specify the image dependency @@ -181,8 +181,8 @@ class PackerTemplate: except FileNotFoundError: manifest_data = [] else: - manifest_data = yaml.safe_load(fin) - manifest_data = manifest_data["provisioners"] + root_node = yaml.safe_load(fin) + manifest_data = root_node["provisioners"] # Loop over the provisioners list and update when necessary relative paths with absolute one for packer to run correctly for provisioner in manifest_data: diff --git a/src/packme/Packman.py b/src/packme/Packman.py index 7724539..29cf367 100644 --- a/src/packme/Packman.py +++ b/src/packme/Packman.py @@ -4,7 +4,7 @@ import shutil import subprocess import yaml -from typing import List, Optional +from typing import Any, Dict, List, Optional from .PackerTemplate import PackerTemplate @@ -167,7 +167,7 @@ class Packman: templates = self.get_templates_selection(selected_templates) - config_hierarchy = [] + config_hierarchy : List[str] = [] for template in templates: self._build_template_hierarchy(template, config_hierarchy) -- GitLab