Merge pull request #1057 from kyrias/dictclient-utf8

Make dictclient.py unicode capable
This commit is contained in:
Valentin Lorentz 2015-02-21 20:22:19 +01:00
commit a59784a366

View File

@ -111,7 +111,7 @@ class Connection:
capstr, msgid = re.search('<(.*)> (<.*>)$', string).groups()
self.capabilities = capstr.split('.')
self.messageid = msgid
def getcapabilities(self):
"""Returns a list of the capabilities advertised by the server."""
return self.capabilities
@ -126,7 +126,7 @@ class Connection:
network traffic!"""
if hasattr(self, 'dbdescs'):
return self.dbdescs
self.sendcommand("SHOW DB")
self.dbdescs = self.get100dict()
return self.dbdescs
@ -165,7 +165,7 @@ class Connection:
def sendcommand(self, command):
"""Takes a command, without a newline character, and sends it to
the server."""
self.wfile.write(command.encode('ascii') + b"\n")
self.wfile.write(command.encode('utf-8') + b"\n")
def define(self, database, word):
"""Returns a list of Definition objects for each matching
@ -182,7 +182,7 @@ class Connection:
if database != '*' and database != '!' and \
not database in self.getdbdescs():
raise Exception("Invalid database '%s' specified" % database)
self.sendcommand("DEFINE " + enquote(database) + " " + enquote(word))
code = self.getresultcode()[0]
@ -249,11 +249,11 @@ class Database:
a database name."""
self.conn = dictconn
self.name = dbname
def getname(self):
"""Returns the short name for this database."""
return self.name
def getdescription(self):
if hasattr(self, 'description'):
return self.description
@ -264,7 +264,7 @@ class Database:
else:
self.description = self.conn.getdbdescs()[self.getname()]
return self.description
def getinfo(self):
"""Returns a string of info describing this database."""
if hasattr(self, 'info'):