Packs/Base/Scripts/ValidateContent/ValidateContent.py
def convert_contribution_to_pack(contrib_converter: ContributionConverter) -> None:
    """Create or updates a pack in the content repo from the contents of a contribution zipfile

    Args:
        contrib_converter (ContributionConverter): Contribution contributor object
    """
    # only create pack_metadata.json and base pack files if creating a new pack
    if contrib_converter.create_new:
        if contrib_converter.contribution:
            # create pack metadata file
            with zipfile.ZipFile(contrib_converter.contribution) as zipped_contrib:
                with zipped_contrib.open('metadata.json') as metadata_file:
                    metadata = json.loads(metadata_file.read())
                    contrib_converter.create_metadata_file(metadata)
        # create base files
        contrib_converter.create_pack_base_files = types.MethodType(_create_pack_base_files, contrib_converter)
        contrib_converter.create_pack_base_files()
    # unpack
    contrib_converter.unpack_contribution_to_dst_pack_directory()
    # convert
    unpacked_contribution_dirs = get_child_directories(contrib_converter.pack_dir_path)
    for unpacked_contribution_dir in unpacked_contribution_dirs:
        contrib_converter.convert_contribution_dir_to_pack_contents(unpacked_contribution_dir)
    # extract to package format
    for pack_subdir in get_child_directories(contrib_converter.pack_dir_path):
        basename = os.path.basename(pack_subdir)
        if basename in {SCRIPTS_DIR, INTEGRATIONS_DIR}:
            contrib_converter.content_item_to_package_format = types.MethodType(content_item_to_package_format,
                                                                                contrib_converter)
            contrib_converter.content_item_to_package_format(
                pack_subdir, del_unified=True, source_mapping=None
            )
Create or updates a pack in the content repo from the contents of a contribution zipfile

    Args:
        contrib_converter (ContributionConverter): Contribution contributor object
    
Create or updates a pack in the content repo from the contents of a contribution zipfile
Create or updates a pack in the content repo from the contents of a contribution zipfile
def convert_contribution_to_pack(contrib_converter: ContributionConverter) -> None:
    if contrib_converter.create_new:
        if contrib_converter.contribution:
            with zipfile.ZipFile(contrib_converter.contribution) as zipped_contrib:
                with zipped_contrib.open('metadata.json') as metadata_file:
                    metadata = json.loads(metadata_file.read())
                    contrib_converter.create_metadata_file(metadata)
        contrib_converter.create_pack_base_files = types.MethodType(_create_pack_base_files, contrib_converter)
        contrib_converter.create_pack_base_files()
    contrib_converter.unpack_contribution_to_dst_pack_directory()
    unpacked_contribution_dirs = get_child_directories(contrib_converter.pack_dir_path)
    for unpacked_contribution_dir in unpacked_contribution_dirs:
        contrib_converter.convert_contribution_dir_to_pack_contents(unpacked_contribution_dir)
    for pack_subdir in get_child_directories(contrib_converter.pack_dir_path):
        basename = os.path.basename(pack_subdir)
        if basename in {SCRIPTS_DIR, INTEGRATIONS_DIR}:
            contrib_converter.content_item_to_package_format = types.MethodType(content_item_to_package_format,
                                                                                contrib_converter)
            contrib_converter.content_item_to_package_format(
                pack_subdir, del_unified=True, source_mapping=None
            )
def convert_contribution_to_pack ( contrib_converter : ContributionConverter ) -> None : if contrib_converter . create_new : if contrib_converter . contribution : with zipfile . ZipFile ( contrib_converter . contribution ) as zipped_contrib : with zipped_contrib . open ( 'metadata.json' ) as metadata_file : metadata = json . loads ( metadata_file . read ( ) ) contrib_converter . create_metadata_file ( metadata ) contrib_converter . create_pack_base_files = types . MethodType ( _create_pack_base_files , contrib_converter ) contrib_converter . create_pack_base_files ( ) contrib_converter . unpack_contribution_to_dst_pack_directory ( ) unpacked_contribution_dirs = get_child_directories ( contrib_converter . pack_dir_path ) for unpacked_contribution_dir in unpacked_contribution_dirs : contrib_converter . convert_contribution_dir_to_pack_contents ( unpacked_contribution_dir ) for pack_subdir in get_child_directories ( contrib_converter . pack_dir_path ) : basename = os . path . basename ( pack_subdir ) if basename in { SCRIPTS_DIR , INTEGRATIONS_DIR } : contrib_converter . content_item_to_package_format = types . MethodType ( content_item_to_package_format , contrib_converter ) contrib_converter . content_item_to_package_format ( pack_subdir , del_unified = True , source_mapping = None )
Create or updates a pack in the content repo from the contents of a contribution zipfile
Create or updates a pack in the content repo from the contents of a contribution zipfile
"""Create or updates a pack in the content repo from the contents of a contribution zipfile

    Args:
        contrib_converter (ContributionConverter): Contribution contributor object
    """ # only create pack_metadata.json and base pack files if creating a new pack # create pack metadata file # create base files # unpack # convert # extract to package format
contrib_converter
ContributionConverter
Contribution contributor object
Contribution contributor object