""" This has only one function. It mostly exists to allow imports of things like tftypes """ from copy import deepcopy from tfscript.tftypes import Double def makeCFG(bindList, default=False): if default: # Write to defaultDict instead of condDict Double.condDict = Double.defaultDict else: Double.condDict = deepcopy(Double.defaultDict) ret = '' for bind in bindList: ret += bind.toTF2() # Doubles are weird. All of the toggles got put into a dictionary. # This takes all of the nested dictionaries and turns them into the right string if default or Double.condDict != Double.defaultDict: # ==, and by extension !=, does in fact check # for dictionary equality in keys and values for key, toggles in Double.condDict.items(): onCondPress = ';'.join(toggles["change_keys"]) onCondRelease = ';'.join(toggles["restore_keys"]) ret += ( f'alias +{key}_toggles "{onCondPress}"\n' + f'alias -{key}_toggles "{onCondRelease}"\n' + f'bind {key} "+{key}_toggles"\n' ) return ret