#!/usr/bin/python3
"""Fabric script that generates a .tgz archive
from the contents of the web_static folder."""


from fabric.api import local
from datetime import datetime
from fabric.decorators import runs_once


def do_pack():
    """Generates .tgz archive from the contents of the web_static folder."""
    local("mkdir -p versions")
    path = "versions/web_static_{}.tgz".format(
            datetime.strftime(datetime.now(), "%Y%m%d%H%M%S"))
    result = local("tar -czf {} web_static".format(path))
    if result.failed:
        return None
    return path
