本文整理匯總了Python中fofix.core.VFS.getWritableResourcePath方法的典型用法代碼示例。如果您正苦於以下問題:Python VFS.getWritableResourcePath方法的具體用法?Python VFS.getWritableResourcePath怎麽用?Python VFS.getWritableResourcePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fofix.core.VFS
的用法示例。
在下文中一共展示了VFS.getWritableResourcePath方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from fofix.core import VFS [as 別名]
# 或者: from fofix.core.VFS import getWritableResourcePath [as 別名]
def __init__(self, prototype, fileName=None, type=0):
"""
@param prototype: The configuration prototype mapping
@param fileName: The file that holds this configuration registry
"""
self.prototype = prototype
# read configuration
self.config = MyConfigParser()
if fileName:
if not os.path.isfile(fileName):
path = VFS.getWritableResourcePath()
fileName = os.path.join(path, fileName)
self.config.read(fileName)
self.fileName = fileName
self.type = type
# fix the defaults and non-existing keys
for section, options in prototype.items():
if not self.config.has_section(section):
self.config.add_section(section)
for option in options.keys():
type = options[option].type
default = options[option].default
if not self.config.has_option(section, option):
self.config.set(section, option, str(default))
示例2: load_config
# 需要導入模塊: from fofix.core import VFS [as 別名]
# 或者: from fofix.core.VFS import getWritableResourcePath [as 別名]
def load_config(configPath):
''' Load the configuration file. '''
if configPath is not None:
if configPath.lower() == "reset":
# Get os specific location of config file, and remove it.
fileName = os.path.join(VFS.getWritableResourcePath(), Version.PROGRAM_UNIXSTYLE_NAME + ".ini")
os.remove(fileName)
# Recreate it
config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
else:
# Load specified config file
config = Config.load(configPath, setAsDefault = True)
else:
# Use default configuration file
config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
return config