Browse Source

bugfixes

refactor
Ulrich 2 years ago
parent
commit
ef2c8c9a21
  1. 2
      basic/program.py
  2. 2
      basic/text_const.py
  3. 3
      basic/toolHandling.py
  4. 9
      test/test_02css.py
  5. 6
      utils/conn_tool.py
  6. 12
      utils/css_tool.py
  7. 2
      utils/path_tool.py

2
basic/program.py

@ -504,8 +504,8 @@ class Parameter:
class Configuration: class Configuration:
def __init__ (self, job, program): def __init__ (self, job, program):
self.program = program self.program = program
print (f"job initialisiert {self.program}")
path = utils.path_tool.getBasisConfigPath() path = utils.path_tool.getBasisConfigPath()
print ("conf initialisieren "+self.program+" > "+path)
self.setConfiguration(job, path) self.setConfiguration(job, path)
return return

2
basic/text_const.py

@ -1,5 +1,7 @@
# ----------------- # -----------------
EXP_PATH_MISSING = "path is missing {}"
EXP_CONFIG_MISSING = "config is missing {}"
EXP_KEY_MISSING = "key is missing {}" EXP_KEY_MISSING = "key is missing {}"
EXP_KEY_DOESNT_EXIST = "key {} doesnt exist in domain {}" EXP_KEY_DOESNT_EXIST = "key {} doesnt exist in domain {}"
LIST_EXP_TEXT = [EXP_KEY_MISSING, EXP_KEY_DOESNT_EXIST] LIST_EXP_TEXT = [EXP_KEY_MISSING, EXP_KEY_DOESNT_EXIST]

3
basic/toolHandling.py

@ -63,7 +63,8 @@ def getTool(technicType, comp, job):
# class ToolManager: # class ToolManager:
def getDbTool(job, comp, dbtype=""): def getDbTool(job, comp, dbtype=""):
verify = int(job.getDebugLevel("db_tool")) verify = int(job.getDebugLevel("db_tool"))
dbtype = getCompAttr(comp, B.TOPIC_NODE_DB, B.ATTR_TYPE, "") if len(dbtype) < 3:
dbtype = getCompAttr(comp, B.TOPIC_NODE_DB, B.ATTR_TYPE, "")
toolname = "db"+dbtype+"_tool" toolname = "db"+dbtype+"_tool"
filepath = os.path.join(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_PROGRAM], "utils", toolname+".py") filepath = os.path.join(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_PROGRAM], "utils", toolname+".py")
#comp.m.debug(verify, "toolname "+filepath) #comp.m.debug(verify, "toolname "+filepath)

9
test/test_02css.py

@ -5,6 +5,7 @@ import unittest
import utils.css_tool import utils.css_tool
import basic.program import basic.program
import test.testtools import test.testtools
import basic.constants as B
# the list of TEST_FUNCTIONS defines which function will be really tested. # the list of TEST_FUNCTIONS defines which function will be really tested.
# if you minimize the list you can check the specific test-function # if you minimize the list you can check the specific test-function
@ -24,8 +25,8 @@ class MyTestCase(unittest.TestCase):
"modus": "unit"} "modus": "unit"}
job.par.setParameterArgs(job, args) job.par.setParameterArgs(job, args)
# ------- inline --------------- # ------- inline ---------------
job.conf.setConfig("tools.csstyp", "inline") job.conf.setConfig("tool.css.type", "inline")
job.conf.confs.get("tools")["csstyp"] == "inline" job.conf.confs.get(B.SUBJECT_TOOL).get("css").get("typ") == "inline"
text = utils.css_tool.getInlineStyle(job, "diffFiles", "diffA") text = utils.css_tool.getInlineStyle(job, "diffFiles", "diffA")
self.assertEqual(len(text), 37) self.assertEqual(len(text), 37)
self.assertEqual(("style" in text), True) self.assertEqual(("style" in text), True)
@ -40,7 +41,7 @@ class MyTestCase(unittest.TestCase):
text = utils.css_tool.getExternalStyle(job, "diffFiles") text = utils.css_tool.getExternalStyle(job, "diffFiles")
self.assertEqual(len(text), 0) self.assertEqual(len(text), 0)
# ------- internal --------------- # ------- internal ---------------
job.conf.setConfig("tools.csstyp", "internal") job.conf.setConfig("tool.css.type", "internal")
text = utils.css_tool.getInlineStyle(job, "diffFiles", "diffA") text = utils.css_tool.getInlineStyle(job, "diffFiles", "diffA")
self.assertEqual(len(text), 13) self.assertEqual(len(text), 13)
self.assertEqual(("class" in text), True) self.assertEqual(("class" in text), True)
@ -64,7 +65,7 @@ class MyTestCase(unittest.TestCase):
if verbose: print(text) if verbose: print(text)
if verbose: print(str(len(text))) if verbose: print(str(len(text)))
# ------- external --------------- # ------- external ---------------
job.conf.setConfig("tools.csstyp", "external") job.conf.setConfig("tool.css.type", "external")
text = utils.css_tool.getInlineStyle(job, "diffFiles", "diffA") text = utils.css_tool.getInlineStyle(job, "diffFiles", "diffA")
self.assertEqual(len(text), 13) self.assertEqual(len(text), 13)
self.assertEqual(("class" in text), True) self.assertEqual(("class" in text), True)

6
utils/conn_tool.py

@ -13,7 +13,7 @@ def getConnection(job, comp, nr):
#job = basic.program.Job.getInstance() #job = basic.program.Job.getInstance()
verify = job.getDebugLevel("conn_tool") verify = job.getDebugLevel("conn_tool")
conn = {} conn = {}
if job.conf.confs.get("tools").get("connsrc") == D.DFILE_TYPE_YML: if job.conf.confs.get(B.SUBJECT_TOOL).get("connsrc") == D.DFILE_TYPE_YML:
conn = utils.config_tool.getConfig(job, "tool", B.SUBJECT_CONN) conn = utils.config_tool.getConfig(job, "tool", B.SUBJECT_CONN)
xtypes = None xtypes = None
if ("types" in conn["env"][comp]): if ("types" in conn["env"][comp]):
@ -25,10 +25,6 @@ def getConnection(job, comp, nr):
return conn["env"][comp][instnr] return conn["env"][comp][instnr]
else: else:
job.m.setFatal("Conn-Tool: Comp not configured " + comp + " " + str(nr)) job.m.setFatal("Conn-Tool: Comp not configured " + comp + " " + str(nr))
elif job.conf.confs.get("tools").get("connsrc") == "flaskdb":
pass
elif job.conf.confs.get("tools").get("connsrc") == D.DFILE_TYPE_CSV:
pass
return None return None

12
utils/css_tool.py

@ -1,4 +1,6 @@
import basic.program import basic.program
import basic.constants as B
CSS_CLASS = { CSS_CLASS = {
"general": { "general": {
"table, td, th": "border: 1px solid grey;font-family:sans-serif" "table, td, th": "border: 1px solid grey;font-family:sans-serif"
@ -23,7 +25,7 @@ def getInlineStyle(job, filetype, cssclass):
#job = basic.program.Job.getInstance() #job = basic.program.Job.getInstance()
verify = int(job.getDebugLevel("css_tool")) - 1 verify = int(job.getDebugLevel("css_tool")) - 1
# job.debug(verify, "getDiffHeader ") # job.debug(verify, "getDiffHeader ")
if job.conf.confs.get("tools").get("csstyp") == "inline": if job.conf.confs.get(B.SUBJECT_TOOL).get("css").get("type") == "inline":
out = "style=\""+CSS_CLASS[filetype][cssclass]+"\"" out = "style=\""+CSS_CLASS[filetype][cssclass]+"\""
else: else:
out = "class=\"" + cssclass + "\"" out = "class=\"" + cssclass + "\""
@ -33,7 +35,7 @@ def getInternalStyle(job, filetype):
#job = basic.program.Job.getInstance() #job = basic.program.Job.getInstance()
verify = int(job.getDebugLevel("match_tool")) - 1 verify = int(job.getDebugLevel("match_tool")) - 1
out = "" out = ""
if job.conf.confs.get("tools").get("csstyp") == "internal": if job.conf.confs.get(B.SUBJECT_TOOL).get("css").get("type") == "internal":
out = "<style>" out = "<style>"
for c in CSS_CLASS["general"]: for c in CSS_CLASS["general"]:
line = "\n"+c+" { "+CSS_CLASS["general"][c]+"} " line = "\n"+c+" { "+CSS_CLASS["general"][c]+"} "
@ -44,8 +46,8 @@ def getInternalStyle(job, filetype):
for c in CSS_CLASS[a]: for c in CSS_CLASS[a]:
out += "\n."+c+" { "+CSS_CLASS[a][c].replace(":", ": ").replace(";", "; ")+"} " out += "\n."+c+" { "+CSS_CLASS[a][c].replace(":", ": ").replace(";", "; ")+"} "
out += "\n</style>" out += "\n</style>"
elif job.conf.confs.get("tools").get("csstyp") == "external": elif job.conf.confs.get(B.SUBJECT_TOOL).get("css").get("type") == "external":
out = " <link rel=\"stylesheet\" href=\""+job.conf.confs.get("tools").get("cssfile")+"\"> " out = " <link rel=\"stylesheet\" href=\""+job.conf.confs.get(B.SUBJECT_TOOL).get("css").get("file")+"\"> "
else: else:
out = "<style>" out = "<style>"
for c in CSS_CLASS["general"]: for c in CSS_CLASS["general"]:
@ -59,7 +61,7 @@ def getExternalStyle(job, filetype):
#job = basic.program.Job.getInstance() #job = basic.program.Job.getInstance()
verify = int(job.getDebugLevel("match_tool")) - 1 verify = int(job.getDebugLevel("match_tool")) - 1
out = "" out = ""
if job.conf.confs.get("tools").get("csstyp") == "external": if job.conf.confs.get(B.SUBJECT_TOOL).get("css").get("type") == "external":
arr = filetype.split(",") arr = filetype.split(",")
for a in arr: for a in arr:
for c in CSS_CLASS[a]: for c in CSS_CLASS[a]:

2
utils/path_tool.py

@ -33,7 +33,7 @@ def getHome():
def getBasisConfigPath(): def getBasisConfigPath():
home = os.getcwd() home = os.getcwd()
a = home.split(os.path.sep) a = home.split(os.path.sep)
for i in range(0, len(a)): for i in range(1, len(a)):
path = os.path.sep.join(a[0:-i]) path = os.path.sep.join(a[0:-i])
path = os.path.join(path, P.VAL_CONFIG, B.BASIS_FILE) path = os.path.join(path, P.VAL_CONFIG, B.BASIS_FILE)
for format in utils.config_tool.CONFIG_FORMAT: for format in utils.config_tool.CONFIG_FORMAT:

Loading…
Cancel
Save