# Path: muninn/_compat.py
# PY3 = sys.version_info[0] == 3
#     def is_python2_unicode(x):
#     def dictkeys(d):
#     def dictvalues(d):
#     def path_utf8(path):
#     def encode(s):
#     def decode(s):
#     def is_python2_unicode(x):
#     def path_utf8(path):
#     def decode(s):
#     def encode(s):
# 
# Path: muninn/_compat.py
# def path_utf8(path):
#     return path.encode('utf-8')
# 
# def encode(s):
#     return s.encode('utf-8')
# 
# def decode(s):
#     return s.decode('utf-8')


import errno
import hashlib
import os
import shutil
import tempfile
from muninn._compat import string_types as basestring
from muninn._compat import path_utf8, encode, decode
            # Read a block of character data.
            data = stream.read(block_size)
            if not data:
                return encode(hash.hexdigest())

            # Update hash.
            hash.update(data)


# NB. os.path.islink() can be True even if neither os.path.isdir() nor os.path.isfile() is True.
# NB. os.path.exists() is False for a dangling symbolic link, even if the symbolic link itself does exist.
def product_hash(roots, resolve_root=True, resolve_links=False, force_encapsulation=False,
                 block_size=65536, hash_type=None):
    hash_func = getattr(hashlib, hash_type or 'sha1')

    def _product_hash_rec(root, resolve_root, resolve_links, hash_func, block_size):
        if os.path.islink(root) and not (resolve_root or resolve_links):
            # Hash link _contents_.
            return hash_string(path_utf8(os.readlink(root)), hash_func)

        elif os.path.isfile(root):
            # Hash file contents.
            return hash_file(root, block_size, hash_func)

        elif os.path.isdir(root):
            # Create a fingerprint of the directory by computing the hash of (for each entry in the directory) the hash
            # of the entry name, the type of entry (link, file, or directory), and the hash of the contents of the
            # entry.
            hash = hash_func()
            for basename in sorted(os.listdir(root)):

# Path: muninn/_compat.py
# PY3 = sys.version_info[0] == 3
#     def is_python2_unicode(x):
#     def dictkeys(d):
#     def dictvalues(d):
#     def path_utf8(path):
#     def encode(s):
#     def decode(s):
#     def is_python2_unicode(x):
#     def path_utf8(path):
#     def decode(s):
#     def encode(s):
# 
# Path: muninn/_compat.py
# def path_utf8(path):
#     return path.encode('utf-8')
# 
# def encode(s):
#     return s.encode('utf-8')
# 
# def decode(s):
#     return s.decode('utf-8')


# Path: muninn/util.py
import errno
import hashlib
import os
import shutil
import tempfile
from muninn._compat import string_types as basestring
from muninn._compat import path_utf8, encode, decode

            # Read a block of character data.
            data = stream.read(block_size)
            if not data:
                return encode(hash.hexdigest())

            # Update hash.
            hash.update(data)


# NB. os.path.islink() can be True even if neither os.path.isdir() nor os.path.isfile() is True.
# NB. os.path.exists() is False for a dangling symbolic link, even if the symbolic link itself does exist.
def product_hash(roots, resolve_root=True, resolve_links=False, force_encapsulation=False,
                 block_size=65536, hash_type=None):
    hash_func = getattr(hashlib, hash_type or 'sha1')

    def _product_hash_rec(root, resolve_root, resolve_links, hash_func, block_size):
        if os.path.islink(root) and not (resolve_root or resolve_links):
            # Hash link _contents_.
            return hash_string(path_utf8(os.readlink(root)), hash_func)

        elif os.path.isfile(root):
            # Hash file contents.
            return hash_file(root, block_size, hash_func)

        elif os.path.isdir(root):
            # Create a fingerprint of the directory by computing the hash of (for each entry in the directory) the hash
            # of the entry name, the type of entry (link, file, or directory), and the hash of the contents of the
            # entry.
            hash = hash_func()
            for basename in sorted(os.listdir(root)):

                hash.update(hash_string(path_utf8(basename), hash_func))