Used 2to3 to convert to python3

output of
$ 2to3 -f all -f buffer -f idioms -f set_literal -f ws_comma -w -n -v . 2>&1 |tee refactor.log

RefactoringTool: Adding transformation: apply
RefactoringTool: Adding transformation: asserts
RefactoringTool: Adding transformation: basestring
RefactoringTool: Adding transformation: buffer
RefactoringTool: Adding transformation: callable
RefactoringTool: Adding transformation: dict
RefactoringTool: Adding transformation: except
RefactoringTool: Adding transformation: exec
RefactoringTool: Adding transformation: execfile
RefactoringTool: Adding transformation: exitfunc
RefactoringTool: Adding transformation: filter
RefactoringTool: Adding transformation: funcattrs
RefactoringTool: Adding transformation: future
RefactoringTool: Adding transformation: getcwdu
RefactoringTool: Adding transformation: has_key
RefactoringTool: Adding transformation: idioms
RefactoringTool: Adding transformation: import
RefactoringTool: Adding transformation: imports
RefactoringTool: Adding transformation: imports2
RefactoringTool: Adding transformation: input
RefactoringTool: Adding transformation: intern
RefactoringTool: Adding transformation: isinstance
RefactoringTool: Adding transformation: itertools
RefactoringTool: Adding transformation: itertools_imports
RefactoringTool: Adding transformation: long
RefactoringTool: Adding transformation: map
RefactoringTool: Adding transformation: metaclass
RefactoringTool: Adding transformation: methodattrs
RefactoringTool: Adding transformation: ne
RefactoringTool: Adding transformation: next
RefactoringTool: Adding transformation: nonzero
RefactoringTool: Adding transformation: numliterals
RefactoringTool: Adding transformation: operator
RefactoringTool: Adding transformation: paren
RefactoringTool: Adding transformation: print
RefactoringTool: Adding transformation: raise
RefactoringTool: Adding transformation: raw_input
RefactoringTool: Adding transformation: reduce
RefactoringTool: Adding transformation: reload
RefactoringTool: Adding transformation: renames
RefactoringTool: Adding transformation: repr
RefactoringTool: Adding transformation: set_literal
RefactoringTool: Adding transformation: standarderror
RefactoringTool: Adding transformation: sys_exc
RefactoringTool: Adding transformation: throw
RefactoringTool: Adding transformation: tuple_params
RefactoringTool: Adding transformation: types
RefactoringTool: Adding transformation: unicode
RefactoringTool: Adding transformation: urllib
RefactoringTool: Adding transformation: ws_comma
RefactoringTool: Adding transformation: xrange
RefactoringTool: Adding transformation: xreadlines
RefactoringTool: Adding transformation: zip
RefactoringTool: Descending into .
RefactoringTool: Refactoring ./config.py
RefactoringTool: No changes to ./config.py
RefactoringTool: No changes to ./config.py
RefactoringTool: Refactoring ./server.py
RefactoringTool: Refactored ./server.py
RefactoringTool: Wrote changes to ./server.py
RefactoringTool: Descending into ./fw
RefactoringTool: Refactoring ./fw/__init__.py
RefactoringTool: No changes in ./fw/__init__.py
RefactoringTool: Refactoring ./fw/client.py
RefactoringTool: Refactored ./fw/client.py
RefactoringTool: Wrote changes to ./fw/client.py
RefactoringTool: Refactoring ./fw/db.py
RefactoringTool: No changes to ./fw/db.py
RefactoringTool: No changes to ./fw/db.py
RefactoringTool: Refactoring ./fw/interface.py
RefactoringTool: No changes to ./fw/interface.py
RefactoringTool: No changes to ./fw/interface.py
RefactoringTool: Refactoring ./fw/register.py
RefactoringTool: Refactored ./fw/register.py
RefactoringTool: Wrote changes to ./fw/register.py
RefactoringTool: Refactoring ./fw/util.py
RefactoringTool: Refactored ./fw/util.py
RefactoringTool: Wrote changes to ./fw/util.py
RefactoringTool: Refactoring ./fw/world.py
RefactoringTool: Refactored ./fw/world.py
RefactoringTool: Wrote changes to ./fw/world.py
RefactoringTool: Files that were modified:
RefactoringTool: ./config.py
RefactoringTool: ./server.py
RefactoringTool: ./fw/client.py
RefactoringTool: ./fw/db.py
RefactoringTool: ./fw/interface.py
RefactoringTool: ./fw/register.py
RefactoringTool: ./fw/util.py
RefactoringTool: ./fw/world.py
--- ./server.py	(original)
+++ ./server.py	(refactored)
@@ -1,5 +1,5 @@
 import threading
-import SocketServer
+import socketserver
 import socket
 import string
 import traceback
@@ -36,7 +36,7 @@
         return self.lastid

     def get_client(self, cid):
-        for c, i in self.idmap.iteritems():
+        for c, i in self.idmap.items():
             if i == cid:
                 return c
         return None
@@ -50,7 +50,7 @@
         self.clients.remove(client)

-class ThreadedTCPRequestHandler(SocketServer.StreamRequestHandler):
+class ThreadedTCPRequestHandler(socketserver.StreamRequestHandler):
     """
     Basic handler for TCP input
     Interfaces with the FW client class
@@ -76,7 +76,7 @@
         self.silent = False
         self.op = False

-        print("New client: " + ip)
+        print(("New client: " + ip))
         self.wfile.write("Welcome!\n")
         for data in self.rfile:
             try:
@@ -86,7 +86,7 @@
                 traceback.print_exc()
                 self.wfile.write("An error occured. Please reconnect...\n")
                 break
-        print("Client disconnected: " + ip)
+        print(("Client disconnected: " + ip))
         self.cl.on_disconnect()
         self.server.cr.delete(self.cl)
         if not self.silent:
@@ -121,7 +121,7 @@
         return False

     def scmd_shutdown(self, rest):
-        print("Shutdown request by " + self.cl.name)
+        print(("Shutdown request by " + self.cl.name))
         self.server.running = False
         return True

@@ -169,7 +169,7 @@
         return True

-class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
+class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
     allow_reuse_address = True

 if __name__ == "__main__":
--- ./fw/client.py	(original)
+++ ./fw/client.py	(refactored)
@@ -12,11 +12,11 @@
     """

     cmds = {
-            'chat'   : 'cmd_chat',
-            'name'   : 'cmd_name',
-            'help'   : 'cmd_help',
-            'create' : 'cmd_create',
-            'play'   : 'cmd_play',
+            'chat': 'cmd_chat',
+            'name': 'cmd_name',
+            'help': 'cmd_help',
+            'create': 'cmd_create',
+            'play': 'cmd_play',
     }

@@ -95,16 +95,16 @@
             return r

         cmds = {}
-        for k, c in self.cmds.items():
+        for k, c in list(self.cmds.items()):
             cmds[k] = clientcmd(getattr(self, c))
         if self.player is not None:
-            for k, c in self.player.cmds.items():
+            for k, c in list(self.player.cmds.items()):
                 cmds[k] = getattr(self.player, c)
             for p in self.player.powers:
-                for k, c in p.cmdlist().items():
-                    cmds[k] = getattr(p, c).im_func
+                for k, c in list(p.cmdlist().items()):
+                    cmds[k] = getattr(p, c).__func__
             if self.player.room is not None:
-                for k, c in self.player.room.cmds.items():
+                for k, c in list(self.player.room.cmds.items()):
                     cmds[k] = getattr(self.player.room, c)
         return cmds

@@ -115,7 +115,7 @@
         """
         cmds = self.available_cmds()
         words = data.split()
-        match = filter(lambda x:util.match_name(words[0], x), cmds.keys())
+        match = [x for x in list(cmds.keys()) if util.match_name(words[0], x)]
         if len(match) != 1:
             self.send("Huh?")
             return
--- ./fw/register.py	(original)
+++ ./fw/register.py	(refactored)
@@ -11,7 +11,7 @@

 def get_type(fancy_name):
-    for c in registry.itervalues():
+    for c in registry.values():
         if getattr(c, 'fancy_name', None) == fancy_name:
             return c
     return None
@@ -19,7 +19,7 @@

 def get_types():
     fn = []
-    for c in registry.itervalues():
+    for c in registry.values():
         f = getattr(c, 'fancy_name', None)
         if f is not None and f not in fn:
             fn.append(f)
--- ./fw/util.py	(original)
+++ ./fw/util.py	(refactored)
@@ -1,4 +1,4 @@
-from __future__ import print_function
+

 import types

@@ -7,15 +7,15 @@
 import sys

 member_types = (
-    types.BooleanType,
-    types.DictType,
-    types.FloatType,
-    types.IntType,
-    types.ListType,
-    types.NoneType,
-    types.StringType,
-    types.TupleType,
-    types.UnicodeType,
+    bool,
+    dict,
+    float,
+    int,
+    list,
+    type(None),
+    bytes,
+    tuple,
+    str,
 )

 def log_err(msg):
@@ -45,7 +45,7 @@

 def match_list(short, elts):
-    return filter(lambda x:match_name(short, x.name), elts)
+    return [x for x in elts if match_name(short, x.name)]

 def player_snames(player, allow_no_room=False):
@@ -83,20 +83,20 @@

 def multiple_choice(choices):
-    names = map(lambda x:x.name, choices)
+    names = [x.name for x in choices]
     return "Which one?\nChoices are: " + ', '.join(names)

 def myrepr(obj):
     if type(obj) in (str, int, float, bool):
         return repr(obj)
-    elif type(obj) is list:
+    elif isinstance(obj, list):
         return '[{}]'.format(', '.join([myrepr(x) for x in obj]))
-    elif type(obj) is tuple:
+    elif isinstance(obj, tuple):
         return '({})'.format(', '.join([myrepr(x) for x in obj]))
-    elif type(obj) is dict:
+    elif isinstance(obj, dict):
         return '{{{}}}'.format(', '.join(['{}: {}'.format(myrepr(k), myrepr(v))
-                                            for k, v in obj.items()]))
+                                            for k, v in list(obj.items())]))
     elif obj is None:
         return 'None'
     else:
--- ./fw/world.py	(original)
+++ ./fw/world.py	(refactored)
@@ -64,7 +64,7 @@
         self.emit(player.name + " says: " + rest)

     def cmd_emit(self, player, rest):
-        self.emit(rest.replace('\\n','\n').replace('\\t','\t'))
+        self.emit(rest.replace('\\n', '\n').replace('\\t', '\t'))

     def cmd_link(self, player, rest):
         def doit(arg, _):
@@ -93,12 +93,12 @@

     fancy_name = "player"
     cmds = {
-            "look"     : "cmd_look",
-            "go"       : "cmd_go",
-            "describe" : "cmd_describe",
-            "cmd"      : "cmd_cmd",
-            "destroy"  : "cmd_destroy",
-            "examine"  : "cmd_examine",
+            "look": "cmd_look",
+            "go": "cmd_go",
+            "describe": "cmd_describe",
+            "cmd": "cmd_cmd",
+            "destroy": "cmd_destroy",
+            "examine": "cmd_examine",
     }

     def __init__(self, name):
@@ -137,7 +137,7 @@
     def cmd_describe(self, player, rest):
         def doit(thing, _):
             thing.description = (' '.join(rest.split()[1:])
-                                 .replace('\\n','\n').replace('\\t','\t'))
+                                 .replace('\\n', '\n').replace('\\t', '\t'))

         self.find_doit(rest, doit, noarg="Describe what?")

@@ -148,7 +148,7 @@
                 return
             cmd = rest.split()[1]
             cmd_name = "cmd_" + cmd
-            cmd_txt = ' '.join(rest.split()[2:]).replace('\\n','\n').replace('\\t','\t')
+            cmd_txt = ' '.join(rest.split()[2:]).replace('\\n', '\n').replace('\\t', '\t')
             thing.add_cmd(cmd, cmd_name, cmd_txt)

         self.find_doit(rest, doit, noarg="Add a command to what?")
@@ -284,7 +284,7 @@
     def cmd_exec(self, rest):
         try:
             genv, lenv = self._safe_env()
-            exec(rest.replace('\\n','\n').replace('\\t','\t'), genv, lenv)
+            exec(rest.replace('\\n', '\n').replace('\\t', '\t'), genv, lenv)
         except Exception as pbm:
             self.send(str(pbm))
Fix double parenthesis put by 2to3
Re-align dictionnaries

This is a stylistic change only. 2to3 'fixed' dictionnaries so we're
reverting back to the style we chose: the ':' should all be aligned.
Encode/decode bytes and strings