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.

168 lines
5.6 KiB

#!/usr/bin/python
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------------------------------------
# Author : Ulrich Carmesin
# Source : gitea.ucarmesin.de
# ---------------------------------------------------------------------------------------------------------
3 years ago
""" In diesem Modul werden alle Funktionen zusammengefasst zur Generierung und Ermittlung von pathsn """
import sys
3 years ago
import basic.program
3 years ago
import utils.config_tool
import re
import basic.constants as B
3 years ago
def getKeyValue(key, comp=None):
3 years ago
job = basic.program.Job.getInstance()
3 years ago
verify = job.getDebugLevel("path_tool")-4
3 years ago
pt = PathConf.getInstance()
job.debug(verify, "getKeyValue " + key)
3 years ago
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)
3 years ago
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
3 years ago
return utils.config_tool.getAttr(comp, key[5:])
elif 'env.' in key:
#if key[4:]
pass
3 years ago
elif (pt.pattern):
return pt.pattern[key]
job.debug(verify, "pt exists")
3 years ago
else:
return "xx-"+key+"-xx"
3 years ago
def composePath(pathname, comp):
3 years ago
job = basic.program.Job.getInstance()
3 years ago
verify = job.getDebugLevel("path_tool")
pt = PathConf.getInstance()
job.debug(verify, "composePath " + pathname + " zu " + str(pt) + "mit ")
job.debug(verify, str(pt.pattern))
3 years ago
if pt.pattern[pathname]:
return composePatttern(pt.pattern[pathname], comp)
else:
job.debug(verify, "in Pattern nicht vorhanden: " + pathname)
3 years ago
3 years ago
def composePatttern(pattern, comp):
3 years ago
job = basic.program.Job.getInstance()
3 years ago
verify = job.getDebugLevel("path_tool")
job.debug(verify, "composePattern " + pattern)
3 years ago
max=5
l = re.findall('\{.*?\}', pattern)
job.debug(verify, l)
3 years ago
for pat in l:
3 years ago
print(str(max) + ": " + pattern + ": " + pat)
pit = getKeyValue(pat[1:-1], comp)
job.debug(verify, str(max) + ": " + pattern + ": " + pat + ": " + pit)
3 years ago
pattern = pattern.replace(pat, pit)
job.debug(verify, str(max) + ": " + pattern + ": " + pat + ": " + pit)
3 years ago
while ("{" in pattern):
max = max-1
job.debug(verify, str(max) + ": " + pattern + ": " + pat + ": " + pit)
3 years ago
pattern = composePatttern(pattern, comp)
job.debug(verify, str(max) + ": " + pattern + ": " + pat + ": " + pit)
3 years ago
if (max < 3) :
break
return pattern
def extractPattern(pathtyp, comp=None):
3 years ago
job = basic.program.Job.getInstance()
verify = job.getDebugLevel("path_tool")
3 years ago
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)
3 years ago
tup = (pre, pat, pit)
out.append(tup)
work = work[j+1:]
return out
def extractPath(pathtyp, pathname):
3 years ago
job = basic.program.Job.getInstance()
3 years ago
patterlist = extractPattern(pathtyp)
work = pathname
i = 0
print("-- extractPatternList -- " + pathtyp + ":" + str(patterlist))
for p in patterlist:
if len(p) < 1 : continue
3 years ago
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