Commit 2146af1c authored by Eric Pellegrini's avatar Eric Pellegrini

updated docstrings and stub files

parent 9b63ba84
......@@ -6,7 +6,7 @@ import os
import pprint
import yaml
from typing import List
from typing import Dict, List
class PackerTemplate:
"""This class implements one packer template.
......@@ -55,8 +55,13 @@ class PackerTemplate:
self._load_packages(packages)
def _update_builder(self, builder):
"""Update a builder.
def _update_builder(self, builder: Dict[str,str]):
"""Update some fields of a builder.
Parameters
----------
builder: dict
The builder to update.
"""
builder["output_directory"] = "builds"
......@@ -70,7 +75,17 @@ class PackerTemplate:
# For convenience set the vm name with a fixed standardized value
builder["vm_name"] = "{}-{}".format(self._name,builder["type"])
def _update_provisioner(self, provisioner, base_dir):
def _update_provisioner(self, provisioner : Dict[str,str], base_dir : str):
"""Update some fields of a provisioner.
Parameters
----------
provisioner: dict
The provisioner to update.
base_dir: str
The base directory for this provisioner.
"""
if not provisioner["type"] in ["file","shell"]:
return
......@@ -203,14 +218,14 @@ class PackerTemplate:
fin = open(manifest_file, "r")
# If the manifest does not exist, the provisioners list is set to an empty list
except FileNotFoundError:
manifest_data = []
manifest_data: List = []
else:
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:
self._update_provisioner(provisioner,package_dir,self._name)
self._update_provisioner(provisioner,os.path.join(package_dir,self._name))
# Extend the current provisioners list with the ones of the selected packages
self._provisioners.extend(manifest_data)
......@@ -253,7 +268,7 @@ class PackerTemplate:
"""Returns the string representation for this :class:`PackerTemplate`.
"""
d = collections.OrderedDict()
d : collections.OrderedDict = collections.OrderedDict()
d["description"] = self._description
d["variables"] = self._variables
d["builders"] = self._builders
......
......@@ -105,7 +105,7 @@ class Packman:
fin = open(manifest_file, "r")
# If the file does not exist, the manifest contents is just an empty dict
except FileNotFoundError:
manifest_data = {}
manifest_data : Dict[str,str] = {}
else:
manifest_data = yaml.safe_load(fin)
......
from typing import Any, List
class PackerTemplate:
def __init__(self, name: str, yaml_node: dict, packages: List[str]) -> None: ...
def __init__(self, name: str, yaml_node: dict, packages: List[str], packages_base_dir: str, templates_base_dir: str) -> None: ...
@property
def builders(self) -> list: ...
@property
......
from .PackerTemplate import PackerTemplate as PackerTemplate
from typing import Any, List, Optional
class Packman:
def __init__(self, input_file: str, templates_base_dir: str) -> None: ...
def get_templates_selection(self, selected_templates: Optional[Any]=...) -> Any: ...
def get_template(self, template_name: Any) -> Any: ...
def run(self, selected_templates: Optional[List[str]]=..., log: Optional[bool]=...) -> Any: ...
def __init__(self, input_file: str, templates_base_dir: Optional[str]=..., packages_base_dir: Optional[str]=...) -> None: ...
def get_templates_selection(self, selected_templates: Optional[Any] = ...): ...
def get_template(self, template_name: Any): ...
def run(self, selected_templates: Optional[List[str]]=..., log: Optional[bool]=..., key_rate: Optional[int]=...) -> Any: ...
def build(self, selected_templates: Optional[List[str]]=..., **kwargs: Any) -> Any: ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment