shyaml.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:smarthome 作者: smarthomeNG 项目源码 文件源码
def writeBackToFile(filename, itempath, itemattr, value):
    """
    write the value of an item's attribute back to the yaml-file

    :param filename: name of the yaml-file (without the .yaml extension!)
    :param itempath: path of the item to modify
    :param itemattr: name of the item's attribute to modify
    :param value: new value for the attribute

    :return: formatted string
    """

    itemyamlfile = yamlfile(filename)
    if os.path.isfile(filename+YAML_FILE):
        itemyamlfile.load()
    itemyamlfile.setleafvalue(itempath, itemattr, value)
    itemyamlfile.save()


# ==================================================================================
#   class yamlfile (for editing multiple entries at a time)
#
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号