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.
 
 
 

148 lines
4.8 KiB

# All functions related to the full path.
# It implements the team conventions of the directory structure
# -----------------------------------------------------------------------
""" In diesem Modul werden alle Funktionen zusammengefasst zur Generierung und Ermittlung von pathsn """
import sys
import ulrich.program
import utils.config_tool
import re
def getKeyValue(key):
job = ulrich.program.Job.getInstance()
verify = job.getDebugLevel("path_tool")
pt = PathConf.getInstance()
print("getKeyValue " + key)
if 'job.par' in key:
neu = job.getParameter(key[8:])
return neu
elif 'job.conf' in key:
neu = job.conf.confs["paths"][key[9:]]
print(neu)
return neu
# return job.conf.confs["paths"][key[9:]]
elif (pt.pattern):
return pt.pattern[key]
print("pt exists")
else:
return "xx-"+key+"-xx"
def composePath(pathname, comp):
job = ulrich.program.Job.getInstance()
verify = job.getDebugLevel("path_tool")
pt = PathConf.getInstance()
print("composePath " + pathname + " zu " + str(pt) + "mit ")
print(pt.pattern)
if pt.pattern[pathname]:
return composePatttern(pt.pattern[pathname], comp)
else:
print("in Pattern nicht vorhanden: " + pathname)
def composePatttern(pattern, comp):
job = ulrich.program.Job.getInstance()
verify = job.getDebugLevel("path_tool")
print("composePattern " + pattern)
max=5
l = re.findall('\{.*?\}', pattern)
print(l)
for pat in l:
pit = getKeyValue(pat[1:-1])
print(str(max) + ": " + pattern + ": " + pat + ": " + pit)
pattern = pattern.replace(pat, pit)
print(str(max) + ": " + pattern + ": " + pat + ": " + pit)
while ("{" in pattern):
max = max-1
print(str(max) + ": " + pattern + ": " + pat + ": " + pit)
pattern = composePatttern(pattern, comp)
print(str(max) + ": " + pattern + ": " + pat + ": " + pit)
if (max < 3) :
break
return pattern
def extractPattern(pathtyp):
job = ulrich.program.Job.getInstance()
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]
print (work + " von " + str(i) + "-" + str(j) + " pre " + pre + "pat " + pat)
pit = getKeyValue(pat)
tup = (pre, pat, pit)
out.append(tup)
work = work[j+1:]
return out
def extractPath(pathtyp, pathname):
job = ulrich.program.Job.getInstance()
patterlist = extractPattern(pathtyp)
work = pathname
i = 0
print("-- extractPatternList -- " + pathtyp + ":" + str(patterlist))
for p in patterlist:
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