本文整理汇总了Python中CIME.XML.generic_xml.GenericXML.invalidate方法的典型用法代码示例。如果您正苦于以下问题:Python GenericXML.invalidate方法的具体用法?Python GenericXML.invalidate怎么用?Python GenericXML.invalidate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIME.XML.generic_xml.GenericXML
的用法示例。
在下文中一共展示了GenericXML.invalidate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: lock_file
# 需要导入模块: from CIME.XML.generic_xml import GenericXML [as 别名]
# 或者: from CIME.XML.generic_xml.GenericXML import invalidate [as 别名]
def lock_file(filename, caseroot=None, newname=None):
expect("/" not in filename, "Please just provide basename of locked file")
caseroot = os.getcwd() if caseroot is None else caseroot
newname = filename if newname is None else newname
fulllockdir = os.path.join(caseroot, LOCKED_DIR)
if not os.path.exists(fulllockdir):
os.mkdir(fulllockdir)
logging.debug("Locking file {}".format(filename))
# JGF: It is extremely dangerous to alter our database (xml files) without
# going through the standard API. The copy below invalidates all existing
# GenericXML instances that represent this file and all caching that may
# have involved this file. We should probably seek a safer way of locking
# files.
safe_copy(os.path.join(caseroot, filename), os.path.join(fulllockdir, newname))
GenericXML.invalidate(os.path.join(fulllockdir, newname))