Commit 5671281f authored by Michal Čihař's avatar Michal Čihař

Various Python 3 fixes

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent fd6c84d5
...@@ -29,6 +29,7 @@ from django.utils import timezone ...@@ -29,6 +29,7 @@ from django.utils import timezone
from weblate.trans.models import SubProject from weblate.trans.models import SubProject
from weblate.trans.tests.test_models import REPOWEB_URL from weblate.trans.tests.test_models import REPOWEB_URL
from weblate.trans.tests.test_views import ViewTestCase from weblate.trans.tests.test_views import ViewTestCase
from weblate.trans.vcs import HgRepository
EXTRA_PO = ''' EXTRA_PO = '''
#: accounts/models.py:319 trans/views/basic.py:104 weblate/html/index.html:21 #: accounts/models.py:319 trans/views/basic.py:104 weblate/html/index.html:21
......
...@@ -33,6 +33,7 @@ import subprocess ...@@ -33,6 +33,7 @@ import subprocess
from dateutil import parser from dateutil import parser
import six
from six.moves.configparser import RawConfigParser from six.moves.configparser import RawConfigParser
from weblate.trans.util import get_clean_env, add_configuration_error from weblate.trans.util import get_clean_env, add_configuration_error
...@@ -325,7 +326,7 @@ class Repository(object): ...@@ -325,7 +326,7 @@ class Repository(object):
with open(real_path, 'rb') as handle: with open(real_path, 'rb') as handle:
data = handle.read() data = handle.read()
objhash.update('blob {0}\0'.format(len(data))) objhash.update('blob {0}\0'.format(len(data)).encode('ascii'))
objhash.update(data) objhash.update(data)
return objhash.hexdigest() return objhash.hexdigest()
...@@ -773,9 +774,10 @@ class HgRepository(Repository): ...@@ -773,9 +774,10 @@ class HgRepository(Repository):
""" """
section, option = path.split('.', 1) section, option = path.split('.', 1)
filename = os.path.join(self.path, '.hg', 'hgrc') filename = os.path.join(self.path, '.hg', 'hgrc')
value = value.encode('utf-8') if six.PY2:
section = section.encode('utf-8') value = value.encode('utf-8')
option = option.encode('utf-8') section = section.encode('utf-8')
option = option.encode('utf-8')
config = RawConfigParser() config = RawConfigParser()
config.read(filename) config.read(filename)
if not config.has_section(section): if not config.has_section(section):
...@@ -784,7 +786,7 @@ class HgRepository(Repository): ...@@ -784,7 +786,7 @@ class HgRepository(Repository):
config.get(section, option) == value): config.get(section, option) == value):
return return
config.set(section, option, value) config.set(section, option, value)
with open(filename, 'wb') as handle: with open(filename, 'w') as handle:
config.write(handle) config.write(handle)
def set_committer(self, name, mail): def set_committer(self, name, mail):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment