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.

79 lines
2.3 KiB

1 year ago
1 year ago
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):
return getPurKeyword(inkey)+"s"
def getSingularKeyword(inkey):
return getPurKeyword(inkey)
def getPluralAttribut(inkey):
return "_"+getPurKeyword(inkey)+"s"
def getSingularAttribut(inkey):
return "_"+getPurKeyword(inkey)
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