mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-19 00:22:50 +01:00
Merge pull request #1057 from kyrias/dictclient-utf8
Make dictclient.py unicode capable
This commit is contained in:
commit
a59784a366
@ -111,7 +111,7 @@ class Connection:
|
|||||||
capstr, msgid = re.search('<(.*)> (<.*>)$', string).groups()
|
capstr, msgid = re.search('<(.*)> (<.*>)$', string).groups()
|
||||||
self.capabilities = capstr.split('.')
|
self.capabilities = capstr.split('.')
|
||||||
self.messageid = msgid
|
self.messageid = msgid
|
||||||
|
|
||||||
def getcapabilities(self):
|
def getcapabilities(self):
|
||||||
"""Returns a list of the capabilities advertised by the server."""
|
"""Returns a list of the capabilities advertised by the server."""
|
||||||
return self.capabilities
|
return self.capabilities
|
||||||
@ -126,7 +126,7 @@ class Connection:
|
|||||||
network traffic!"""
|
network traffic!"""
|
||||||
if hasattr(self, 'dbdescs'):
|
if hasattr(self, 'dbdescs'):
|
||||||
return self.dbdescs
|
return self.dbdescs
|
||||||
|
|
||||||
self.sendcommand("SHOW DB")
|
self.sendcommand("SHOW DB")
|
||||||
self.dbdescs = self.get100dict()
|
self.dbdescs = self.get100dict()
|
||||||
return self.dbdescs
|
return self.dbdescs
|
||||||
@ -165,7 +165,7 @@ class Connection:
|
|||||||
def sendcommand(self, command):
|
def sendcommand(self, command):
|
||||||
"""Takes a command, without a newline character, and sends it to
|
"""Takes a command, without a newline character, and sends it to
|
||||||
the server."""
|
the server."""
|
||||||
self.wfile.write(command.encode('ascii') + b"\n")
|
self.wfile.write(command.encode('utf-8') + b"\n")
|
||||||
|
|
||||||
def define(self, database, word):
|
def define(self, database, word):
|
||||||
"""Returns a list of Definition objects for each matching
|
"""Returns a list of Definition objects for each matching
|
||||||
@ -182,7 +182,7 @@ class Connection:
|
|||||||
if database != '*' and database != '!' and \
|
if database != '*' and database != '!' and \
|
||||||
not database in self.getdbdescs():
|
not database in self.getdbdescs():
|
||||||
raise Exception("Invalid database '%s' specified" % database)
|
raise Exception("Invalid database '%s' specified" % database)
|
||||||
|
|
||||||
self.sendcommand("DEFINE " + enquote(database) + " " + enquote(word))
|
self.sendcommand("DEFINE " + enquote(database) + " " + enquote(word))
|
||||||
code = self.getresultcode()[0]
|
code = self.getresultcode()[0]
|
||||||
|
|
||||||
@ -249,11 +249,11 @@ class Database:
|
|||||||
a database name."""
|
a database name."""
|
||||||
self.conn = dictconn
|
self.conn = dictconn
|
||||||
self.name = dbname
|
self.name = dbname
|
||||||
|
|
||||||
def getname(self):
|
def getname(self):
|
||||||
"""Returns the short name for this database."""
|
"""Returns the short name for this database."""
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def getdescription(self):
|
def getdescription(self):
|
||||||
if hasattr(self, 'description'):
|
if hasattr(self, 'description'):
|
||||||
return self.description
|
return self.description
|
||||||
@ -264,7 +264,7 @@ class Database:
|
|||||||
else:
|
else:
|
||||||
self.description = self.conn.getdbdescs()[self.getname()]
|
self.description = self.conn.getdbdescs()[self.getname()]
|
||||||
return self.description
|
return self.description
|
||||||
|
|
||||||
def getinfo(self):
|
def getinfo(self):
|
||||||
"""Returns a string of info describing this database."""
|
"""Returns a string of info describing this database."""
|
||||||
if hasattr(self, 'info'):
|
if hasattr(self, 'info'):
|
||||||
|
Loading…
Reference in New Issue
Block a user