Merge branch 'maintenance' into devel
# Conflicts: # src/octoprint/util/__init__.py
This commit is contained in:
commit
adea0db344
2 files changed
+6
No files matched your search
@@ -67,6 +67,7 @@ INSTALL_REQUIRES_PYTHON2 = [
|
||||
"monotonic>=1.5,<1.6",
|
||||
"scandir>=1.9,<1.10",
|
||||
"chainmap>=1.0.2,<1.1",
|
||||
"typing>=3.6.4,<4"
|
||||
]
|
||||
|
||||
# OSX specific requirements
|
||||
|
||||
@@ -26,6 +26,8 @@ import collections
|
||||
import frozendict
|
||||
import copy
|
||||
|
||||
from typing import Union
|
||||
|
||||
try:
|
||||
import queue
|
||||
except ImportError:
|
||||
@@ -37,6 +39,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def to_bytes(s_or_u, encoding="utf-8", errors="strict"):
|
||||
# type: (Union[str, bytes], str, str) -> bytes
|
||||
"""Make sure ``s_or_u`` is a bytestring."""
|
||||
if isinstance(s_or_u, unicode):
|
||||
return s_or_u.encode(encoding, errors=errors)
|
||||
@@ -45,6 +48,7 @@ def to_bytes(s_or_u, encoding="utf-8", errors="strict"):
|
||||
|
||||
|
||||
def to_unicode(s_or_u, encoding="utf-8", errors="strict"):
|
||||
# type: (Union[str, bytes], str, str) -> str
|
||||
"""Make sure ``s_or_u`` is a unicode string."""
|
||||
if isinstance(s_or_u, bytes):
|
||||
return s_or_u.decode(encoding, errors=errors)
|
||||
@@ -53,6 +57,7 @@ def to_unicode(s_or_u, encoding="utf-8", errors="strict"):
|
||||
|
||||
|
||||
def to_native_str(s_or_u):
|
||||
# type: (Union[str, bytes]) -> Union[str, bytes]
|
||||
"""Make sure ``s_or_u`` is a 'str'."""
|
||||
if sys.version_info[0] == 2:
|
||||
return to_bytes(s_or_u)
|
||||
|
||||
Reference in new issue
Block a user