Refactored to allow ConceptEvaluator
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user