Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
7cff66d4
Commit
7cff66d4
authored
Feb 01, 2002
by
Steven M. Gava
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve user config dir handling
parent
a498af26
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
13 deletions
+31
-13
Lib/idlelib/configHandler.py
Lib/idlelib/configHandler.py
+31
-13
No files found.
Lib/idlelib/configHandler.py
View file @
7cff66d4
...
@@ -152,28 +152,46 @@ class IdleConf:
...
@@ -152,28 +152,46 @@ class IdleConf:
"""
"""
#build idle install path
#build idle install path
if
__name__
!=
'__main__'
:
# we were imported
if
__name__
!=
'__main__'
:
# we were imported
idle
d
ir
=
os
.
path
.
dirname
(
__file__
)
idle
D
ir
=
os
.
path
.
dirname
(
__file__
)
else
:
# we were exec'ed (for testing only)
else
:
# we were exec'ed (for testing only)
idledir
=
os
.
path
.
abspath
(
sys
.
path
[
0
])
idleDir
=
os
.
path
.
abspath
(
sys
.
path
[
0
])
#print idledir
userDir
=
self
.
GetUserCfgDir
()
try
:
#build user home path
userdir
=
os
.
environ
[
'HOME'
]
#real home directory
except
KeyError
:
userdir
=
os
.
getcwd
()
#hack for os'es without real homedirs
userdir
=
os
.
path
.
join
(
userdir
,
'.idlerc'
)
#print userdir
if
not
os
.
path
.
exists
(
userdir
):
os
.
mkdir
(
userdir
)
configTypes
=
(
'main'
,
'extensions'
,
'highlight'
,
'keys'
)
configTypes
=
(
'main'
,
'extensions'
,
'highlight'
,
'keys'
)
defCfgFiles
=
{}
defCfgFiles
=
{}
usrCfgFiles
=
{}
usrCfgFiles
=
{}
for
cfgType
in
configTypes
:
#build config file names
for
cfgType
in
configTypes
:
#build config file names
defCfgFiles
[
cfgType
]
=
os
.
path
.
join
(
idle
d
ir
,
'config-'
+
cfgType
+
'.def'
)
defCfgFiles
[
cfgType
]
=
os
.
path
.
join
(
idle
D
ir
,
'config-'
+
cfgType
+
'.def'
)
usrCfgFiles
[
cfgType
]
=
os
.
path
.
join
(
user
d
ir
,
'config-'
+
cfgType
+
'.cfg'
)
usrCfgFiles
[
cfgType
]
=
os
.
path
.
join
(
user
D
ir
,
'config-'
+
cfgType
+
'.cfg'
)
for
cfgType
in
configTypes
:
#create config parsers
for
cfgType
in
configTypes
:
#create config parsers
self
.
defaultCfg
[
cfgType
]
=
IdleConfParser
(
defCfgFiles
[
cfgType
])
self
.
defaultCfg
[
cfgType
]
=
IdleConfParser
(
defCfgFiles
[
cfgType
])
self
.
userCfg
[
cfgType
]
=
IdleUserConfParser
(
usrCfgFiles
[
cfgType
])
self
.
userCfg
[
cfgType
]
=
IdleUserConfParser
(
usrCfgFiles
[
cfgType
])
def
GetUserCfgDir
(
self
):
"""
Creates (if required) and returns a filesystem directory for storing
user config files.
"""
cfgDir
=
'.idlerc'
userDir
=
os
.
path
.
expanduser
(
'~'
)
if
userDir
!=
'~'
:
#'HOME' exists as a key in os.environ
if
not
os
.
path
.
exists
(
userDir
):
warn
=
(
'
\
n
Warning: HOME environment variable points to
\
n
'
+
userDir
+
'
\
n
but the path does not exist.
\
n
'
)
sys
.
stderr
.
write
(
warn
)
userDir
=
'~'
if
userDir
==
'~'
:
#we still don't have a home directory
#traditionally idle has defaulted to os.getcwd(), is this adeqate?
userDir
=
os
.
getcwd
()
#hack for no real homedir
userDir
=
os
.
path
.
join
(
userDir
,
cfgDir
)
if
not
os
.
path
.
exists
(
userDir
):
try
:
#make the config dir if it doesn't exist yet
os
.
mkdir
(
userDir
)
except
IOError
:
warn
=
(
'
\
n
Warning: unable to create user config directory
\
n
'
+
userDir
+
'
\
n
'
)
sys
.
stderr
.
write
(
warn
)
return
userDir
def
GetOption
(
self
,
configType
,
section
,
option
,
default
=
None
,
type
=
None
):
def
GetOption
(
self
,
configType
,
section
,
option
,
default
=
None
,
type
=
None
):
"""
"""
Get an option value for given config type and given general
Get an option value for given config type and given general
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment