package_creator.py
def merge_script_package_to_yml(package_path, dir_name, dest_path=""):
    """Merge the various components to create an output yml file

    Args:
        package_path (str): Directory containing the various files
        dir_name (str): Parent directory containing package (Scripts/Integrations)
        dest_path (str, optional): Defaults to "". Destination output

    Returns:
        output path, script path, image path
    """
    print("Merging package: {}".format(package_path))
    output_filename = '{}-{}.yml'.format(DIR_TO_PREFIX[dir_name], os.path.basename(os.path.dirname(package_path)))
    if dest_path:
        output_path = os.path.join(dest_path, output_filename)
    else:
        output_path = os.path.join(dir_name, output_filename)

    yml_paths = glob.glob(package_path + '*.yml')
    yml_path = yml_paths[0]
    for path in yml_paths:
        # The plugin creates a unified YML file for the package.
        # In case this script runs locally and there is a unified YML file in the package we need to ignore it.
        # Also,
        # we don't take the unified file by default because there might be packages that were not created by the plugin.
        if 'unified' not in path:
            yml_path = path
            break

    with open(yml_path, 'r') as yml_file:
        yml_data = yaml.safe_load(yml_file)

    script_obj = yml_data

    if dir_name != 'Scripts':
        script_obj = yml_data['script']
    script_type = TYPE_TO_EXTENSION[script_obj['type']]

    with io.open(yml_path, mode='r', encoding='utf-8') as yml_file:
        yml_text = yml_file.read()

    yml_text, script_path = insert_script_to_yml(package_path, script_type, yml_text, dir_name, yml_data)
    image_path = None
    desc_path = None
    if dir_name in ('Integrations', 'Beta_Integrations'):
        yml_text, image_path = insert_image_to_yml(dir_name, package_path, yml_data, yml_text)
        yml_text, desc_path = insert_description_to_yml(dir_name, package_path, yml_data, yml_text)

    output_map = write_yaml_with_docker(output_path, yml_text, yml_data, script_obj)
    return list(output_map.keys()), yml_path, script_path, image_path, desc_path
Merge the various components to create an output yml file

    Args:
        package_path (str): Directory containing the various files
        dir_name (str): Parent directory containing package (Scripts/Integrations)
        dest_path (str, optional): Defaults to "". Destination output

    Returns:
        output path, script path, image path
    
Merge the various components to create an output yml file
Merge the various components to create an output yml file
def merge_script_package_to_yml(package_path, dir_name, dest_path=""):
    print("Merging package: {}".format(package_path))
    output_filename = '{}-{}.yml'.format(DIR_TO_PREFIX[dir_name], os.path.basename(os.path.dirname(package_path)))
    if dest_path:
        output_path = os.path.join(dest_path, output_filename)
    else:
        output_path = os.path.join(dir_name, output_filename)
    yml_paths = glob.glob(package_path + '*.yml')
    yml_path = yml_paths[0]
    for path in yml_paths:
        if 'unified' not in path:
            yml_path = path
            break
    with open(yml_path, 'r') as yml_file:
        yml_data = yaml.safe_load(yml_file)
    script_obj = yml_data
    if dir_name != 'Scripts':
        script_obj = yml_data['script']
    script_type = TYPE_TO_EXTENSION[script_obj['type']]
    with io.open(yml_path, mode='r', encoding='utf-8') as yml_file:
        yml_text = yml_file.read()
    yml_text, script_path = insert_script_to_yml(package_path, script_type, yml_text, dir_name, yml_data)
    image_path = None
    desc_path = None
    if dir_name in ('Integrations', 'Beta_Integrations'):
        yml_text, image_path = insert_image_to_yml(dir_name, package_path, yml_data, yml_text)
        yml_text, desc_path = insert_description_to_yml(dir_name, package_path, yml_data, yml_text)
    output_map = write_yaml_with_docker(output_path, yml_text, yml_data, script_obj)
    return list(output_map.keys()), yml_path, script_path, image_path, desc_path
def merge_script_package_to_yml ( package_path , dir_name , dest_path = "" ) : print ( "Merging package: {}" . format ( package_path ) ) output_filename = '{}-{}.yml' . format ( DIR_TO_PREFIX [ dir_name ] , os . path . basename ( os . path . dirname ( package_path ) ) ) if dest_path : output_path = os . path . join ( dest_path , output_filename ) else : output_path = os . path . join ( dir_name , output_filename ) yml_paths = glob . glob ( package_path + '*.yml' ) yml_path = yml_paths [ 0 ] for path in yml_paths : if 'unified' not in path : yml_path = path break with open ( yml_path , 'r' ) as yml_file : yml_data = yaml . safe_load ( yml_file ) script_obj = yml_data if dir_name != 'Scripts' : script_obj = yml_data [ 'script' ] script_type = TYPE_TO_EXTENSION [ script_obj [ 'type' ] ] with io . open ( yml_path , mode = 'r' , encoding = 'utf-8' ) as yml_file : yml_text = yml_file . read ( ) yml_text , script_path = insert_script_to_yml ( package_path , script_type , yml_text , dir_name , yml_data ) image_path = None desc_path = None if dir_name in ( 'Integrations' , 'Beta_Integrations' ) : yml_text , image_path = insert_image_to_yml ( dir_name , package_path , yml_data , yml_text ) yml_text , desc_path = insert_description_to_yml ( dir_name , package_path , yml_data , yml_text ) output_map = write_yaml_with_docker ( output_path , yml_text , yml_data , script_obj ) return list ( output_map . keys ( ) ) , yml_path , script_path , image_path , desc_path
Merge the various components to create an output yml file
Merge the various components to create an output yml file
"""Merge the various components to create an output yml file

    Args:
        package_path (str): Directory containing the various files
        dir_name (str): Parent directory containing package (Scripts/Integrations)
        dest_path (str, optional): Defaults to "". Destination output

    Returns:
        output path, script path, image path
    """ # The plugin creates a unified YML file for the package. # In case this script runs locally and there is a unified YML file in the package we need to ignore it. # Also, # we don't take the unified file by default because there might be packages that were not created by the plugin.
None
package_path
Directory containing the various files
Directory containing the various files
dir_name
Parent directory containing package (Scripts/Integrations)
Parent directory containing package ( Scripts / Integrations )
dest_path
Defaults to "". Destination output
Defaults to " " . Destination output