How to use the cobald.daemon.config.mapping.Translator function in cobald

To help you get started, we’ve selected a few cobald examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MatterMiners / tardis / tardis / configuration / configuration.py View on Github external
def translate_config(obj):
    if isinstance(obj, AttributeDict):
        translated_obj = AttributeDict(obj)
        for key, value in obj.items():
            if key == "user_data":  # base64 encode user data
                with open(os.path.join(os.getcwd(), obj[key]), "rb") as f:
                    translated_obj[key] = b64encode(f.read())
            elif key == "__type__":  # do legacy object initialisation
                return Translator().translate_hierarchy(obj)
            else:
                translated_obj[key] = translate_config(value)
        return translated_obj
    elif isinstance(obj, list):
        return [translate_config(item) for item in obj]
    else:
        return obj