Commit ec411345 authored by Laurent Peuch's avatar Laurent Peuch
Browse files

fix: please flake8

parent 059aaef44ca8
Pipeline #90312 failed with stages
in 30 seconds
......@@ -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 * # noqa
......@@ -14,6 +14,6 @@
# this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"""
AIL - Artificial Intelligence Language
AIL - Artificial Intelligence Language
"""
......@@ -18,5 +18,7 @@
"""
from os.path import join
__revision__ = "$Id: __pkginfo__.py,v 1.16 2005-03-25 14:31:12 adim Exp $"
modname = "ail"
......@@ -44,8 +46,6 @@
scripts = ["bin/ail"]
from os.path import join
include_dirs = [join("test", "data")]
debian_maintainer = "Arthur Lutz"
......
......@@ -63,5 +63,5 @@
brain.load(args)
try:
while True:
input = input(">>> ")
customized_input = input(">>> ")
try:
......@@ -67,5 +67,5 @@
try:
answer = brain.think(input)
answer = brain.think(customized_input)
except AilError as exc:
answer = "Error: %s" % exc
if answer.startswith("assert"):
......@@ -128,7 +128,7 @@
elif line.startswith("include "):
filename = line[8:].strip()
yield from read_from_stream(
file(join(base_dir, filename)), env_context=env_context
open(join(base_dir, filename)), env_context=env_context
)
else:
raise BadAilRule(line)
......@@ -183,7 +183,7 @@
except ValueError:
try:
return float(string)
except:
except Exception:
if encoding is not None:
string = str(string, encoding)
return string
......@@ -202,7 +202,7 @@
"""load rules files"""
for name in filenames:
# print "plugin' brain %s..." % name
self.load_stream(file(name), abspath(dirname(name)), env_context)
self.load_stream(open(name), abspath(dirname(name)), env_context)
self.source_files.append(name)
def reload(self):
......@@ -258,5 +258,5 @@
cycle_stopper += 1
if cycle_stopper > 1000:
raise InfiniteCycleError
## try:
# try:
rule_type, next = self._rewrite(next)
......@@ -262,9 +262,9 @@
rule_type, next = self._rewrite(next)
## except NoRewriteError :
## # FIXME (syt+adim): should not catch this exception, imo rewrite without
## # ending command is a bug in the rule file
## return next
## if rule_type == 'TERMINAL':
# except NoRewriteError :
# # FIXME (syt+adim): should not catch this exception, imo rewrite without
# # ending command is a bug in the rule file
# return next
# if rule_type == 'TERMINAL':
words = self.split(next)
try:
method = getattr(self._cmds_hdlr, words[0].lower())
......
......@@ -23,7 +23,6 @@
import shutil
from distutils.core import setup
from distutils import command
from distutils.command import install_lib
from os.path import isdir, exists, join
from os import walk
......
......@@ -3,6 +3,7 @@
__revision__ = "$Id: %"
if __name__ == "__main__":
import sys, os
import sys
import os
main(os.path.dirname(sys.argv[0]) or ".")
......@@ -47,7 +47,7 @@
return f"added {(subject, predicate, object)} to the knowledge base"
def search(self, subject, predicate, object):
assert (subject, predicate, object) is not (None, None, None)
assert (subject, predicate, object) != (None, None, None)
for triple in self._kb:
(_sub, _pred, _obj) = triple
if (
......@@ -287,8 +287,8 @@
def tearDown(self):
# for_reload.ail is supposed to be empty
fp = file(self.reload_file, "w")
fp = open(self.reload_file, "w")
fp.write(EMPTY_RULEFILE)
fp.close()
def _add_rule_for_reload(self, rule):
......@@ -291,8 +291,8 @@
fp.write(EMPTY_RULEFILE)
fp.close()
def _add_rule_for_reload(self, rule):
fp = file(self.reload_file, "a")
fp = open(self.reload_file, "a")
fp.write(rule + "\n")
fp.close()
......@@ -337,7 +337,7 @@
pass
finally:
sys.stdout = sys.__stdout__
context = {}
# context = {}
# exec "import ail" in context
# exec "ail.run(['data/tests.ail', 'data/input_question'])" in context
......
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