本文整理汇总了Python中iniparse.RawConfigParser.get方法的典型用法代码示例。如果您正苦于以下问题:Python RawConfigParser.get方法的具体用法?Python RawConfigParser.get怎么用?Python RawConfigParser.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iniparse.RawConfigParser
的用法示例。
在下文中一共展示了RawConfigParser.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: inifile_readstring
# 需要导入模块: from iniparse import RawConfigParser [as 别名]
# 或者: from iniparse.RawConfigParser import get [as 别名]
def inifile_readstring(inifilename,section,key,default=None):
"""Read a string parameter from inifile"""
inifile = RawConfigParser()
inifile.read(inifilename)
if inifile.has_section(section) and inifile.has_option(section,key):
return inifile.get(section,key)
else:
return default
示例2: __init__
# 需要导入模块: from iniparse import RawConfigParser [as 别名]
# 或者: from iniparse.RawConfigParser import get [as 别名]
class Config:
OUT_EDDN = 1
OUT_BPC = 2
OUT_TD = 4
OUT_CSV = 8
OUT_SHIP_EDS = 16
OUT_LOG_FILE = 32
#OUT_STAT = 64 # No longer available
OUT_SHIP_CORIOLIS = 128
OUT_LOG_EDSM = 256
OUT_LOG_AUTO = 512
if platform=='darwin':
def __init__(self):
self.app_dir = join(NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)[0], appname)
if not isdir(self.app_dir):
mkdir(self.app_dir)
self.plugin_dir = join(self.app_dir, 'plugins')
if not isdir(self.plugin_dir):
mkdir(self.plugin_dir)
self.home = expanduser('~')
self.respath = getattr(sys, 'frozen', False) and normpath(join(dirname(sys.executable), pardir, 'Resources')) or dirname(__file__)
if not getattr(sys, 'frozen', False):
# Don't use Python's settings if interactive
self.bundle = 'uk.org.marginal.%s' % appname.lower()
NSBundle.mainBundle().infoDictionary()['CFBundleIdentifier'] = self.bundle
self.bundle = NSBundle.mainBundle().bundleIdentifier()
self.defaults = NSUserDefaults.standardUserDefaults()
settings = self.defaults.persistentDomainForName_(self.bundle) or {}
self.settings = dict(settings)
# Check out_dir exists
if not self.get('outdir') or not isdir(self.get('outdir')):
self.set('outdir', NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, True)[0])
def get(self, key):
return self.settings.get(key)
def getint(self, key):
try:
return int(self.settings.get(key, 0)) # should already be int, but check by casting
except:
return 0
def set(self, key, val):
self.settings[key] = val
def save(self):
self.defaults.setPersistentDomain_forName_(self.settings, self.bundle)
self.defaults.synchronize()
def close(self):
self.save()
self.defaults = None
elif platform=='win32':
def __init__(self):
buf = ctypes.create_unicode_buffer(MAX_PATH)
ctypes.windll.shell32.SHGetSpecialFolderPathW(0, buf, CSIDL_LOCAL_APPDATA, 0)
self.app_dir = join(buf.value, appname)
if not isdir(self.app_dir):
mkdir(self.app_dir)
self.plugin_dir = join(self.app_dir, 'plugins')
if not isdir(self.plugin_dir):
mkdir(self.plugin_dir)
# expanduser in Python 2 on Windows doesn't handle non-ASCII - http://bugs.python.org/issue13207
ctypes.windll.shell32.SHGetSpecialFolderPathW(0, buf, CSIDL_PROFILE, 0)
self.home = buf.value
self.respath = dirname(getattr(sys, 'frozen', False) and sys.executable or __file__)
self.hkey = HKEY()
disposition = DWORD()
if RegCreateKeyEx(HKEY_CURRENT_USER, r'Software\Marginal\EDMarketConnector', 0, None, 0, KEY_ALL_ACCESS, None, ctypes.byref(self.hkey), ctypes.byref(disposition)):
raise Exception()
if disposition.value == REG_CREATED_NEW_KEY:
# Migrate pre-1.3.4 registry location
oldkey = HKEY()
if not RegOpenKeyEx(HKEY_CURRENT_USER, r'Software\EDMarketConnector', 0, KEY_ALL_ACCESS, ctypes.byref(oldkey)):
RegCopyTree(oldkey, None, self.hkey)
RegCloseKey(oldkey)
RegDeleteKey(HKEY_CURRENT_USER, r'Software\EDMarketConnector')
# set WinSparkle defaults - https://github.com/vslavik/winsparkle/wiki/Registry-Settings
sparklekey = HKEY()
if not RegCreateKeyEx(self.hkey, 'WinSparkle', 0, None, 0, KEY_ALL_ACCESS, None, ctypes.byref(sparklekey), ctypes.byref(disposition)):
if disposition.value == REG_CREATED_NEW_KEY:
buf = ctypes.create_unicode_buffer('1')
#.........这里部分代码省略.........
示例3: __init__
# 需要导入模块: from iniparse import RawConfigParser [as 别名]
# 或者: from iniparse.RawConfigParser import get [as 别名]
class Config:
OUT_EDDN = 1
OUT_BPC = 2
OUT_TD = 4
OUT_CSV = 8
OUT_SHIP = 16
OUT_LOG = 32
if platform == "darwin":
def __init__(self):
self.app_dir = join(
NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)[0], appname
)
if not isdir(self.app_dir):
mkdir(self.app_dir)
if not getattr(sys, "frozen", False):
# Don't use Python's settings if interactive
self.bundle = "uk.org.marginal.%s" % appname.lower()
NSBundle.mainBundle().infoDictionary()["CFBundleIdentifier"] = self.bundle
self.bundle = NSBundle.mainBundle().bundleIdentifier()
self.defaults = NSUserDefaults.standardUserDefaults()
settings = self.defaults.persistentDomainForName_(self.bundle) or {}
self.settings = dict(settings)
# Check out_dir exists
if not self.get("outdir") or not isdir(self.get("outdir")):
self.set("outdir", NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, True)[0])
def get(self, key):
return self.settings.get(key)
def getint(self, key):
try:
return int(self.settings.get(key, 0)) # should already be int, but check by casting
except:
return 0
def set(self, key, val):
self.settings[key] = val
def close(self):
self.defaults.setPersistentDomain_forName_(self.settings, self.bundle)
self.defaults.synchronize()
self.defaults = None
elif platform == "win32":
def __init__(self):
buf = ctypes.create_unicode_buffer(MAX_PATH)
ctypes.windll.shell32.SHGetSpecialFolderPathW(0, buf, CSIDL_LOCAL_APPDATA, 0)
self.app_dir = join(buf.value, appname)
if not isdir(self.app_dir):
mkdir(self.app_dir)
self.hkey = HKEY()
disposition = DWORD()
if RegCreateKeyEx(
HKEY_CURRENT_USER,
r"Software\Marginal\EDMarketConnector",
0,
None,
0,
KEY_ALL_ACCESS,
None,
ctypes.byref(self.hkey),
ctypes.byref(disposition),
):
raise Exception()
if disposition.value == REG_CREATED_NEW_KEY:
# Migrate pre-1.3.4 registry location
oldkey = HKEY()
if not RegOpenKeyEx(
HKEY_CURRENT_USER, r"Software\EDMarketConnector", 0, KEY_ALL_ACCESS, ctypes.byref(oldkey)
):
SHCopyKey(oldkey, None, self.hkey, 0)
SHDeleteKey(oldkey, "")
RegCloseKey(oldkey)
# set WinSparkle defaults - https://github.com/vslavik/winsparkle/wiki/Registry-Settings
sparklekey = HKEY()
if not RegCreateKeyEx(
self.hkey,
"WinSparkle",
0,
None,
0,
KEY_ALL_ACCESS,
None,
ctypes.byref(sparklekey),
ctypes.byref(disposition),
):
if disposition.value == REG_CREATED_NEW_KEY:
buf = ctypes.create_unicode_buffer("1")
RegSetValueEx(sparklekey, "CheckForUpdates", 0, 1, buf, len(buf) * 2)
#.........这里部分代码省略.........
示例4: __init__
# 需要导入模块: from iniparse import RawConfigParser [as 别名]
# 或者: from iniparse.RawConfigParser import get [as 别名]
class Config:
OUT_MKT_EDDN = 1
OUT_MKT_BPC = 2
OUT_MKT_TD = 4
OUT_MKT_CSV = 8
OUT_SHIP_EDS = 16
# OUT_SYS_FILE = 32 # No longer supported
# OUT_STAT = 64 # No longer available
OUT_SHIP_CORIOLIS = 128
OUT_STATION_ANY = OUT_MKT_EDDN|OUT_MKT_BPC|OUT_MKT_TD|OUT_MKT_CSV|OUT_SHIP_EDS|OUT_SHIP_CORIOLIS
OUT_SYS_EDSM = 256
# OUT_SYS_AUTO = 512 # Now always automatic
OUT_MKT_MANUAL = 1024
OUT_SYS_EDDN = 2048
OUT_SYS_DELAY = 4096
if platform=='darwin':
def __init__(self):
self.app_dir = join(NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)[0], appname)
if not isdir(self.app_dir):
mkdir(self.app_dir)
self.plugin_dir = join(self.app_dir, 'plugins')
if not isdir(self.plugin_dir):
mkdir(self.plugin_dir)
self.default_journal_dir = join(NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)[0], 'Frontier Developments', 'Elite Dangerous')
self.home = expanduser('~')
self.respath = getattr(sys, 'frozen', False) and normpath(join(dirname(sys.executable), pardir, 'Resources')) or dirname(__file__)
if not getattr(sys, 'frozen', False):
# Don't use Python's settings if interactive
self.bundle = 'uk.org.marginal.%s' % appname.lower()
NSBundle.mainBundle().infoDictionary()['CFBundleIdentifier'] = self.bundle
else:
self.bundle = NSBundle.mainBundle().bundleIdentifier()
self.defaults = NSUserDefaults.standardUserDefaults()
self.settings = dict(self.defaults.persistentDomainForName_(self.bundle) or {}) # make writeable
# Check out_dir exists
if not self.get('outdir') or not isdir(self.get('outdir')):
self.set('outdir', NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, True)[0])
def get(self, key):
val = self.settings.get(key)
if hasattr(val, '__iter__'):
return list(val) # make writeable
else:
return val
def getint(self, key):
try:
return int(self.settings.get(key, 0)) # should already be int, but check by casting
except:
return 0
def set(self, key, val):
self.settings[key] = val
def delete(self, key):
self.settings.pop(key, None)
def save(self):
self.defaults.setPersistentDomain_forName_(self.settings, self.bundle)
self.defaults.synchronize()
def close(self):
self.save()
self.defaults = None
elif platform=='win32':
def __init__(self):
self.app_dir = join(KnownFolderPath(FOLDERID_LocalAppData), appname)
if not isdir(self.app_dir):
mkdir(self.app_dir)
self.plugin_dir = join(self.app_dir, 'plugins')
if not isdir(self.plugin_dir):
mkdir(self.plugin_dir)
# expanduser in Python 2 on Windows doesn't handle non-ASCII - http://bugs.python.org/issue13207
self.home = KnownFolderPath(FOLDERID_Profile) or u'\\'
journaldir = KnownFolderPath(FOLDERID_SavedGames)
self.default_journal_dir = journaldir and join(journaldir, 'Frontier Developments', 'Elite Dangerous') or None
self.respath = dirname(getattr(sys, 'frozen', False) and sys.executable or __file__)
self.hkey = HKEY()
disposition = DWORD()
if RegCreateKeyEx(HKEY_CURRENT_USER, r'Software\Marginal\EDMarketConnector', 0, None, 0, KEY_ALL_ACCESS, None, ctypes.byref(self.hkey), ctypes.byref(disposition)):
raise Exception()
if disposition.value == REG_CREATED_NEW_KEY:
#.........这里部分代码省略.........
示例5: __init__
# 需要导入模块: from iniparse import RawConfigParser [as 别名]
# 或者: from iniparse.RawConfigParser import get [as 别名]
class Config:
OUT_EDDN = 1
OUT_BPC = 2
OUT_TD = 4
OUT_CSV = 8
if platform=='darwin':
def __init__(self):
self.app_dir = join(NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, True)[0], appname)
if not isdir(self.app_dir):
mkdir(self.app_dir)
self.bundle = getattr(sys, 'frozen', False) and NSBundle.mainBundle().bundleIdentifier() or 'uk.org.marginal.%s' % appname.lower() # Don't use Python's settings if interactive
self.defaults = NSUserDefaults.standardUserDefaults()
settings = self.defaults.persistentDomainForName_(self.bundle) or {}
self.settings = dict(settings)
# Check out_dir exists
if not self.get('outdir') or not isdir(self.get('outdir')):
self.set('outdir', NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, True)[0])
def get(self, key):
return self.settings.get(key)
def getint(self, key):
try:
return int(self.settings.get(key, 0)) # should already be int, but check by casting
except:
return 0
def set(self, key, val):
self.settings[key] = val
def close(self):
self.defaults.setPersistentDomain_forName_(self.settings, self.bundle)
self.defaults.synchronize()
self.defaults = None
elif platform=='win32':
def __init__(self):
CSIDL_PERSONAL = 0x0005
CSIDL_LOCAL_APPDATA = 0x001C
buf = ctypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH)
ctypes.windll.shell32.SHGetSpecialFolderPathW(0, buf, CSIDL_LOCAL_APPDATA, 0)
self.app_dir = join(buf.value, appname)
if not isdir(self.app_dir):
mkdir(self.app_dir)
self.handle = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, r'Software\%s' % appname)
if not self.get('outdir') or not isdir(self.get('outdir')):
ctypes.windll.shell32.SHGetSpecialFolderPathW(0, buf, CSIDL_PERSONAL, 0)
self.set('outdir', buf.value)
def get(self, key):
try:
return _winreg.QueryValueEx(self.handle, key)[0]
except:
return None
def getint(self, key):
try:
return int(_winreg.QueryValueEx(self.handle, key)[0]) # should already be int, but check by casting
except:
return 0
def set(self, key, val):
if isinstance(val, basestring):
_winreg.SetValueEx(self.handle, key, 0, _winreg.REG_SZ, val)
elif isinstance(val, numbers.Integral):
_winreg.SetValueEx(self.handle, key, 0, _winreg.REG_DWORD, val)
else:
raise NotImplementedError()
def close(self):
_winreg.CloseKey(self.handle)
self.handle = None
elif platform=='linux2':
def __init__(self):
# http://standards.freedesktop.org/basedir-spec/latest/ar01s03.html
self.app_dir = join(getenv('XDG_DATA_HOME', expanduser('~/.local/share')), appname)
if not isdir(self.app_dir):
makedirs(self.app_dir)
self.filename = join(getenv('XDG_CONFIG_HOME', expanduser('~/.config')), appname, '%s.ini' % appname)
if not isdir(dirname(self.filename)):
makedirs(dirname(self.filename))
self.config = RawConfigParser()
try:
self.config.readfp(codecs.open(self.filename, 'r', 'utf-8'))
# XXX handle missing?
except:
self.config.add_section('DEFAULT')
#.........这里部分代码省略.........
示例6: main
# 需要导入模块: from iniparse import RawConfigParser [as 别名]
# 或者: from iniparse.RawConfigParser import get [as 别名]
def main():
if len(args) == 0:
print "ERROR : You must provide one action to perform"
parser.print_usage()
sys.exit(2)
action = args[0]
# Config file
if not os.path.isfile(config_file):
logger.error("Error : could not find file : " + config_file + ", please check the path")
logger.debug("Config file: %s" % config_file)
defaults = {
"repositories": "",
"repo_url": "",
"default_source_url": "",
"private_key": "",
"public_cert": "",
"default_development_base": "c:\tranquilit",
"default_package_prefix": "tis",
"default_sources_suffix": "wapt",
"default_sources_url": "",
"upload_cmd": "",
"wapt_server": "",
"loglevel": "info",
}
cp = RawConfigParser(defaults=defaults)
cp.add_section("global")
cp.read(config_file)
global loglevel
if not loglevel and cp.has_option("global", "loglevel"):
loglevel = cp.get("global", "loglevel")
setloglevel(loglevel)
mywapt = Wapt(config=cp)
if options.wapt_url:
mywapt.wapt_repourl = options.wapt_url
if options.private_key:
mywapt.private_key = options.private_key
else:
mywapt.private_key = cp.get("global", "private_key")
mywapt.dry_run = options.dry_run
# logger.info("Main wapt Repository %s" % mywapt.wapt_repourl)
logger.debug("WAPT base directory : %s" % mywapt.wapt_base_dir)
logger.debug("Package cache dir : %s" % mywapt.packagecachedir)
logger.debug("WAPT DB Structure version;: %s" % mywapt.waptdb.db_version)
try:
params_dict = {}
try:
params_dict = json.loads(options.params.replace("'", '"'))
except:
raise Exception("Install Parameters must be in json format")
if action == "install" or action == "download":
if len(args) < 2:
print "You must provide at least one package name"
sys.exit(1)
if os.path.isdir(args[1]) or os.path.isfile(args[1]):
print "installing WAPT file %s" % args[1]
if action == "install":
mywapt.install_wapt(args[1], params_dict=params_dict)
else:
print "%sing WAPT packages %s" % (action, ",".join(args[1:]))
if options.update_packages:
print "Update package list"
mywapt.update()
result = mywapt.install(
args[1:], force=options.force, params_dict=params_dict, download_only=(action == "download")
)
print "\nResults :"
if action <> "download":
for k in ("install", "additional", "upgrade", "skipped", "errors"):
if result.get(k, []):
print "\n=== %s packages ===\n%s" % (
k,
"\n".join(
[" %-30s | %s (%s)" % (s[0], s[1].package, s[1].version) for s in result[k]]
),
)
else:
for k in ("downloaded", "skipped", "errors"):
if result.get("downloads", {"downloaded": [], "skipped": [], "errors": []})[k]:
print "\n=== %s packages ===\n%s" % (
k,
"\n".join([" %s" % (s,) for s in result["downloads"][k]]),
)
elif action == "download":
if len(args) < 2:
print "You must provide at least one package name to download"
sys.exit(1)
#.........这里部分代码省略.........