Data-Test-Executer Framework speziell zum Test von Datenverarbeitungen mit Datengenerierung, Systemvorbereitungen, Einspielungen, ganzheitlicher diversifizierender Vergleich
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

167 lines
5.6 KiB

#!/usr/bin/python
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------------------------------------
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
""" In diesem Modul werden alle Funktionen zusammengefasst zur Generierung und Ermittlung von pathsn """
import sys
import basic.program
import utils.config_tool
import re
import basic.constants as B
def getKeyValue(key, comp=None):
job = basic.program.Job.getInstance()
verify = job.getDebugLevel("path_tool")-4
pt = PathConf.getInstance()
job.debug(verify, "getKeyValue " + key)
if 'job.par' in key:
neu = job.getParameter(key[8:])
return neu
elif 'job.conf' in key:
neu = job.conf.confs[B.SUBJECT_PATH][key[9:]]
job.debug(verify, neu)
return neu
# return job.conf.confs["paths"][key[9:]]
elif 'comp.' in key:
if comp is None:
raise Exception("Component is missing for "+key)
if not utils.config_tool.hasAttr(comp, key[5:]):
pass
return utils.config_tool.getAttr(comp, key[5:])
elif 'env.' in key:
#if key[4:]
pass
elif (pt.pattern):
return pt.pattern[key]
job.debug(verify, "pt exists")
else:
return "xx-"+key+"-xx"
def composePath(pathname, comp):
job = basic.program.Job.getInstance()
verify = job.getDebugLevel("path_tool")
pt = PathConf.getInstance()
job.debug(verify, "composePath " + pathname + " zu " + str(pt) + "mit ")
job.debug(verify, str(pt.pattern))
if pt.pattern[pathname]:
return composePatttern(pt.pattern[pathname], comp)
else:
job.debug(verify, "in Pattern nicht vorhanden: " + pathname)
def composePatttern(pattern, comp):
job = basic.program.Job.getInstance()
verify = job.getDebugLevel("path_tool")
job.debug(verify, "composePattern " + pattern)
max=5
l = re.findall('\{.*?\}', pattern)
job.debug(verify, l)
for pat in l:
print(str(max) + ": " + pattern + ": " + pat)
pit = getKeyValue(pat[1:-1], comp)
job.debug(verify, str(max) + ": " + pattern + ": " + pat + ": " + pit)
pattern = pattern.replace(pat, pit)
job.debug(verify, str(max) + ": " + pattern + ": " + pat + ": " + pit)
while ("{" in pattern):
max = max-1
job.debug(verify, str(max) + ": " + pattern + ": " + pat + ": " + pit)
pattern = composePatttern(pattern, comp)
job.debug(verify, str(max) + ": " + pattern + ": " + pat + ": " + pit)
if (max < 3) :
break
return pattern
def extractPattern(pathtyp, comp=None):
job = basic.program.Job.getInstance()
verify = job.getDebugLevel("path_tool")
out = []
pt = PathConf.getInstance()
pattern = pt.pattern[pathtyp]
work = pattern
while "{" in work:
i = work.index("{")
j = work.index("}")
pre = work[0:i]
pat = work[i+1:j]
job.debug(verify, work + " von " + str(i) + "-" + str(j) + " pre " + pre + "pat " + pat)
pit = getKeyValue(pat, comp)
tup = (pre, pat, pit)
out.append(tup)
work = work[j+1:]
return out
def extractPath(pathtyp, pathname):
job = basic.program.Job.getInstance()
patterlist = extractPattern(pathtyp)
work = pathname
i = 0
print("-- extractPatternList -- " + pathtyp + ":" + str(patterlist))
for p in patterlist:
if len(p) < 1 : continue
delim = p[0]
key = p[1]
val = p[2]
nextdelim = ""
if i >= len(patterlist) - 1:
nextdelim = ""
else:
nextdelim = patterlist[i+1][0]
print("xPath delim " + delim + " " + str(len(delim)) + ", " + nextdelim + " work " + work)
work = work[len(delim):]
print("xPath key " + key + " i " + str(i) + " work " + work)
if val is not None:
print("val not none " + val)
if val in work:
print("val ok")
work = work.replace(val, "")
elif "time" in key and "job.par" in key:
prop = ""
if i < len(patterlist) - 1:
prop = work[0:work.index(nextdelim)]
else:
prop = work
key = key[8:]
print("setprop " + key + " = " + prop)
if hasattr(job.par, key): delattr(job.par, key)
setattr(job.par, key, val)
else:
print("val not not ok " + val + " zu " + key)
elif "job.par" in key:
prop = ""
if i < len(patterlist) - 1:
print("job.par nextdelim " + nextdelim)
prop = work[0:work.index(nextdelim)]
else:
prop = work
key = key[8:]
print("setprop " + key + " = " + prop)
if hasattr(job.par, key): delattr(job.par, key)
setattr(job.par, key, prop)
work = work.replace(prop, "")
else:
print("val is none " + key)
i = i +1
class PathConf:
__instance = None
def __init__(self):
print('init pathConf')
confs = utils.config_tool.getConfig("tool", "path")
self.pattern = confs["pattern"]
print(self.pattern)
PathConf.__instance = self
@staticmethod
def getInstance():
#print("PathConf getInstance " + str(PathConf.__instance))
if (PathConf.__instance is None):
PathConf()
#print("PathConf getInstance " + str(PathConf.__instance))
return PathConf.__instance