Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
7cff66d4
Kaydet (Commit)
7cff66d4
authored
Şub 01, 2002
tarafından
Steven M. Gava
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
improve user config dir handling
üst
a498af26
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
13 deletions
+31
-13
configHandler.py
Lib/idlelib/configHandler.py
+31
-13
No files found.
Lib/idlelib/configHandler.py
Dosyayı görüntüle @
7cff66d4
...
...
@@ -152,28 +152,46 @@ class IdleConf:
"""
#build idle install path
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)
idledir
=
os
.
path
.
abspath
(
sys
.
path
[
0
])
#print idledir
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
)
idleDir
=
os
.
path
.
abspath
(
sys
.
path
[
0
])
userDir
=
self
.
GetUserCfgDir
()
configTypes
=
(
'main'
,
'extensions'
,
'highlight'
,
'keys'
)
defCfgFiles
=
{}
usrCfgFiles
=
{}
for
cfgType
in
configTypes
:
#build config file names
defCfgFiles
[
cfgType
]
=
os
.
path
.
join
(
idle
d
ir
,
'config-'
+
cfgType
+
'.def'
)
usrCfgFiles
[
cfgType
]
=
os
.
path
.
join
(
user
d
ir
,
'config-'
+
cfgType
+
'.cfg'
)
defCfgFiles
[
cfgType
]
=
os
.
path
.
join
(
idle
D
ir
,
'config-'
+
cfgType
+
'.def'
)
usrCfgFiles
[
cfgType
]
=
os
.
path
.
join
(
user
D
ir
,
'config-'
+
cfgType
+
'.cfg'
)
for
cfgType
in
configTypes
:
#create config parsers
self
.
defaultCfg
[
cfgType
]
=
IdleConfParser
(
defCfgFiles
[
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
):
"""
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