Commit c3fde200 authored by Nicolas Chauvat's avatar Nicolas Chauvat
Browse files

refactor: 2to3

parent 2f72c6714581
......@@ -3,4 +3,4 @@
__revision__ = '$Id: __init__.py,v 1.3 2004-09-24 10:49:30 syt Exp $'
from ail import *
from .ail import *
......@@ -38,7 +38,7 @@
:type status: int
:param status: exit status
"""
print __doc__ % basename(sys.argv[0])
print(__doc__ % basename(sys.argv[0]))
sys.exit(status)
def run(args):
......@@ -50,8 +50,8 @@
long_list = ['help']
try:
optlist, args = getopt.getopt(args, 'h', long_list)
except getopt.error, ex:
print 'Error:', ex
except getopt.error as ex:
print('Error:', ex)
usage(1)
for opt, val in optlist:
if opt in ('-h', '--help'):
......@@ -61,6 +61,6 @@
brain.load(args)
try:
while True :
input = raw_input('>>> ')
input = input('>>> ')
try:
answer = brain.think(input)
......@@ -65,5 +65,5 @@
try:
answer = brain.think(input)
except AilError, exc:
except AilError as exc:
answer = 'Error: %s' % exc
if answer.startswith('assert') :
......@@ -68,4 +68,4 @@
answer = 'Error: %s' % exc
if answer.startswith('assert') :
print "I learned that", answer[6:]
print("I learned that", answer[6:])
elif answer.startswith('search') :
......@@ -71,3 +71,3 @@
elif answer.startswith('search') :
print "I search for", answer[6:]
print("I search for", answer[6:])
else :
......@@ -73,5 +73,5 @@
else :
print answer
print(answer)
except (KeyboardInterrupt, EOFError) :
# print "I'm dying..."
pass
......@@ -166,7 +166,7 @@
return float(string)
except:
if encoding is not None:
string = unicode(string, encoding)
string = str(string, encoding)
return string
class Brain(object):
......@@ -228,7 +228,7 @@
"""process the given input, returning the value produced by thinking
(i.e. a direct answer or the result of a command)
"""
if isinstance(input, unicode):
if isinstance(input, str):
encoding = encoding or self.encoding
input = input.encode(self.encoding)
else:
......
......@@ -17,7 +17,7 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
""" Generic Setup script, takes package info from __pkginfo__.py file """
from __future__ import nested_scopes
import os
import sys
......@@ -28,7 +28,7 @@
from os.path import isdir, exists, join, walk
# import required features
from __pkginfo__ import modname, version, license, short_desc, long_desc, \
from .__pkginfo__ import modname, version, license, short_desc, long_desc, \
web, author, author_email
# import optional features
try:
......@@ -32,7 +32,7 @@
web, author, author_email
# import optional features
try:
from __pkginfo__ import distname
from .__pkginfo__ import distname
except ImportError:
distname = modname
try:
......@@ -36,7 +36,7 @@
except ImportError:
distname = modname
try:
from __pkginfo__ import scripts
from .__pkginfo__ import scripts
except ImportError:
scripts = []
try:
......@@ -40,7 +40,7 @@
except ImportError:
scripts = []
try:
from __pkginfo__ import data_files
from .__pkginfo__ import data_files
except ImportError:
data_files = None
try:
......@@ -44,7 +44,7 @@
except ImportError:
data_files = None
try:
from __pkginfo__ import subpackage_of
from .__pkginfo__ import subpackage_of
except ImportError:
subpackage_of = None
try:
......@@ -48,7 +48,7 @@
except ImportError:
subpackage_of = None
try:
from __pkginfo__ import include_dirs
from .__pkginfo__ import include_dirs
except ImportError:
include_dirs = []
try:
......@@ -52,7 +52,7 @@
except ImportError:
include_dirs = []
try:
from __pkginfo__ import ext_modules
from .__pkginfo__ import ext_modules
except ImportError:
ext_modules = None
......@@ -110,7 +110,7 @@
continue
src = '%s/%s' % (directory, filename)
dest = to_dir + src[len(from_dir):]
print >> sys.stderr, src, '->', dest
print(src, '->', dest, file=sys.stderr)
if os.path.isdir(src):
if not exists(dest):
os.mkdir(dest)
......@@ -120,7 +120,7 @@
shutil.copy2(src, dest)
try:
os.mkdir(to_dir)
except OSError, ex:
except OSError as ex:
# file exists ?
import errno
if ex.errno != errno.EEXIST:
......
......@@ -15,7 +15,7 @@
import unittest
import re
import sys
from cStringIO import StringIO
from io import StringIO
from logilab.common.testlib import TestCase
from logilab.common.fileutils import ensure_fs_mode
from stat import S_IWRITE
......@@ -171,7 +171,7 @@
self.assertEqual(res, [('alf', 'WORKS_FOR', 'logilab')])
def test_think_search_multiline(self):
self.assert_(re.match(MATCH_EXPR, STMT_XML))
self.assertTrue(re.match(MATCH_EXPR, STMT_XML))
res = self.brain.think(STMT_XML)
self.assertEqual(res, "rdf-import")
......
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