本文整理汇总了Python中pyanaconda.simpleconfig.SimpleConfigFile.unset方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleConfigFile.unset方法的具体用法?Python SimpleConfigFile.unset怎么用?Python SimpleConfigFile.unset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyanaconda.simpleconfig.SimpleConfigFile
的用法示例。
在下文中一共展示了SimpleConfigFile.unset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: unset
# 需要导入模块: from pyanaconda.simpleconfig import SimpleConfigFile [as 别名]
# 或者: from pyanaconda.simpleconfig.SimpleConfigFile import unset [as 别名]
def unset(self, *args):
for key in args:
if self.get(key):
self._dirty = True
break
else:
return
ifcfglog.debug("IfcfgFile.unset %s: %s", self.filename, args)
SimpleConfigFile.unset(self, *args)
示例2: remove_key_test
# 需要导入模块: from pyanaconda.simpleconfig import SimpleConfigFile [as 别名]
# 或者: from pyanaconda.simpleconfig.SimpleConfigFile import unset [as 别名]
def remove_key_test(self):
from pyanaconda.simpleconfig import SimpleConfigFile
scf = SimpleConfigFile()
scf.read(self.PATH)
scf.unset("BOOT")
scf.write("/tmp/file")
scf.reset()
scf.read("/tmp/file")
self.assertEqual(scf.get("BOOT"), "")
示例3: remove_key_test
# 需要导入模块: from pyanaconda.simpleconfig import SimpleConfigFile [as 别名]
# 或者: from pyanaconda.simpleconfig.SimpleConfigFile import unset [as 别名]
def remove_key_test(self):
with tempfile.NamedTemporaryFile(mode="wt") as testconfig:
testconfig.write(self.TEST_CONFIG)
testconfig.flush()
scf = SimpleConfigFile()
scf.read(testconfig.name)
self.assertEqual(scf.get("BOOT"), "always")
scf.unset("BOOT")
scf.write(testconfig.name)
testconfig.flush()
scf.reset()
scf.read(testconfig.name)
self.assertEqual(scf.get("BOOT"), "")
示例4: unset_test
# 需要导入模块: from pyanaconda.simpleconfig import SimpleConfigFile [as 别名]
# 或者: from pyanaconda.simpleconfig.SimpleConfigFile import unset [as 别名]
def unset_test(self):
scf = SimpleConfigFile()
scf.set(('key1', 'value1'))
scf.unset(('key1'))
self.assertEqual(scf.get('key1'), '')