# Path: pywr/hashes.py
# def check_hash(filename, hash, algorithm="md5", **kwargs):
#     """Check the hash for filename using the named algorithm
# 
#     If the hashes do not match a HashMismatchError error is raised.
# 
#     This function is not case sensitive.
#     """
# 
#     actual_hash = compute_hash(filename, algorithm=algorithm, **kwargs)
# 
#     if hash.lower() != actual_hash.lower():
#         raise HashMismatchError(
#             'Hash mismatch using {} on file: "{}"'.format(algorithm, filename)
#         )


import pandas
import os
from pandas.tseries.offsets import Tick, DateOffset
from pandas._libs.tslibs.period import IncompatibleFrequency
from .hashes import check_hash
                freq = pandas.infer_freq(df.index)
                if freq is None:
                    raise IndexError(
                        'Failed to identify frequency of dataset "{}"'.format(name)
                    )
                df = df.asfreq(freq)
    except AttributeError:
        # Probably wasn't a pandas dataframe at this point.
        pass

    return df


def read_dataframe(model, data):
    # values reference data in an external file
    url = data.pop("url", None)
    if url is not None:
        if not os.path.isabs(url) and model.path is not None:
            url = os.path.join(model.path, url)
    else:
        # Must be an embedded dataframe
        df_data = data.pop("data", None)

    if url is None and df_data is None:
        raise ValueError('No data specified. Provide a "url" or "data" key.')

    if url is not None:
        # Check hashes if given before reading the data
        checksums = data.pop("checksum", {})
        for algo, hash in checksums.items():

# Path: pywr/hashes.py
# def check_hash(filename, hash, algorithm="md5", **kwargs):
#     """Check the hash for filename using the named algorithm
# 
#     If the hashes do not match a HashMismatchError error is raised.
# 
#     This function is not case sensitive.
#     """
# 
#     actual_hash = compute_hash(filename, algorithm=algorithm, **kwargs)
# 
#     if hash.lower() != actual_hash.lower():
#         raise HashMismatchError(
#             'Hash mismatch using {} on file: "{}"'.format(algorithm, filename)
#         )


# Path: pywr/dataframe_tools.py
import pandas
import os
from pandas.tseries.offsets import Tick, DateOffset
from pandas._libs.tslibs.period import IncompatibleFrequency
from .hashes import check_hash

                freq = pandas.infer_freq(df.index)
                if freq is None:
                    raise IndexError(
                        'Failed to identify frequency of dataset "{}"'.format(name)
                    )
                df = df.asfreq(freq)
    except AttributeError:
        # Probably wasn't a pandas dataframe at this point.
        pass

    return df


def read_dataframe(model, data):
    # values reference data in an external file
    url = data.pop("url", None)
    if url is not None:
        if not os.path.isabs(url) and model.path is not None:
            url = os.path.join(model.path, url)
    else:
        # Must be an embedded dataframe
        df_data = data.pop("data", None)

    if url is None and df_data is None:
        raise ValueError('No data specified. Provide a "url" or "data" key.')

    if url is not None:
        # Check hashes if given before reading the data
        checksums = data.pop("checksum", {})
        for algo, hash in checksums.items():

            check_hash(url, hash, algorithm=algo)