Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dvc/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def update(self):

@staticmethod
def validate(d, fname=None):
from dvc.utils import convert_to_unicode
from dvc.utils.compat import convert_to_unicode

try:
Schema(Stage.SCHEMA).validate(convert_to_unicode(d))
Expand Down
10 changes: 0 additions & 10 deletions dvc/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,16 +292,6 @@ def fix_env(env=None):
return env


def convert_to_unicode(data):
if isinstance(data, builtin_str):
return str(data)
if isinstance(data, dict):
return dict(map(convert_to_unicode, data.items()))
if isinstance(data, (list, tuple)):
return type(data)(map(convert_to_unicode, data))
return data


def tmp_fname(fname):
""" Temporary name for a partial download """
return fspath(fname) + "." + str(uuid()) + ".tmp"
Expand Down
12 changes: 12 additions & 0 deletions dvc/utils/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ def __enter__(self):
def __exit__(self, *args):
self.close()

def convert_to_unicode(data):
if isinstance(data, builtin_str):
return str(data)
if isinstance(data, dict):
return dict(map(convert_to_unicode, data.items()))
if isinstance(data, (list, tuple)):
return type(data)(map(convert_to_unicode, data))
return data


elif is_py3:
import pathlib # noqa: F401
Expand Down Expand Up @@ -170,6 +179,9 @@ def __exit__(self, *args):
range = range # noqa: F821
FileNotFoundError = FileNotFoundError

def convert_to_unicode(data):
return data


# Backport os.fspath() from Python 3.6
try:
Expand Down