Ulrich Carmesin
3 years ago
6 changed files with 114 additions and 6 deletions
@ -0,0 +1,17 @@ |
|||
# |
|||
# the internal datastructure is a tree with this design: |
|||
# root { : constant |
|||
# + option { : constant |
|||
# + |
|||
# + steps |
|||
# + comp { : variable component-name |
|||
# + substructure { : variable maybe scheme, table of a database-component |
|||
# + + _header [ : constant |
|||
# - fields : variable field-name |
|||
DATA_NODE_DATA = "_data" |
|||
|
|||
# the configuration of a component or tool |
|||
# entity { : variable name of the group, basic, component-name or tool-name |
|||
# + subject { : variable subject-name - it correspondends to a tool |
|||
# + + sub-subject { : variable subject-name - it correspondends to a tool |
|||
# + attributes : constant of the tool in which the attribute ist implemented |
@ -1,9 +1,61 @@ |
|||
# |
|||
import importlib, os |
|||
|
|||
import basic.program |
|||
# ------------------------------------------------- |
|||
|
|||
def hasAttr(o, name): |
|||
print("hasAttr " + str(type(o))+" "+name) |
|||
if (isinstance(o, dict)): |
|||
if (name in o.keys()): |
|||
print("hasAttr dict ok " + str(type(o))) |
|||
return True |
|||
print("hasAttr dict "+str(type(o))) |
|||
elif (isinstance(o, list)): |
|||
print("hasAttr list "+str(type(o))) |
|||
elif hasattr(o, name): |
|||
print("hasAttr class ok "+str(type(o))) |
|||
return True |
|||
return False |
|||
|
|||
""" |
|||
Toolmanager |
|||
""" |
|||
class ToolManager: |
|||
# for c job.conf.toolscls |
|||
# c = importlib. [c].capital(c()) |
|||
pass |
|||
# class ToolManager: |
|||
def getDbTool(comp): |
|||
job = basic.program.Job.getInstance() |
|||
verify = int(job.getDebugLevel("db_tool")) |
|||
if not hasAttr(comp.conf["conn"], "dbtype"): |
|||
if hasAttr(comp.conf["conn"], "types") and hasAttr(comp.conf["conn"]["types"], "dbtype"): |
|||
dbtype = comp.conf["conn"]["types"]["dbtype"] |
|||
else: |
|||
raise LookupError("dbtype is not set in comp " + comp.name) |
|||
else: |
|||
dbtype = comp.conf["conn"]["dbtype"] |
|||
toolname = "db"+dbtype+"_tool" |
|||
print("toolname "+toolname) |
|||
filepath = os.path.join(job.conf.confs["paths"]["program"], "utils", toolname+".py") |
|||
print("toolname "+filepath) |
|||
if not os.path.exists(filepath): |
|||
raise FileNotFoundError("file for tool "+toolname+" does not exist "+filepath) |
|||
cmodul = importlib.import_module("utils."+toolname) |
|||
class_ = getattr(cmodul, "DbFcts") |
|||
c = class_() |
|||
c.setComp(comp) |
|||
return c |
|||
|
|||
def getCliTool(comp): |
|||
job = basic.program.Job.getInstance() |
|||
verify = int(job.getDebugLevel("db_tool")) |
|||
if not hasAttr(comp.conf["conn"], "clitype"): |
|||
raise LookupError("dbtype is not set in comp " + comp.name) |
|||
toolname = "cli"+comp.conf["conn"]["clitype"]+"_tool" |
|||
print("toolname "+toolname) |
|||
filepath = os.path.join(job.conf.confs["paths"]["program"], "utils", toolname+".py") |
|||
print("toolname "+filepath) |
|||
if not os.path.exists(filepath): |
|||
raise FileNotFoundError("file for tool "+toolname+" does not exist "+filepath) |
|||
cmodul = importlib.import_module("utils."+toolname) |
|||
class_ = getattr(cmodul, "CliFcts") |
|||
c = class_() |
|||
c.setComp(comp) |
|||
return c |
|||
|
Loading…
Reference in new issue