コード例 #1
0
def get_latest_pack_zip_from_pack_files(pack, pack_files):
    """
    Returns the latest zip of a pack from a list of blobs.
    Args:
        pack: The pack name
        pack_files: A list of string which are paths of the pack's files
    Returns:
        latest_zip_path: The zip path of the pack with the latest version.
    """
    latest_zip_path = None
    latest_zip_version = None
    for current_file_path in pack_files:
        current_pack_name = os.path.splitext(os.path.basename(current_file_path))[0]
        if current_pack_name == pack and current_file_path.endswith('.zip'):
            current_pack_zip_version = LooseVersion(os.path.basename(os.path.dirname(current_file_path)))
            if not latest_zip_version or latest_zip_version < current_pack_zip_version:
                latest_zip_version = current_pack_zip_version
                latest_zip_path = current_file_path

    return latest_zip_path
コード例 #2
0
ファイル: zip_packs.py プロジェクト: pxjohnny/content
def get_latest_pack_zip_from_blob(pack, blobs):
    """
    Returns the latest zip of a pack from a list of blobs.
    Args:
        pack: The pack name
        blobs: The blob list

    Returns:
        blob: The zip blob of the pack with the latest version.
    """
    blob = None
    blobs = [
        b for b in blobs
        if os.path.splitext(os.path.basename(b.name))[0] == pack
        and b.name.endswith('.zip')
    ]
    if blobs:
        blobs = sorted(blobs,
                       key=lambda b: LooseVersion(
                           os.path.basename(os.path.dirname(b.name))),
                       reverse=True)
        blob = blobs[0]

    return blob