Encodes a string into the proper filesystem encoding

    Borrowed from pip-tools

def fs_str(string):
    """Encodes a string into the proper filesystem encoding

    Borrowed from pip-tools
    """

    if isinstance(string, str):
        return string
    assert not isinstance(string, bytes)
    return string.encode(_fs_encoding)