# Path: statik/errors.py
# class ProjectConfigurationError(StatikError):
#     """For generic project configuration-related errors."""
#     error_kind = "Project configuration error"
#     exit_code = 2
# 
# class DeploymentError(StatikError):
#     """For errors relating to deployment of built projects."""
#     error_kind = "Deployment-related error"
#     exit_code = 9
# 
# Path: statik/deploy/base.py
# class DeploymentMethod(object):
#     """An abstract method for handling deployment."""
# 
#     def __init__(self, config, error_context=None):
#         """Must validate the given configuration for this deployment method and raise an exception
#         if it's invalid."""
#         raise NotImplementedError
# 
#     def execute(self, source_path):
#         """Must actually execute the implemented deployment method."""
#         raise NotImplementedError


import os
import os.path
import requests
import hashlib
import time
import json
import logging
from collections import OrderedDict, namedtuple
from datetime import datetime
from dateutil.parser import parse as dateutil_parse
from urllib.parse import quote as urllib_quote
from ..errors import ProjectConfigurationError, DeploymentError
from .base import DeploymentMethod
            if file_hash not in filenames_by_hash:
                filenames_by_hash[file_hash] = [df]
            else:
                filenames_by_hash[file_hash].append(df)

    return hashes_by_filename, filenames_by_hash


def sha1sum(path: str) -> str:
    """Computes the SHA-1 hash of the file at the given path."""
    sha1 = hashlib.sha1()
    with open(path, 'rb') as f:
        while True:
            data = f.read(1024*1024)
            if not data:
                break
            sha1.update(data)

    return sha1.hexdigest()


def check_rate_limit(resp):
    """Checks the given HTTP response's headers for rate limit information (to see if we're being
    throttled now) and, if we're being throttled, wait until the x-ratelimit-reset time."""

    rate_limit_remaining = int(resp.headers.get('x-ratelimit-remaining', -1))
    logger.debug("Netlify rate limit remaining: %d" % rate_limit_remaining)
    if rate_limit_remaining < 1:
        rate_limit_reset = resp.headers.get('x-ratelimit-reset')
        # wait 60 seconds by default

# Path: statik/errors.py
# class ProjectConfigurationError(StatikError):
#     """For generic project configuration-related errors."""
#     error_kind = "Project configuration error"
#     exit_code = 2
# 
# class DeploymentError(StatikError):
#     """For errors relating to deployment of built projects."""
#     error_kind = "Deployment-related error"
#     exit_code = 9
# 
# Path: statik/deploy/base.py
# class DeploymentMethod(object):
#     """An abstract method for handling deployment."""
# 
#     def __init__(self, config, error_context=None):
#         """Must validate the given configuration for this deployment method and raise an exception
#         if it's invalid."""
#         raise NotImplementedError
# 
#     def execute(self, source_path):
#         """Must actually execute the implemented deployment method."""
#         raise NotImplementedError


# Path: statik/deploy/netlify.py
import os
import os.path
import requests
import hashlib
import time
import json
import logging
from collections import OrderedDict, namedtuple
from datetime import datetime
from dateutil.parser import parse as dateutil_parse
from urllib.parse import quote as urllib_quote
from ..errors import ProjectConfigurationError, DeploymentError
from .base import DeploymentMethod

            if file_hash not in filenames_by_hash:
                filenames_by_hash[file_hash] = [df]
            else:
                filenames_by_hash[file_hash].append(df)

    return hashes_by_filename, filenames_by_hash


def sha1sum(path: str) -> str:
    """Computes the SHA-1 hash of the file at the given path."""
    sha1 = hashlib.sha1()
    with open(path, 'rb') as f:
        while True:
            data = f.read(1024*1024)
            if not data:
                break
            sha1.update(data)

    return sha1.hexdigest()


def check_rate_limit(resp):
    """Checks the given HTTP response's headers for rate limit information (to see if we're being
    throttled now) and, if we're being throttled, wait until the x-ratelimit-reset time."""

    rate_limit_remaining = int(resp.headers.get('x-ratelimit-remaining', -1))
    logger.debug("Netlify rate limit remaining: %d" % rate_limit_remaining)
    if rate_limit_remaining < 1:
        rate_limit_reset = resp.headers.get('x-ratelimit-reset')
        # wait 60 seconds by default

        rate_limit_wait = 60.0