From c768a99151e47c3a4bb7b92c514d256abd301c4d Mon Sep 17 00:00:00 2001
From: dvshkurko <dvshkurko@yandex-team.ru>
Date: Thu, 10 Feb 2022 16:45:52 +0300
Subject: Restoring authorship annotation for <dvshkurko@yandex-team.ru>.
 Commit 2 of 2.

---
 library/python/strings/strings.py | 54 +++++++++++++++++++--------------------
 1 file changed, 27 insertions(+), 27 deletions(-)

(limited to 'library/python/strings/strings.py')

diff --git a/library/python/strings/strings.py b/library/python/strings/strings.py
index 2e018ae038..5bfddfe78a 100644
--- a/library/python/strings/strings.py
+++ b/library/python/strings/strings.py
@@ -1,6 +1,6 @@
 import locale
 import logging
-import six 
+import six
 import sys
 import codecs
 
@@ -23,15 +23,15 @@ def left_strip(el, prefix):
 
 
 # Explicit to-text conversion
-# Chooses between str/unicode, i.e. six.binary_type/six.text_type 
+# Chooses between str/unicode, i.e. six.binary_type/six.text_type
 def to_basestring(value):
-    if isinstance(value, (six.binary_type, six.text_type)): 
+    if isinstance(value, (six.binary_type, six.text_type)):
         return value
     try:
-        if six.PY2: 
-            return unicode(value) 
-        else: 
-            return str(value) 
+        if six.PY2:
+            return unicode(value)
+        else:
+            return str(value)
     except UnicodeDecodeError:
         try:
             return str(value)
@@ -41,35 +41,35 @@ to_text = to_basestring
 
 
 def to_unicode(value, from_enc=DEFAULT_ENCODING):
-    if isinstance(value, six.text_type): 
+    if isinstance(value, six.text_type):
         return value
-    if isinstance(value, six.binary_type): 
-        if six.PY2: 
-            return unicode(value, from_enc, ENCODING_ERRORS_POLICY) 
-        else: 
-            return value.decode(from_enc, errors=ENCODING_ERRORS_POLICY) 
-    return six.text_type(value) 
+    if isinstance(value, six.binary_type):
+        if six.PY2:
+            return unicode(value, from_enc, ENCODING_ERRORS_POLICY)
+        else:
+            return value.decode(from_enc, errors=ENCODING_ERRORS_POLICY)
+    return six.text_type(value)
 
 
 # Optional from_enc enables transcoding
 def to_str(value, to_enc=DEFAULT_ENCODING, from_enc=None):
-    if isinstance(value, six.binary_type): 
+    if isinstance(value, six.binary_type):
         if from_enc is None or to_enc == from_enc:
             # Unknown input encoding or input and output encoding are the same
             return value
         value = to_unicode(value, from_enc=from_enc)
-    if isinstance(value, six.text_type): 
+    if isinstance(value, six.text_type):
         return value.encode(to_enc, ENCODING_ERRORS_POLICY)
-    return six.binary_type(value) 
+    return six.binary_type(value)
 
 
 def _convert_deep(x, enc, convert, relaxed=True):
     if x is None:
         return None
-    if isinstance(x, (six.text_type, six.binary_type)): 
+    if isinstance(x, (six.text_type, six.binary_type)):
         return convert(x, enc)
     if isinstance(x, dict):
-        return {convert(k, enc): _convert_deep(v, enc, convert, relaxed) for k, v in six.iteritems(x)} 
+        return {convert(k, enc): _convert_deep(v, enc, convert, relaxed) for k, v in six.iteritems(x)}
     if isinstance(x, list):
         return [_convert_deep(e, enc, convert, relaxed) for e in x]
     if isinstance(x, tuple):
@@ -91,13 +91,13 @@ def stringize_deep(x, enc=DEFAULT_ENCODING, relaxed=True):
 @library.python.func.memoize()
 def locale_encoding():
     try:
-        loc = locale.getdefaultlocale()[1] 
-        if loc: 
-            codecs.lookup(loc) 
-        return loc 
-    except LookupError as e: 
-        logger.debug('Cannot get system locale: %s', e) 
-        return None 
+        loc = locale.getdefaultlocale()[1]
+        if loc:
+            codecs.lookup(loc)
+        return loc
+    except LookupError as e:
+        logger.debug('Cannot get system locale: %s', e)
+        return None
     except ValueError as e:
         logger.warn('Cannot get system locale: %s', e)
         return None
@@ -124,6 +124,6 @@ def get_stream_encoding(stream):
 
 
 def encode(value, encoding=DEFAULT_ENCODING):
-    if isinstance(value, six.binary_type): 
+    if isinstance(value, six.binary_type):
         value = value.decode(encoding, errors='ignore')
     return value.encode(encoding)
-- 
cgit v1.2.3