本文整理汇总了Python中exe.engine.configparser.ConfigParser.delete方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigParser.delete方法的具体用法?Python ConfigParser.delete怎么用?Python ConfigParser.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exe.engine.configparser.ConfigParser
的用法示例。
在下文中一共展示了ConfigParser.delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Config
# 需要导入模块: from exe.engine.configparser import ConfigParser [as 别名]
# 或者: from exe.engine.configparser.ConfigParser import delete [as 别名]
#.........这里部分代码省略.........
self.deprecatediDevices.remove(key.lower())
# Load the "user" section
if self.configParser.has_section('user'):
if self.configParser.user.has_option('editorMode'):
self.editorMode = self.configParser.user.editorMode
if self.configParser.user.has_option('docType'):
self.docType = self.configParser.user.docType
common.setExportDocType(self.configParser.user.docType)
if self.configParser.user.has_option('defaultStyle'):
self.defaultStyle= self.configParser.user.defaultStyle
if self.configParser.user.has_option('styleSecureMode'):
self.styleSecureMode= self.configParser.user.styleSecureMode
if self.configParser.user.has_option('internalAnchors'):
self.internalAnchors = self.configParser.user.internalAnchors
if self.configParser.user.has_option('lastDir'):
self.lastDir = self.configParser.user.lastDir
if self.configParser.user.has_option('showPreferencesOnStart'):
self.showPreferencesOnStart = self.configParser.user.showPreferencesOnStart
if self.configParser.user.has_option('showIdevicesGrouped'):
self.showIdevicesGrouped = self.configParser.user.showIdevicesGrouped
if self.configParser.user.has_option('locale'):
self.locale = self.configParser.user.locale
return
self.locale = chooseDefaultLocale(self.localeDir)
def onWrite(self, configParser):
"""
Called just before the config file is written.
We use it to fill out any settings that are stored here and
not in the config parser itself
"""
# Recent projects
self.configParser.delete('recent_projects')
recentProjectsSection = self.configParser.addSection('recent_projects')
for num, path in enumerate(self.recentProjects):
recentProjectsSection[str(num)] = path
def setupLogging(self):
"""
setup logging file
"""
try:
hdlr = RotatingFileHandler(self.configDir/'exe.log', 'a',
500000, 10)
hdlr.doRollover()
except OSError:
# ignore the error we get if the log file is logged
hdlr = logging.FileHandler(self.configDir/'exe.log')
format = "%(asctime)s %(name)s %(levelname)s %(message)s"
log = logging.getLogger()
hdlr.setFormatter(logging.Formatter(format))
log.addHandler(hdlr)
loggingLevels = {"DEBUG" : logging.DEBUG,
"INFO" : logging.INFO,
"WARNING" : logging.WARNING,
"ERROR" : logging.ERROR,
"CRITICAL" : logging.CRITICAL }
if self.configParser.has_section('logging'):
for logger, level in self.configParser._sections["logging"].items():
if logger == "root":
logging.getLogger().setLevel(loggingLevels[level])
示例2: __init__
# 需要导入模块: from exe.engine.configparser import ConfigParser [as 别名]
# 或者: from exe.engine.configparser.ConfigParser import delete [as 别名]
#.........这里部分代码省略.........
value = value.strip().lower()
if value == "0" or value == "no" or value == "false" or \
value == "off":
self.hiddeniDevices.append(key.lower())
#self.deprecatediDevices = [ "flash with text", "flash movie", ...]
# and UN-Load from the list of "deprecated" iDevices
if self.configParser.has_section('deprecated'):
deprecatedSection = self.configParser.deprecated
for key,value in deprecatedSection.items():
# emulate standard library's getboolean()
value = value.strip().lower()
if value == "1" or value == "yes" or value == "true" or \
value == "on":
if key.lower() in self.deprecatediDevices:
self.deprecatediDevices.remove(key.lower())
# Load the "user" section
if self.configParser.has_section('user'):
if self.configParser.user.has_option('internalAnchors'):
self.internalAnchors = self.configParser.user.internalAnchors
if self.configParser.user.has_option('locale'):
self.locale = self.configParser.user.locale
return
self.locale = chooseDefaultLocale(self.localeDir)
def onWrite(self, configParser):
"""
Called just before the config file is written.
We use it to fill out any settings that are stored here and
not in the config parser itself
"""
# Recent projects
self.configParser.delete('recent_projects')
recentProjectsSection = self.configParser.addSection('recent_projects')
for num, path in enumerate(self.recentProjects):
recentProjectsSection[str(num)] = path
def setupLogging(self):
"""
setup logging file
"""
try:
hdlr = RotatingFileHandler(self.configDir/'exe.log', 'a',
500000, 10)
hdlr.doRollover()
except OSError:
# ignore the error we get if the log file is logged
hdlr = logging.FileHandler(self.configDir/'exe.log')
format = "%(asctime)s %(name)s %(levelname)s %(message)s"
log = logging.getLogger()
hdlr.setFormatter(logging.Formatter(format))
log.addHandler(hdlr)
loggingLevels = {"DEBUG" : logging.DEBUG,
"INFO" : logging.INFO,
"WARNING" : logging.WARNING,
"ERROR" : logging.ERROR,
"CRITICAL" : logging.CRITICAL }
if self.configParser.has_section('logging'):
for logger, level in self.configParser._sections["logging"].items():
if logger == "root":
logging.getLogger().setLevel(loggingLevels[level])
示例3: __init__
# 需要导入模块: from exe.engine.configparser import ConfigParser [as 别名]
# 或者: from exe.engine.configparser.ConfigParser import delete [as 别名]
#.........这里部分代码省略.........
self.configDir.mkdir()
self.recentProjects = []
if self.configParser.has_section('recent_projects'):
recentProjectsSection = self.configParser.recent_projects
for key, path in recentProjectsSection.items():
self.recentProjects.append(path)
self.hiddeniDevices = []
if self.configParser.has_section('idevices'):
idevicesSection = self.configParser.idevices
for key,value in idevicesSection.items():
value = value.strip().lower()
if value == "0" or value == "no" or value == "false" or \
value == "off":
self.hiddeniDevices.append(key.lower())
if self.configParser.has_section('deprecated'):
deprecatedSection = self.configParser.deprecated
for key,value in deprecatedSection.items():
value = value.strip().lower()
if value == "1" or value == "yes" or value == "true" or \
value == "on":
if key.lower() in self.deprecatediDevices:
self.deprecatediDevices.remove(key.lower())
if self.configParser.has_section('user'):
if self.configParser.user.has_option('locale'):
self.locale = self.configParser.user.locale
return
self.locale = chooseDefaultLocale(self.localeDir)
def onWrite(self, configParser):
"""
Called just before the config file is written.
We use it to fill out any settings that are stored here and
not in the config parser itself
"""
self.configParser.delete('recent_projects')
recentProjectsSection = self.configParser.addSection('recent_projects')
for num, path in enumerate(self.recentProjects):
recentProjectsSection[str(num)] = path
def setupLogging(self):
"""
setup logging file
"""
try:
hdlr = RotatingFileHandler(self.configDir/'exe.log', 'a',
500000, 10)
hdlr.doRollover()
except OSError:
hdlr = logging.FileHandler(self.configDir/'exe.log')
format = "%(asctime)s %(name)s %(levelname)s %(message)s"
log = logging.getLogger()
hdlr.setFormatter(logging.Formatter(format))
log.addHandler(hdlr)
loggingLevels = {"DEBUG" : logging.DEBUG,
"INFO" : logging.INFO,
"WARNING" : logging.WARNING,
"ERROR" : logging.ERROR,
"CRITICAL" : logging.CRITICAL }
if self.configParser.has_section('logging'):
for logger, level in self.configParser._sections["logging"].items():
if logger == "root":
logging.getLogger().setLevel(loggingLevels[level])
else:
logging.getLogger(logger).setLevel(loggingLevels[level])
log.info("************** eXe logging started **************")
log.info("configPath = %s" % self.configPath)
log.info("exePath = %s" % self.exePath)
log.info("browserPath = %s" % self.browserPath)
示例4: TestConfigParser
# 需要导入模块: from exe.engine.configparser import ConfigParser [as 别名]
# 或者: from exe.engine.configparser.ConfigParser import delete [as 别名]
#.........这里部分代码省略.........
self.c.set('main', 'testing', 'ok')
self.c.write('temp.ini')
file_ = open('temp.ini')
try:
data = file_.read()
assert data == '[main]\ntesting = ok', data
finally:
file_.close()
os.remove('temp.ini')
def testGet(self):
"""Tests the get method"""
file_ = testFile()
self.c.read(file_)
assert self.c.get('main', 'testing') == 'false'
assert self.c.get('main', 'not exists', 'default') == 'default'
self.failUnlessRaises(ValueError, self.c.get, 'main', 'not exists')
def testSet(self):
"""Test the set method"""
file_ = testFile()
self.c.read(file_)
# An existing option
self.c.set('main', 'testing', 'perhaps')
assert self.c._sections['main']['testing'] == 'perhaps'
# A new and numeric option
self.c.set('main', 'new option', 4.1)
self.assertEquals(self.c._sections['main']['new option'], '4.1')
# A new option in a new section
self.c.set('new section', 'new option', 4.1)
assert self.c._sections['new section']['new option'] == '4.1'
def testDel(self):
"""Should be able to delete a section and/or a value in a section"""
file_ = testFile()
self.c.read(file_)
assert self.c._sections['main']['level'] == '5'
self.c.delete('main', 'level')
assert not self.c._sections['main'].has_key('level')
self.c.delete('main')
assert not self.c._sections.has_key('main')
def testShortening(self):
"""There was a bug (Issue 66) where when a longer name was read
and a shorter name was written, the extra characters of the
longer name would remain in the entry"""
file_ = open('temp.ini', 'w')
file_.write(TEST_TEXT)
file_.close()
self.c.read('temp.ini')
self.c.set('second', 'available', 'abcdefghijklmnop')
self.c.write('temp.ini')
c2 = ConfigParser()
c2.read('temp.ini')
c2.set('second', 'available', 'short')
c2.write('temp.ini')
self.c.read('temp.ini')
assert self.c.get('second', 'available', '') == 'short', \
self.c.get('second', 'available', '')
def testUnicodeSet(self):
"""
Should be able to set unicode option values
with both python internal unicode strings
or raw string containing utf8 encoded data
"""