def export(self, export_path):
     """ Exports the inventory report to a yaml file """
     inventory_path = os.path.join(
         export_path,
         self.name + '.yaml'
     )
     utils.yaml_writer(self.make_export_dict(), inventory_path)
     return inventory_path
def create_new_data_yaml(output_dir, system_key, component_key=None):
    """ Create new component yaml """
    system_key = slugify(system_key)
    if component_key:
        component_key = slugify(component_key)
    file_path = get_file_path(output_dir, system_key, component_key)
    data_dict = create_data_dict(system_key, component_key)
    utils.yaml_writer(data_dict, file_path)
    return file_path
def create_inventory(certification_path, output_path):
    """ Creates an inventory yaml """
    inventory = build_inventory(certification_path)
    inventory_path = os.path.join(
        output_path,
        inventory.get('certification') + '.yaml'
    )
    utils.yaml_writer(inventory, inventory_path)
    return inventory_path
def create_yaml_certifications(certification, data_dir, output_dir):
    """ Generate certification yamls from data """
    certifications_path, components_path, standards_path = prepare_data_paths(certification, data_dir)
    standards = create_standards_dic(standards_path)
    components_dict, bystandards_dict = prepare_components(components_path, data_dir, output_dir)
    name, certification = build_certification(
        certifications_path, bystandards_dict, standards
    )
    certification['components'] = components_dict
    filename = os.path.join(output_dir, name + '.yaml')
    utils.yaml_writer(component_data=certification, filename=filename)
    return filename
def create_inventory(certification, certification_dir, output_path):
    """ Creates an inventory yaml """
    certification_path = prepare_cert_path(certification, certification_dir)
    if not os.path.exists(certification_path):
        return None, "{} certification not found".format(certification)
    output_path = prepare_output_path(output_path)
    inventory = build_inventory(certification_path)
    inventory_path = os.path.join(
        output_path,
        inventory.get('certification') + '.yaml'
    )
    utils.yaml_writer(inventory, inventory_path)
    return inventory_path, None
def create_yaml_certifications(data_dir, output_dir):
    """ Generate certification yamls from data """
    certifications_path, components_path, standards_path = prepare_data_paths(data_dir)
    output_path = prepare_output_path(output_dir)
    standards = create_standards_dic(standards_path)
    components = create_bystandards_dict(components_path)
    certifications = build_certifications(
        certifications_path, components, standards
    )
    for name, certification in certifications:
        filename = os.path.join(output_path, name + '.yaml')
        utils.yaml_writer(component_data=certification, filename=filename)
    return output_path
def create_new_component_yaml(system, component, output_dir):
    """ Create new component yaml """
    file_path = get_file_path(system, component, output_dir)
    component_dict = create_component_dict(system, component)
    utils.yaml_writer(component_dict, file_path)
    return file_path