fix utf8 and python3

master
Amin Dandache 10 years ago
parent 38ae8dd285
commit 2a20ef36bb
  1. 32
      gitstatus.py

@ -21,7 +21,11 @@ __all__ = ["Print"]
try: try:
Print = eval("print") # python 3.0 case Print = eval("print") # python 3.0 case
except SyntaxError: python_version = 3
to_str = str
except SyntaxError as e:
python_version = 2
to_str = unicode
D = dict() D = dict()
try: try:
exec ("from __future__ import print_function\np=print", D) exec ("from __future__ import print_function\np=print", D)
@ -126,14 +130,24 @@ else:
if remote == "": if remote == "":
remote = '.' remote = '.'
if python_version == 2:
remote = remote.decode('utf-8')
out = '\n'.join([ out = '\n'.join([
branch, branch,
remote.decode('utf-8'), remote,
str(len(staged)), to_str(len(staged)),
str(len(conflicts)), to_str(len(conflicts)),
str(len(changed)), to_str(len(changed)),
str(len(untracked)), to_str(len(untracked)),
str(stashed), to_str(stashed),
str(clean) to_str(clean),
to_str(python_version),
]) ])
Print(out)
if python_version == 2:
Print(out.encode('utf-8'))
else:
Print(out)

Loading…
Cancel
Save