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 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