mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
some manual py2 cleanups
This commit is contained in:
parent
30c1e8289f
commit
ab19b94811
23 changed files with 31 additions and 59 deletions
|
|
@ -1,6 +1,3 @@
|
|||
import six
|
||||
|
||||
|
||||
def to_text(s):
|
||||
return s if isinstance(s, str) else s.decode('UTF-8')
|
||||
|
||||
|
|
@ -9,4 +6,4 @@ def to_bytes(s):
|
|||
return s if isinstance(s, bytes) else s.encode('UTF-8')
|
||||
|
||||
|
||||
n = to_bytes if six.PY2 else to_text
|
||||
n = to_text
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class CalledProcessError(RuntimeError):
|
|||
self.stdout = stdout
|
||||
self.stderr = stderr
|
||||
|
||||
def to_bytes(self):
|
||||
def __bytes__(self):
|
||||
def _indent_or_none(part):
|
||||
if part:
|
||||
return b'\n ' + part.replace(b'\n', b'\n ')
|
||||
|
|
@ -97,11 +97,8 @@ class CalledProcessError(RuntimeError):
|
|||
b'stderr:', _indent_or_none(self.stderr),
|
||||
))
|
||||
|
||||
def to_text(self):
|
||||
return self.to_bytes().decode('UTF-8')
|
||||
|
||||
__bytes__ = to_bytes
|
||||
__str__ = to_text
|
||||
def __str__(self):
|
||||
return self.__bytes__().decode('UTF-8')
|
||||
|
||||
|
||||
def _cmd_kwargs(*cmd, **kwargs):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue