Mac 上 Python IDLE 的 .idlerc 文件夹在哪里?
Where is the .idlerc folder for Python IDLE on Mac?
我正在寻找 IDLE 的 .idlerc 文件夹。我的设置是 Python 2.7.9 + Mac OSX El Capitan。此文件夹包含 "config-highlight.cfg" 文件以应用新的自定义主题。
.idlerc
应该在您的 HOME 目录中。目录读写的代码在idlelib/configHandler.py中,在GetUserCfgDir'method'中。我在下面复制了它,删除了无用的 self
参数,并添加了所需的导入。
import os, sys
def GetUserCfgDir():
"""Return a filesystem directory for storing user config files.
Creates it if required.
"""
cfgDir = '.idlerc'
userDir = os.path.expanduser('~')
if userDir != '~': # expanduser() found user home dir
if not os.path.exists(userDir):
warn = ('\n Warning: os.path.expanduser("~") points to\n ' +
userDir + ',\n but the path does not exist.')
try:
print(warn, file=sys.stderr)
except OSError:
pass
userDir = '~'
if userDir == "~": # still no path to home!
# traditionally IDLE has defaulted to os.getcwd(), is this adequate?
userDir = os.getcwd()
userDir = os.path.join(userDir, cfgDir)
if not os.path.exists(userDir):
try:
os.mkdir(userDir)
except OSError:
warn = ('\n Warning: unable to create user config directory\n' +
userDir + '\n Check path and permissions.\n Exiting!\n')
print(warn, file=sys.stderr)
raise SystemExit
# TODO continue without userDIr instead of exit
return userDir
print(GetUserCfgDir())
我会考虑将此信息添加到“首选项”对话框中。但我还注意到,可以通过在对话框中编辑现有主题来添加主题。对于 2.7.11、3.4.4 和 3.5.1,IDLE 有一个新的深色主题。为了使编辑更容易,我们计划添加一种简单的方法来更改所有使用它的项目的默认背景。
我正在寻找 IDLE 的 .idlerc 文件夹。我的设置是 Python 2.7.9 + Mac OSX El Capitan。此文件夹包含 "config-highlight.cfg" 文件以应用新的自定义主题。
.idlerc
应该在您的 HOME 目录中。目录读写的代码在idlelib/configHandler.py中,在GetUserCfgDir'method'中。我在下面复制了它,删除了无用的 self
参数,并添加了所需的导入。
import os, sys
def GetUserCfgDir():
"""Return a filesystem directory for storing user config files.
Creates it if required.
"""
cfgDir = '.idlerc'
userDir = os.path.expanduser('~')
if userDir != '~': # expanduser() found user home dir
if not os.path.exists(userDir):
warn = ('\n Warning: os.path.expanduser("~") points to\n ' +
userDir + ',\n but the path does not exist.')
try:
print(warn, file=sys.stderr)
except OSError:
pass
userDir = '~'
if userDir == "~": # still no path to home!
# traditionally IDLE has defaulted to os.getcwd(), is this adequate?
userDir = os.getcwd()
userDir = os.path.join(userDir, cfgDir)
if not os.path.exists(userDir):
try:
os.mkdir(userDir)
except OSError:
warn = ('\n Warning: unable to create user config directory\n' +
userDir + '\n Check path and permissions.\n Exiting!\n')
print(warn, file=sys.stderr)
raise SystemExit
# TODO continue without userDIr instead of exit
return userDir
print(GetUserCfgDir())
我会考虑将此信息添加到“首选项”对话框中。但我还注意到,可以通过在对话框中编辑现有主题来添加主题。对于 2.7.11、3.4.4 和 3.5.1,IDLE 有一个新的深色主题。为了使编辑更容易,我们计划添加一种简单的方法来更改所有使用它的项目的默认背景。