Refactored to allow ConceptEvaluator

This commit is contained in:
2019-11-14 22:04:38 +01:00
parent 576ce77740
commit 9e10e77737
30 changed files with 2406 additions and 1007 deletions
+4 -37
View File
@@ -1,8 +1,10 @@
import getopt
import sys
from core.sheerka import Sheerka
import logging
from core.sheerka import Sheerka
import core.utils
def usage():
print("Sheerka v0.1\n")
@@ -10,40 +12,6 @@ def usage():
print(sys.argv[0] + "[-hd] command ")
def sysarg_to_string(argv):
"""
Transform a list of strings into a single string
Add quotes if needed
:return:
"""
if argv is None or not argv:
return ""
result = ""
first = True
for s in argv:
if not first:
result += " "
result += '"' + s + '"' if " " in s else s
first = False
if result[0] in ('"', "'"):
result = result[1:-1] # strip quotes
return result
def init_logging(debug):
if debug:
log_format = "%(asctime)s %(name)s [%(levelname)s] %(message)s"
log_level = logging.DEBUG
else:
log_format = "%(message)s"
log_level = logging.INFO
logging.basicConfig(format=log_format, level=log_level)
def main(argv):
try:
opts, args = getopt.getopt(argv, "hd", ["help", "debug"])
@@ -55,11 +23,10 @@ def main(argv):
if o in ('-d', "--debug"):
debug = True
# init_logging(debug)
sheerka = Sheerka(debug=debug)
sheerka.initialize()
_in = sysarg_to_string(args)
_in = core.utils.sysarg_to_string(args)
result = sheerka.eval(_in)
for res in result: