# Compatibility abstractions

# Discriminating Py2
import sys

py2 = sys.version_info < (3,)

# This resolves pathlib in older Python versions
try:
    from pathlib2 import Path
except ImportError:
    from pathlib import Path


# Ensures that we get an unicode string, even in Py2
def text(data, encoding="utf8"):
    if type(data) is type(""):
        return data
    if type(data) is type(b""):
        return data.decode(encoding)
    return type("")(data)


def isStr(x):
    return type(x) in (
        type(""),
        type(b""),
    )
