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
c11ccf35
Kaydet (Commit)
c11ccf35
authored
Eyl 24, 2001
tarafından
Steven M. Gava
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
start of new config handling stuff
üst
fa26f7cc
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
468 additions
and
48 deletions
+468
-48
config-extensions.def
Lib/idlelib/config-extensions.def
+34
-0
config-highlight.def
Lib/idlelib/config-highlight.def
+56
-0
config-keys.def
Lib/idlelib/config-keys.def
+58
-0
config-main.def
Lib/idlelib/config-main.def
+63
-0
configDialog.py
Lib/idlelib/configDialog.py
+84
-48
configHandler.py
Lib/idlelib/configHandler.py
+173
-0
No files found.
Lib/idlelib/config-extensions.def
0 → 100644
Dosyayı görüntüle @
c11ccf35
# IDLE reads several config files to determine user preferences. This
# file is the default config file for idle extensions settings.
[SearchBinding]
enable=1
[AutoIndent]
enable=1
[AutoExpand]
enable=1
[FormatParagraph]
enable=1
[ZoomHeight]
enable=1
#[ScriptBinding] # disabled in favor of ExecBinding
#enable=0
[ExecBinding]
enable=1
[CallTips]
enable=1
[ParenMatch]
enable=0
style= expression
flash-delay= 500
bell= 1
hilite-foreground= black
hilite-background= #43cd80
Lib/idlelib/config-highlight.def
0 → 100644
Dosyayı görüntüle @
c11ccf35
# IDLE reads several config files to determine user preferences. This
# file is the default config file for idle highlight theme settings.
[IDLE Classic Old - plain fonts]
normal-foreground= black
normal-background= white
normal-fontStyle= normal
keyword-foreground= #ff7700
keyword-fontStyle= normal
comment-foreground= #dd0000
comment-fontStyle= normal
string-foreground= #00aa00
string-fontStyle= normal
definition-foreground= #0000ff
definition-fontStyle= normal
hilite-foreground= #000068
hilite-background= #006868
hilite-fontStyle= normal
break-foreground= #ff7777
break-fontStyle= normal
hit-background= #000000
hit-foreground= #ffffff
hit-fontStyle= normal
cursor-background= black
error-background= #ff7777
#shell window
stdout-foreground= blue
stdout-fontStyle= normal
stderr-foreground= red
stderr-fontStyle= normal
console-foreground= #770000
console-fontStyle= normal
[IDLE Classic New]
normal-foreground= black
normal-background= white
normal-fontStyle= normal
keyword-foreground= #ff7700
keyword-fontStyle= bold
comment-foreground= #dd0000
comment-fontStyle= italic
string-foreground= #00aa00
string-fontStyle= normal
definition-foreground= #0000ff
definition-fontStyle= bold
hilite-foreground= #000068
hilite-background= #006868
break-foreground= #ff7777
hit-background= #000000
hit-foreground= #ffffff
cursor-background= black
error-background= #ff7777
#shell window
stdout-foreground= blue
stderr-foreground= red
console-foreground= #770000
Lib/idlelib/config-keys.def
0 → 100644
Dosyayı görüntüle @
c11ccf35
# IDLE reads several config files to determine user preferences. This
# file is the default config file for idle key binding settings.
[IDLE Classic - windows]
Copy= '<Control-c> <Control-C>'
Cut= '<Control-x> <Control-X>'
Paste= '<Control-v> <Control-V>'
beginning-of-line= '<Control-a> <Home>'
center-insert= '<Control-l>'
close-all-windows= '<Control-q>'
close-window= '<Alt-F4>'
dump-undo-state= '<Control-backslash>'
end-of-file= '<Control-d>'
python-docs= '<F1>'
history-next= '<Alt-n>'
history-previous= '<Alt-p>'
interrupt-execution= '<Control-c>'
open-class-browser= '<Alt-c>'
open-module= '<Alt-m>'
open-new-window= '<Control-n>'
open-window-from-file= '<Control-o>'
plain-newline-and-indent= '<Control-j>'
redo= '<Control-y>'
remove-selection= '<Escape>'
save-copy-of-window-as-file= '<Alt-Shift-s>'
save-window-as-file= '<Alt-s>'
save-window= '<Control-s>'
select-all= '<Alt-a>'
toggle-auto-coloring= '<Control-slash>'
undo= '<Control-z>'
[IDLE Classic - posix]
Copy= '<Alt-w> <Meta-w>'
Cut= '<Control-w>'
Paste= '<Control-y>'
beginning-of-line= '<Control-a> <Home>'
center-insert= '<Control-l>'
close-all-windows= '<Control-x><Control-c>'
close-window= '<Control-x><Control-0> <Control-x><Key-0>'
do-nothing= '<Control-x>'
dump-undo-state= '<Control-backslash>'
end-of-file= '<Control-d>'
help= '<F1>'
history-next= '<Alt-n> <Meta-n>'
history-previous= '<Alt-p> <Meta-p>'
interrupt-execution= '<Control-c>'
open-class-browser= '<Control-x><Control-b>'
open-module= '<Control-x><Control-m>'
open-new-window= '<Control-x><Control-n>'
open-window-from-file= '<Control-x><Control-f>'
plain-newline-and-indent= '<Control-j>'
redo= '<Alt-z> <Meta-z>'
save-copy-of-window-as-file= '<Control-x><w>'
save-window-as-file= '<Control-x><Control-w>'
save-window= '<Control-x><Control-s>'
select-all= '<Alt-a> <Meta-a>'
toggle-auto-coloring= '<Control-slash>'
undo= '<Control-z>'
Lib/idlelib/config-main.def
0 → 100644
Dosyayı görüntüle @
c11ccf35
# IDLE reads several config files to determine user preferences. This
# file is the default config file for general idle settings.
#
# When IDLE starts, it will look in
# the following two sets of files, in order:
#
# default configuration
# ---------------------
# config-main.def the default general config file
# config-extensions.def the default extension config file
# config-highlight.def the default highlighting config file
# config-keys.def the default keybinding config file
#
# user configuration
# -------------------
# ~/.idlerc/idle-main.cfg the user general config file
# ~/.idlerc/idle-extensions.cfg the user extension config file
# ~/.idlerc/idle-highlight.cfg the user highlighting config file
# ~/.idlerc/idle-keys.cfg the user keybinding config file
# XXX what about Windows?
#
# Any options the user saves through the config dialog will be saved to
# the relevant user config file. Reverting any general setting to the
# default causes that entry to be wiped from the user file and re-read
# from the default file. User highlighting themes or keybinding sets are
# retained unless specifically deleted within the config dialog. Choosing
# one of the default themes or keysets just applies the relevant settings
# from the default file.
[General]
run-in-separate-process= 1
[EditorWindow]
width= 80
height= 24
font= courier
font-size= 12
[Indent]
use-spaces= 1
num-spaces= 4
tab-cols= 4
[Theme]
user= 0
name= "IDLE Classic New"
[Keys]
user= 0
name= "IDLE Classic - windows"
[RecentFiles]
1=
2=
3=
4=
5=
6=
7=
8=
9=
10=
Lib/idlelib/configDialog.py
Dosyayı görüntüle @
c11ccf35
...
...
@@ -10,7 +10,7 @@ configuration dialog
from
Tkinter
import
*
import
tkMessageBox
,
tkColorChooser
,
tkFont
import
I
dleConf
from
configHandler
import
i
dleConf
class
ConfigDialog
(
Toplevel
):
"""
...
...
@@ -24,10 +24,7 @@ class ConfigDialog(Toplevel):
self
.
configure
(
borderwidth
=
5
)
self
.
geometry
(
"+
%
d+
%
d"
%
(
parent
.
winfo_rootx
()
+
20
,
parent
.
winfo_rooty
()
+
30
))
self
.
LoadConfig
()
#elguavas - config placeholders til config stuff completed
self
.
bg
=
self
.
cget
(
'bg'
)
self
.
fg
=
None
#self.LoadConfig()
self
.
CreateWidgets
()
self
.
resizable
(
height
=
FALSE
,
width
=
FALSE
)
...
...
@@ -45,19 +42,9 @@ class ConfigDialog(Toplevel):
self
.
bind
(
'<Alt-h>'
,
self
.
ChangePageBinding
)
self
.
bind
(
'<Alt-k>'
,
self
.
ChangePageBinding
)
self
.
bind
(
'<Alt-g>'
,
self
.
ChangePageBinding
)
#self.LoadOptMenuHighlightTarget()
self
.
wait_window
()
def
LoadConfig
(
self
):
#self.configParser=IdleConf.idleconf
#self.loadedConfig={}
#self.workingConfig={}
#for key in .keys():
#print self.configParser.getsection('Colors').options()
self
.
workingTestColours
=
{
'Foo-Bg'
:
'#ffffff'
,
'Foo-Fg'
:
'#000000'
,
'Bar-Bg'
:
'#777777'
}
def
Cancel
(
self
):
self
.
destroy
()
...
...
@@ -134,17 +121,7 @@ class ConfigDialog(Toplevel):
self
.
frameHighlightSample
.
update
()
#redraw after dialog
self
.
labelTestSample
.
update
()
def
__LoadFontList
(
self
):
fonts
=
list
(
tkFont
.
families
(
self
))
fonts
.
sort
()
for
font
in
fonts
:
self
.
listFontName
.
insert
(
END
,
font
)
currentFontIndex
=
fonts
.
index
(
'courier'
)
self
.
listFontName
.
see
(
currentFontIndex
)
self
.
listFontName
.
select_set
(
currentFontIndex
)
self
.
fontSize
.
set
(
'12'
)
def
__SetFontSample
(
self
,
event
):
def
SetFontSample
(
self
,
event
):
self
.
newFont
.
config
(
size
=
self
.
fontSize
.
get
(),
weight
=
NORMAL
,
family
=
self
.
listFontName
.
get
(
self
.
listFontName
.
curselection
()[
0
]))
...
...
@@ -167,13 +144,14 @@ class ConfigDialog(Toplevel):
pageButtonNames
=
(
'Fonts/Tabs'
,
'Highlighting'
,
'Keys'
,
'General'
)
self
.
pageButtons
=
[]
buttonValue
=
0
buttonSelColour
=
framePageButtons
.
cget
(
'bg'
)
for
name
in
pageButtonNames
:
buttonFrame
=
Frame
(
framePageButtons
,
borderwidth
=
2
,
relief
=
RIDGE
)
buttonFrame
.
pack
(
side
=
LEFT
)
button
=
Radiobutton
(
buttonFrame
,
command
=
self
.
ChangePage
,
value
=
buttonValue
,
padx
=
5
,
pady
=
5
,
takefocus
=
FALSE
,
underline
=
0
,
indicatoron
=
FALSE
,
highlightthickness
=
0
,
variable
=
self
.
pageNum
,
selectcolor
=
self
.
bg
,
borderwidth
=
0
,
text
=
name
)
selectcolor
=
buttonSelColour
,
borderwidth
=
0
,
text
=
name
)
button
.
pack
()
button
.
lift
()
self
.
pageButtons
.
append
(
button
)
...
...
@@ -216,21 +194,20 @@ class ConfigDialog(Toplevel):
text
=
'Font :'
)
self
.
listFontName
=
Listbox
(
frameFontName
,
height
=
5
,
takefocus
=
FALSE
,
exportselection
=
FALSE
)
self
.
listFontName
.
bind
(
'<<ListboxSelect>>'
,
self
.
__
SetFontSample
)
self
.
listFontName
.
bind
(
'<<ListboxSelect>>'
,
self
.
SetFontSample
)
scrollFont
=
Scrollbar
(
frameFontName
)
self
.
__
LoadFontList
()
self
.
LoadFontList
()
scrollFont
.
config
(
command
=
self
.
listFontName
.
yview
)
self
.
listFontName
.
config
(
yscrollcommand
=
scrollFont
.
set
)
labelFontSizeTitle
=
Label
(
frameFontSize
,
text
=
'Size :'
)
sizes
=
(
'10'
,
'11'
,
'12'
,
'13'
,
'14'
,
'16'
,
'18'
,
'20'
,
'22'
)
args
=
(
frameFontSize
,
self
.
fontSize
)
+
sizes
keyArgs
=
{
'command'
:
self
.
__
SetFontSample
}
keyArgs
=
{
'command'
:
self
.
SetFontSample
}
optFontSize
=
apply
(
OptionMenu
,
args
,
keyArgs
)
#optFontSize.bind('<<MenuSelect>>',self.__SetFontSample)
frameFontSample
=
Frame
(
frameFont
,
relief
=
SOLID
,
borderwidth
=
1
,
bg
=
self
.
workingTestColours
[
'Foo-Bg'
])
self
.
labelFontSample
=
Label
(
frameFontSample
,
bg
=
self
.
workingTestColours
[
'Foo-Bg'
],
fg
=
'#000000'
,
text
=
'AaBbCcDdEe
\n
FfGgHhIiJjK
\n
1234567890
\n
#:+=(){}[]'
,
#optFontSize.bind('<<MenuSelect>>',self.SetFontSample)
frameFontSample
=
Frame
(
frameFont
,
relief
=
SOLID
,
borderwidth
=
1
)
self
.
labelFontSample
=
Label
(
frameFontSample
,
text
=
'AaBbCcDdEe
\n
FfGgHhIiJjK
\n
1234567890
\n
#:+=(){}[]'
,
justify
=
LEFT
,
font
=
self
.
newFont
)
#frameIndent
labelIndentTitle
=
Label
(
frameIndent
,
text
=
'Set Indentation Defaults'
)
...
...
@@ -299,18 +276,16 @@ class ConfigDialog(Toplevel):
frameCustom
=
Frame
(
frame
,
borderwidth
=
2
,
relief
=
GROOVE
)
frameTheme
=
Frame
(
frame
,
borderwidth
=
2
,
relief
=
GROOVE
)
#frameCustom
frame
Target
=
Frame
(
frameCustom
)
self
.
frameHighlightSample
=
Frame
(
frameCustom
,
relief
=
SOLID
,
borderwidth
=
1
,
b
g
=
self
.
workingTestColours
[
'Foo-Bg'
]
,
cursor
=
'hand2'
)
self
.
frameHighlight
Target
=
Frame
(
frameCustom
)
self
.
frameHighlightSample
=
Frame
(
frameCustom
,
relief
=
SOLID
,
b
orderwidth
=
1
,
cursor
=
'hand2'
)
frameSet
=
Frame
(
frameCustom
)
self
.
frameColourSet
=
Frame
(
frameSet
,
relief
=
SOLID
,
borderwidth
=
1
,
bg
=
self
.
workingTestColours
[
'Foo-Bg'
])
self
.
frameColourSet
=
Frame
(
frameSet
,
relief
=
SOLID
,
borderwidth
=
1
)
frameFontSet
=
Frame
(
frameSet
)
labelCustomTitle
=
Label
(
frameCustom
,
text
=
'Set Custom Highlighting'
)
labelTargetTitle
=
Label
(
frame
Target
,
text
=
'for : '
)
optMenuTarget
=
OptionMenu
(
frame
Target
,
labelTargetTitle
=
Label
(
self
.
frameHighlight
Target
,
text
=
'for : '
)
self
.
optMenuHighlightTarget
=
OptionMenu
(
self
.
frameHighlight
Target
,
self
.
highlightTarget
,
'normal text background'
,
'test target interface item 2'
)
self
.
highlightTarget
.
set
(
'normal text background'
)
buttonSetColour
=
Button
(
self
.
frameColourSet
,
text
=
'Set Colour'
,
command
=
self
.
GetColour
)
labelFontTitle
=
Label
(
frameFontSet
,
text
=
'Set Font Style'
)
...
...
@@ -322,8 +297,7 @@ class ConfigDialog(Toplevel):
text
=
'#when finished, this
\n
#sample area will
\n
#be interactive
\n
'
+
'def Ahem(foo,bar):
\n
'
+
'"""'
+
'doc hazard'
+
'"""'
+
'
\n
test=foo
\n
text=bar
\n
return'
,
bg
=
self
.
workingTestColours
[
'Foo-Bg'
])
'
\n
test=foo
\n
text=bar
\n
return'
)
buttonSaveCustomTheme
=
Button
(
frameCustom
,
text
=
'Save as a Custom Theme'
)
#frameTheme
...
...
@@ -350,13 +324,13 @@ class ConfigDialog(Toplevel):
frameTheme
.
pack
(
side
=
LEFT
,
padx
=
5
,
pady
=
10
,
fill
=
Y
)
#frameCustom
labelCustomTitle
.
pack
(
side
=
TOP
,
anchor
=
W
,
padx
=
5
,
pady
=
5
)
frame
Target
.
pack
(
side
=
TOP
,
padx
=
5
,
pady
=
5
,
fill
=
X
)
self
.
frameHighlight
Target
.
pack
(
side
=
TOP
,
padx
=
5
,
pady
=
5
,
fill
=
X
)
self
.
frameHighlightSample
.
pack
(
side
=
TOP
,
padx
=
5
,
pady
=
5
,
expand
=
TRUE
,
fill
=
BOTH
)
frameSet
.
pack
(
side
=
TOP
,
fill
=
X
)
self
.
frameColourSet
.
pack
(
side
=
LEFT
,
padx
=
5
,
pady
=
5
,
fill
=
BOTH
)
frameFontSet
.
pack
(
side
=
RIGHT
,
padx
=
5
,
pady
=
5
,
anchor
=
W
)
labelTargetTitle
.
pack
(
side
=
LEFT
,
anchor
=
E
)
optMenu
Target
.
pack
(
side
=
RIGHT
,
anchor
=
W
,
expand
=
TRUE
,
fill
=
X
)
self
.
optMenuHighlight
Target
.
pack
(
side
=
RIGHT
,
anchor
=
W
,
expand
=
TRUE
,
fill
=
X
)
buttonSetColour
.
pack
(
expand
=
TRUE
,
fill
=
BOTH
,
padx
=
10
,
pady
=
10
)
labelFontTitle
.
pack
(
side
=
TOP
,
anchor
=
W
)
checkFontBold
.
pack
(
side
=
LEFT
,
anchor
=
W
,
pady
=
2
)
...
...
@@ -529,6 +503,68 @@ class ConfigDialog(Toplevel):
return
frame
def
LoadFontList
(
self
):
fonts
=
list
(
tkFont
.
families
(
self
))
fonts
.
sort
()
for
font
in
fonts
:
self
.
listFontName
.
insert
(
END
,
font
)
currentFontIndex
=
fonts
.
index
(
'courier'
)
self
.
listFontName
.
see
(
currentFontIndex
)
self
.
listFontName
.
select_set
(
currentFontIndex
)
self
.
fontSize
.
set
(
'12'
)
#def LoadOptionMenu(self, optMenu, optList, optVar, optVal=None,
# command=None):
def
LoadOptionMenu
(
self
,
optMenu
,
optVar
,
optVal
=
None
,
command
=
None
):
"""
Load the relevant list of values into an OptionMenu and set
selected value if required.
"""
params
=
{
'cfg'
:
None
,
'section'
:
None
,
'optList'
:
None
,
'optVar'
:
None
,
'optVal'
:
None
,
'command'
:
None
}
if
optMenu
==
self
.
optMenuHighlightTarget
:
params
[
'cfg'
]
=
idleConf
.
userCfg
[
'highlight'
]
# if
# params['section']=idleconf.userCfg['main'].GetDef('EditorWindow',
# 'theme')
#
# params['optVar']=self.HighlightTarget
# params['optList']=idleconf.defaultCfg['main'].options(params.Section)
# else: # a default theme
# pass
#params.optList=idleConf
#if not params.optVar.get(): #no value set yet (initial load)
# params.optVal=
#if params.section: #we're asking to load a list of option names
# optList=params.cfg
#elif optMenu == xx:
#else:
#if self.HighlightTarget.get(): #if there was a value set (reload)
# params.optVal=self.HighlightTarget.get()
#else: #no value set yet (initial load)
#if not params.optVar.get(): #no value set yet (initial load)
menu
=
optMenu
[
'menu'
]
print
menu
menu
.
delete
(
0
,
END
)
for
item
in
optList
:
menu
.
add_command
(
label
=
item
,
command
=
command
)
if
optVal
:
optVar
.
set
(
optVal
)
elif
optList
:
optVar
.
set
(
optList
[
0
])
def
SaveConfigs
(
self
):
pass
if
__name__
==
'__main__'
:
#test the dialog
root
=
Tk
()
...
...
Lib/idlelib/configHandler.py
0 → 100644
Dosyayı görüntüle @
c11ccf35
##---------------------------------------------------------------------------##
##
## idle - configuration data handler, based on and replacing IdleConfig.py
## elguavas
##
##---------------------------------------------------------------------------##
"""Provides access to configuration information"""
import
os
import
sys
from
ConfigParser
import
ConfigParser
,
NoOptionError
,
NoSectionError
class
IdleConfParser
(
ConfigParser
):
"""
A ConfigParser specialised for idle configuration file handling
"""
def
__init__
(
self
,
cfgFile
,
cfgDefaults
=
None
):
"""
cfgFile - string, fully specified configuration file name
"""
self
.
file
=
cfgFile
ConfigParser
.
__init__
(
self
,
defaults
=
cfgDefaults
)
def
GetInt
(
self
,
section
,
option
):
"""
Get an option value as an integer
"""
return
self
.
Get
(
section
,
option
,
type
=
'int'
)
def
GetBool
(
self
,
section
,
option
):
"""
Get an option value as a boolean
"""
return
self
.
Get
(
section
,
option
,
type
=
'bool'
)
def
Get
(
self
,
section
,
option
,
raw
=
0
,
vars
=
None
,
default
=
None
,
type
=
None
):
"""
Get an option value for given section/option or return default.
If type is specified, return as type.
"""
if
type
==
'bool'
:
getVal
=
self
.
getbool
elif
type
==
'int'
:
getVal
=
self
.
getint
else
:
getVal
=
self
.
get
if
self
.
has_option
(
section
,
option
):
return
getVal
(
section
,
option
,
raw
,
vars
)
else
:
return
default
def
GetSectionList
(
self
):
# only provided for consistency
return
self
.
sections
()
def
GetOptionList
(
self
,
section
):
"""
Get an option list for given section
"""
if
self
.
has_section
:
return
self
.
options
(
section
)
else
:
#return a default value
return
[]
def
GetHighlight
(
self
,
theme
,
element
):
fore
=
self
.
Get
(
theme
,
element
+
"-foreground"
)
back
=
self
.
Get
(
theme
,
element
+
"-background"
)
style
=
self
.
Ge
(
theme
,
element
+
"-fontStyle"
,
default
=
''
)
return
{
"fg"
:
fore
,
"bg"
:
back
,
"fStyle"
:
style
}
def
Load
(
self
):
"""
Load the configuration file from disk
"""
self
.
read
(
self
.
file
)
class
IdleUserConfParser
(
IdleConfParser
):
"""
IdleConfigParser specialised for user configuration handling
"""
def
Save
(
self
):
"""
write loaded user configuration file back to disk
"""
# this is a user config, it can be written to disk
self
.
write
()
class
IdleConf
:
"""
holds config parsers for all idle config files:
default config files
(idle install dir)/config-main.def
(idle install dir)/config-extensions.def
(idle install dir)/config-highlight.def
(idle install dir)/config-keys.def
user config files
(user home dir)/.idlerc/idle-main.cfg
(user home dir)/.idlerc/idle-extensions.cfg
(user home dir)/.idlerc/idle-highlight.cfg
(user home dir)/.idlerc/idle-keys.cfg
"""
def
__init__
(
self
):
self
.
defaultCfg
=
{}
self
.
userCfg
=
{}
self
.
cfg
=
{}
self
.
CreateConfigHandlers
()
self
.
LoadCfgFiles
()
#self.LoadCfg()
def
CreateConfigHandlers
(
self
):
"""
set up a dictionary config parsers for default and user
configurations respectively
"""
#build idle install path
if
__name__
!=
'__main__'
:
# we were imported
idledir
=
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
)
configTypes
=
(
'main'
,
'extensions'
,
'highlight'
,
'keys'
)
defCfgFiles
=
{}
usrCfgFiles
=
{}
for
cfgType
in
configTypes
:
#build config file names
defCfgFiles
[
cfgType
]
=
os
.
path
.
join
(
idledir
,
'config-'
+
cfgType
+
'.def'
)
usrCfgFiles
[
cfgType
]
=
os
.
path
.
join
(
userdir
,
'idle-'
+
cfgType
+
'.cfg'
)
for
cfgType
in
configTypes
:
#create config parsers
self
.
defaultCfg
[
cfgType
]
=
IdleConfParser
(
defCfgFiles
[
cfgType
])
self
.
userCfg
[
cfgType
]
=
IdleUserConfParser
(
usrCfgFiles
[
cfgType
])
def
LoadCfgFiles
(
self
):
"""
load all configuration files.
"""
for
key
in
self
.
defaultCfg
.
keys
():
self
.
defaultCfg
[
key
]
.
Load
()
self
.
userCfg
[
key
]
.
Load
()
#same keys
def
SaveUserCfgFiles
(
self
):
"""
write all loaded user configuration files back to disk
"""
for
key
in
self
.
userCfg
.
keys
():
self
.
userCfg
[
key
]
.
Save
()
idleConf
=
IdleConf
()
### module test
if
__name__
==
'__main__'
:
def
dumpCfg
(
cfg
):
print
'
\n
'
,
cfg
,
'
\n
'
for
key
in
cfg
.
keys
():
sections
=
cfg
[
key
]
.
sections
()
print
key
print
sections
for
section
in
sections
:
options
=
cfg
[
key
]
.
options
(
section
)
print
section
print
options
for
option
in
options
:
print
option
,
'='
,
cfg
[
key
]
.
Get
(
section
,
option
)
dumpCfg
(
idleConf
.
defaultCfg
)
dumpCfg
(
idleConf
.
userCfg
)
print
idleConf
.
userCfg
[
'main'
]
.
Get
(
'Theme'
,
'name'
)
#print idleConf.userCfg['highlight'].GetDefHighlight('Foo','normal')
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