Removed codecs

I removed these calls to codecs because I got the error:

ValueError: can't have text and binary mode at once
This commit is contained in:
Rodolfo García Peñas (kix) 2020-08-28 12:38:15 +02:00
parent 476c485a52
commit 5e356b0bf5
2 changed files with 8 additions and 10 deletions

View File

@ -16,7 +16,6 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import codecs
import re # For folderfilter. import re # For folderfilter.
import json import json
from threading import Lock from threading import Lock
@ -120,8 +119,8 @@ class _IntermediateMbnames(object):
if self._dryrun: if self._dryrun:
self.ui.info("mbnames would write %s"% self._path) self.ui.info("mbnames would write %s"% self._path)
else: else:
with codecs.open( with open(
self._path, "wt", encoding='UTF-8') as intermediateFD: self._path, "w", encoding='utf-8') as intermediateFD:
json.dump(itemlist, intermediateFD) json.dump(itemlist, intermediateFD)
@ -235,8 +234,8 @@ class _Mbnames(object):
for intermediateFile in self._iterIntermediateFiles(): for intermediateFile in self._iterIntermediateFiles():
try: try:
with codecs.open( with open(
intermediateFile, 'rt', encoding="UTF-8") as intermediateFD: intermediateFile, 'r', encoding="utf-8") as intermediateFD:
for item in json.load(intermediateFD): for item in json.load(intermediateFD):
itemlist.append(item) itemlist.append(item)
except (OSError, IOError) as e: except (OSError, IOError) as e:
@ -257,8 +256,8 @@ class _Mbnames(object):
self.ui.info("mbnames would write %s"% self._path) self.ui.info("mbnames would write %s"% self._path)
else: else:
try: try:
with codecs.open( with open(
self._path, 'wt', encoding='UTF-8') as mbnamesFile: self._path, 'w', encoding='utf-8') as mbnamesFile:
mbnamesFile.write(self._header) mbnamesFile.write(self._header)
mbnamesFile.write(self._sep.join(itemlist)) mbnamesFile.write(self._sep.join(itemlist))
mbnamesFile.write(self._footer) mbnamesFile.write(self._footer)

View File

@ -19,7 +19,6 @@
import os import os
import netrc import netrc
import errno import errno
import codecs
from sys import exc_info from sys import exc_info
from threading import Event from threading import Event
@ -389,7 +388,7 @@ class IMAPRepository(BaseRepository):
# 1. Evaluate Repository 'remotepasseval'. # 1. Evaluate Repository 'remotepasseval'.
passwd = self.getconf('remotepasseval', None) passwd = self.getconf('remotepasseval', None)
if passwd is not None: if passwd is not None:
return self.localeval.eval(passwd).encode('UTF-8') return self.localeval.eval(passwd).encode('utf-8')
# 2. Read password from Repository 'remotepass'. # 2. Read password from Repository 'remotepass'.
password = self.getconf('remotepass', None) password = self.getconf('remotepass', None)
if password is not None: if password is not None:
@ -399,7 +398,7 @@ class IMAPRepository(BaseRepository):
# 3. Read password from file specified in Repository 'remotepassfile'. # 3. Read password from file specified in Repository 'remotepassfile'.
passfile = self.getconf('remotepassfile', None) passfile = self.getconf('remotepassfile', None)
if passfile is not None: if passfile is not None:
fd = codecs.open(os.path.expanduser(passfile), 'r', 'UTF-8') fd = open(os.path.expanduser(passfile), 'r', 'utf-8')
password = fd.readline().strip() password = fd.readline().strip()
fd.close() fd.close()
return password.encode('UTF-8') return password.encode('UTF-8')