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.
 
 
 

113 lines
3.2 KiB

import basic.constants as B
import tools.data_const as D
def getPurKeyword(inkey):
"""
each key is case-insensitve in lower case.
A keyword can have a singular or plural form - so the plural-s at the end is optional.
A keyword can be assigned as keyword by the beginning digit underscore - so it is optional too.
A keyword in a csv-file can be characterized by the keyword delimited with the in-filed-delimiter colon.
a sub-keyword can be delimited
:param inkey:
:return:
"""
keyPur = inkey.lower()
if ":" in keyPur:
keyPur = keyPur.split(":").pop()
if "-" in keyPur:
keyPur = keyPur.split("-").pop()
if keyPur[0:1] == "_":
keyPur = keyPur[1:]
if keyPur[-1:] == "s":
keyPur = keyPur[:-1]
return keyPur
def getPluralKeyword(inkey):
if "story" in inkey:
return B.SUBJECT_STORIES
return getPurKeyword(inkey)+"s"
def getSingularKeyword(inkey):
"""
singular word is mostly without ending s, except \"stories\"
:param inkey:
:return:
"""
if "stories" in inkey:
return B.SUBJECT_STORY
return getPurKeyword(inkey)
def getPluralAttribut(inkey):
if "story" in inkey:
return "_"+B.SUBJECT_STORIES
return "_"+getPurKeyword(inkey)+"s"
def getSingularAttribut(inkey):
if "stories" in inkey:
return "_"+B.SUBJECT_STORY
return "_"+getPurKeyword(inkey)
def splitDelimitedValues(inValue: str):
return inValue.split(D.INTERNAL_DELIMITER)
def joinValues(inValues: list):
return D.INTERNAL_DELIMITER.join(inValues)
def getExistKeyword(inkey, inDict):
"""
returns the existing keyword in the dictionary
:param inkey: keyword in any form (singular/plural, as attribute or not)
:param inDict: the existing dictionary
:return:
"""
if inkey in inDict:
return inkey
if getSingularKeyword(inkey) in inDict:
return getSingularKeyword(inkey)
if getPluralKeyword(inkey) in inDict:
return getPluralKeyword(inkey)
if getSingularAttribut(inkey) in inDict:
return getSingularAttribut(inkey)
if getPluralAttribut(inkey) in inDict:
return getPluralAttribut(inkey)
return ""
def isStrDict(invalue):
if isinstance(invalue, dict):
return True
if invalue.count(":") == invalue.count(",") + 1:
return True
return False
def getStrDict(invalue):
"""
returns a dict of the input-value.
If it is a string like json (delimited for key-value-pairs by comma and delimted the key-values by colon) then
it is transformed into a dictionary
:param invalue:
:return:
"""
if isinstance(invalue, dict):
return invalue
outDict = {}
if isStrDict(invalue):
keyvalues = invalue.split(",")
for x in keyvalues:
kv = x.split(":")
outDict[kv[0].replace("\"", "")] = kv[1].replace("\"", "")
return outDict
def getValueStr(invalue):
if isinstance(invalue, dict):
keys = list(invalue.keys())
if len(keys) == 0:
return ""
if len(keys) >= 1:
return keys[0]
if isinstance(invalue, list):
if len(invalue) == 0:
return ""
if len(invalue) >= 1:
return invalue[0]
return invalue