Skip to content

Commit dbb669a

Browse files
committed
refactor: Remove _compat
1 parent 0702cde commit dbb669a

File tree

3 files changed

+14
-19
lines changed

3 files changed

+14
-19
lines changed

libvcs/_compat.py

-17
This file was deleted.

libvcs/util.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,24 @@
77
import logging
88
import os
99
import subprocess
10+
import sys
1011

1112
from . import exc
12-
from ._compat import console_to_str
1313

1414
logger = logging.getLogger(__name__)
1515

16+
console_encoding = sys.__stdout__.encoding
17+
18+
19+
def console_to_str(s):
20+
""" From pypa/pip project, pip.backwardwardcompat. License MIT. """
21+
try:
22+
return s.decode(console_encoding)
23+
except UnicodeDecodeError:
24+
return s.decode('utf_8')
25+
except AttributeError: # for tests, #13
26+
return s
27+
1628

1729
def which(
1830
exe=None, default_paths=['/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin']

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[flake8]
2-
exclude = .*/,.tox,*.egg,libvcs/_compat.py,libvcs/__*__.py,
2+
exclude = .*/,.tox,*.egg,libvcs/__*__.py,
33
select = E,W,F,N
44
max-line-length = 88
55
# Stuff we ignore thanks to black: https://github.com/ambv/black/issues/429

0 commit comments

Comments
 (0)