AlkantarClanX12

Your IP : 18.226.82.90


Current Path : /opt/alt/python35/lib64/python3.5/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/idlelib/__pycache__/configHandler.cpython-35.opt-2.pyc



���]�~�@skddlZddlZddlmZddlmZddlmZmZGdd�de	�Z
Gdd�de	�ZGd	d
�d
e	�ZGdd�de	�Z
Gd
d�de�ZGdd�de�ZGdd�d�Ze�ZedkrgddlmZddf\aadd�Zdd�Zeej�eej�edtdtdd�dS)�N)�ConfigParser)�	TkVersion)�Font�
nametofontc@seZdZdS)�InvalidConfigTypeN)�__name__�
__module__�__qualname__�r
r
�2/opt/alt/python35/lib64/python3.5/configHandler.pyrsrc@seZdZdS)�InvalidConfigSetN)rrr	r
r
r
rrsrc@seZdZdS)�InvalidFgBgN)rrr	r
r
r
rr
sr
c@seZdZdS)�InvalidThemeN)rrr	r
r
r
rrsrc@sLeZdZddd�Zddddd�Zdd�Zd	d
�ZdS)�IdleConfParserNcCs&||_tj|d|dd�dS)N�defaults�strictF)�filer�__init__)�self�cfgFileZcfgDefaultsr
r
rr%s	zIdleConfParser.__init__FcCsh|j||�s|S|dkr2|j||�S|dkrN|j||�S|j||d|�SdS)N�bool�int�raw)�
has_optionZ
getbooleanZgetint�get)r�section�option�type�defaultrr
r
r�Get,szIdleConfParser.GetcCs$|j|�r|j|�SgSdS)N)�has_section�options)rrr
r
r�
GetOptionList=s
zIdleConfParser.GetOptionListcCs|j|j�dS)N)�readr)rr
r
r�LoadDszIdleConfParser.Load)rrr	rrr"r$r
r
r
rr!src@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�IdleUserConfParsercCs |j|�s|j|�dS)N)r �add_section)rrr
r
r�
AddSectionMszIdleUserConfParser.AddSectioncCs7x0|j�D]"}|j|�s
|j|�q
WdS)N)�sectionsr"Zremove_section)rrr
r
r�RemoveEmptySectionsRsz&IdleUserConfParser.RemoveEmptySectionscCs|j�|j�S)N)r)r()rr
r
r�IsEmptyXs
zIdleUserConfParser.IsEmptycCs#|j|�r|j||�SdS)NF)r Z
remove_option)rrrr
r
r�RemoveOption]szIdleUserConfParser.RemoveOptioncCs|j||�rH|j||�|kr.dS|j|||�dSn3|j|�sd|j|�|j|||�dSdS)NFT)rr�setr r&)rrr�valuer
r
r�	SetOptionfs
zIdleUserConfParser.SetOptioncCs)tjj|j�r%tj|j�dS)N)�os�path�existsr�remove)rr
r
r�
RemoveFilewszIdleUserConfParser.RemoveFilecCs�|j�sw|j}yt|d�}Wn.tk
rXtj|�t|d�}YnX|�|j|�WdQRXn
|j�dS)N�w)r*r�open�OSErrorr/�unlink�writer3)rZfnamerr
r
r�Save|s	

zIdleUserConfParser.SaveN)
rrr	r'r)r*r+r.r3r9r
r
r
rr%Hs	r%c@sceZdZdd�Zdd�Zdd�Zdddd	d
d�Zdd
�Zdd�Zddd�Z	dd�Z
dd�Zdd�Zdd	d	dd�Z
dd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zdd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�ZdS)8�IdleConfcCs<d|_i|_i|_i|_|j�|j�dS)N�main�
extensions�	highlight�keys)r;r<r=r>)�config_types�
defaultCfg�userCfg�cfg�CreateConfigHandlers�LoadCfgFiles)rr
r
rr�s				
zIdleConf.__init__cCs�tdkr!tjjt�}ntjjtjd�}|j�}i}i}xS|jD]H}tjj	|d|d�||<tjj	|d|d�||<q\Wx?|jD]4}t
||�|j|<t||�|j
|<q�WdS)N�__main__rzconfig-z.defz.cfg)rr/r0�dirname�__file__�abspath�sys�
GetUserCfgDirr?�joinrr@r%rA)rZidleDir�userDirZdefCfgFilesZusrCfgFilesZcfgTyper
r
rrC�s		zIdleConf.CreateConfigHandlerscCsd}tjjd�}|dkrvtjj|�svd|d}yt|dtj�Wntk
roYnXd}|dkr�tj�}tjj	||�}tjj|�sytj
|�Wn9tk
rd|d}t|dtj�t�YnX|S)Nz.idlerc�~z.
 Warning: os.path.expanduser("~") points to
 z,
 but the path does not exist.rz2
 Warning: unable to create user config directory
z(
 Check path and permissions.
 Exiting!
)r/r0�
expanduserr1�printrI�stderrr6�getcwdrK�mkdir�
SystemExit)rZcfgDirrL�warnr
r
rrJ�s*

zIdleConf.GetUserCfgDirNTFc	!CsNy@|j|j||�r?|j|j||d|d|�SWnmtk
r�d||||j|j||d|�f}yt|dtj�Wntk
r�YnXYnXy@|j|j||�r�|j|j||d|d|�SWntk
rYnX|rJd|||f}yt|dtj�Wntk
rIYnX|S)Nrrzu
 Warning: configHandler.py - IdleConf.GetOption -
 invalid %r value for configuration option %r
 from section %r: %rrz�
 Warning: configHandler.py - IdleConf.GetOption -
 problem retrieving configuration option %r
 from section %r.
 returning default value: %r)	rArr�
ValueErrorrOrIrPr6r@)	r�
configTyperrrr�warn_on_defaultr�warningr
r
r�	GetOption�s4

	#




zIdleConf.GetOptioncCs|j|j|||�dS)N)rAr.)rrVrrr-r
r
rr.szIdleConf.SetOptioncCsi||jkrtd��|dkr7|j|}n(|dkrS|j|}ntd��|j�S)NzInvalid configType specified�userrzInvalid configSet specified)r?rrAr@rr()r�	configSetrV�	cfgParserr
r
r�GetSectionList	szIdleConf.GetSectionListcCs�|jdj|�r+|jd|�}n|jd|�}||d}|dkrd|d}n||d}d|d	|i}|s�|S|d
kr�|dS|dkr�|d	Std��dS)
Nr=rrZz-foregroundZcursorznormal-backgroundz-backgroundZ
foregroundZ
backgroundZfg�bgzInvalid fgBg specified)r@r �GetThemeDictr
)r�theme�elementZfgBgZ	themeDictZforeZbackr=r
r
r�GetHighlights	
zIdleConf.GetHighlightc6Csv|dkr|jd}n(|dkr8|jd}ntd��ddddd	dd
dddddd
dddddddddddddddddddddddddddddddddddd dd!dd"di}x�|D]{}|j||�sNd#||||f}yt|d$tj�Wntk
rMYnX|j||d||�||<q�W|S)%NrZr=rzInvalid theme type specifiedznormal-foregroundz#000000znormal-backgroundz#ffffffzkeyword-foregroundzkeyword-backgroundzbuiltin-foregroundzbuiltin-backgroundzcomment-foregroundzcomment-backgroundzstring-foregroundzstring-backgroundzdefinition-foregroundzdefinition-backgroundzhilite-foregroundzhilite-backgroundZgrayzbreak-foregroundzbreak-backgroundzhit-foregroundzhit-backgroundzerror-foregroundzerror-backgroundzcursor-foregroundzstdout-foregroundzstdout-backgroundzstderr-foregroundzstderr-backgroundzconsole-foregroundzconsole-backgroundz�
 Warning: configHandler.IdleConf.GetThemeDict -
 problem retrieving theme element %r
 from theme %r.
 returning default color: %rr)	rAr@rrrOrIrPr6r)rrZ	themeNamer\r`rarXr
r
rr_6sV

zIdleConf.GetThemeDictcCs�|jddddddd�}|rB|jddddd�}|rO|sV|rq|jddd	dd�}|r�|jn|j}|d
j|�r�|SdSdS)Nr;ZThemerrrTZname2��namer=zIDLE Classic)rYr@rAr )rrr`�sourcer
r
r�CurrentThemevszIdleConf.CurrentThemecCs|jddddd�S)Nr;ZKeysrdrrc)rY)rr
r
r�CurrentKeys�szIdleConf.CurrentKeysc	Cs|j|jdd��}|j|jdd��}x'|D]}||kr=|j|�q=W|rg}x�|D]�}|jd|ddddd�rs|s�|r�|r�d}nd	}|jd||ddddd
d�r�|j|�qs|j|�qsW|S|SdS)Nrr<rZ�enableTrrZ
enable_editorZenable_shellrWF)�RemoveKeyBindNamesr]�appendrY)	r�active_onlyZeditor_onlyZ
shell_onlyZextnsZ	userExtns�extn�activeExtnsrr
r
r�
GetExtensions�s.

			zIdleConf.GetExtensionscCsn|}g}x3|D]+}|jd�r|j|j|��qW|jdd�x|D]
}||=qYW|S)N�	_bindings�_cfgBindings�reverseT)rorp)�endswithrj�index�sort)rZextnNameList�namesZkbNameIndiciesrdrsr
r
rri�s

zIdleConf.RemoveKeyBindNamescCsad}d|d}xF|jdd�D]2}x)|j|�D]}||kr=|}q=Wq'W|S)Nz<<z>>rkr)rn�GetExtensionKeys)r�virtualEventZextNameZvEventrl�eventr
r
r�GetExtnNameForEvent�szIdleConf.GetExtnNameForEventc	Cs|d}|j�}i}|jdj|�r{|jdj|�}x0|D](}d|d}||}|||<qOW|S)Nrpr<z<<z>>)�GetCurrentKeySetr@r r")	r�
extensionName�keysNameZ
activeKeys�extKeys�
eventNames�	eventNamerx�bindingr
r
rrv�s


zIdleConf.GetExtensionKeyscCs�|d}i}|jdj|�r�|jdj|�}xG|D]?}|jd||dd�j�}d|d}|||<qCW|S)Nrpr<rrcz<<z>>)r@r r"rY�split)rr{r|r}r~rr�rxr
r
rZ__GetRawExtensionKeys�s

zIdleConf.__GetRawExtensionKeyscCs�|d}|j|�}|jdj|�r�|jdj|�}xG|D]?}|jd||dd�j�}d|d}|||<qLW|S)Nror<rrcz<<z>>)rvr@r r"rYr�)rr{Z	bindsNameZextBindsr~rr�rxr
r
r�GetExtensionBindings�s

zIdleConf.GetExtensionBindingscCs5|dd�}|jd||dd�j�}|S)N�r>rrc���)rYr�)r�
keySetNameZeventStrrr�r
r
r�
GetKeyBindings!zIdleConf.GetKeyBindingcCsn|j|j��}tjdkrjxC|j�D]5\}}dd�|D�}||kr1|||<q1W|S)N�darwincSs"g|]}|jdd��qS)z<Alt-z<Option-)�replace)�.0�xr
r
r�
<listcomp>"s	z-IdleConf.GetCurrentKeySet.<locals>.<listcomp>)�	GetKeySetrgrI�platform�items)r�result�k�vZv2r
r
rrzszIdleConf.GetCurrentKeySetcCs�|j|�}|jdd�}xb|D]Z}|j|�}|r(x<|D]4}|||j�krpd||<||||<qJWq(W|S)Nrk�rc)�GetCoreKeysrn�_IdleConf__GetRawExtensionKeys�values)rr�ZkeySetrmrlr}rxr
r
rr�(s


zIdleConf.GetKeySetcCsd|d|j�kS)Nz<<z>>)r�)rrwr
r
r�
IsCoreBinding:szIdleConf.IsCoreBindingcbCsTdddgdddgddd	gd
ddgd
dgddgddgddgddgddgddgddgddgddgdd gd!d"gd#d$gd%d&gd'd(gd)d*gd+d,gd-d.gd/d0gd1d2gd3d4gd5d6gd7d8gd9d:gd;d<gd=d>gd?d@dAgdBdCgdDdEgdFdGgdHdIgdJdKgdLdMgdNdOdPgdQdRgdSdTgdUdVgdWdXgdYdZgd[d\gd]d^gd_d`gdadbgdcddgdedfgi1}|rPxv|D]n}|j||�}|r	|||<q�dg||||f}yt|dhtj�Wq�tk
rKYq�Xq�W|S)iNz<<copy>>z<Control-c>z<Control-C>z<<cut>>z<Control-x>z<Control-X>z	<<paste>>z<Control-v>z<Control-V>z<<beginning-of-line>>z<Control-a>z<Home>z<<center-insert>>z<Control-l>z<<close-all-windows>>z<Control-q>z<<close-window>>z<Alt-F4>z<<do-nothing>>z<<end-of-file>>z<Control-d>z<<python-docs>>z<F1>z<<python-context-help>>z
<Shift-F1>z<<history-next>>z<Alt-n>z<<history-previous>>z<Alt-p>z<<interrupt-execution>>z<<view-restart>>z<F6>z<<restart-shell>>z<Control-F6>z<<open-class-browser>>z<Alt-c>z<<open-module>>z<Alt-m>z<<open-new-window>>z<Control-n>z<<open-window-from-file>>z<Control-o>z<<plain-newline-and-indent>>z<Control-j>z<<print-window>>z<Control-p>z<<redo>>z<Control-y>z<<remove-selection>>z<Escape>z<<save-copy-of-window-as-file>>z
<Alt-Shift-S>z<<save-window-as-file>>z<Alt-s>z<<save-window>>z<Control-s>z<<select-all>>z<Alt-a>z<<toggle-auto-coloring>>z<Control-slash>z<<undo>>z<Control-z>z<<find-again>>z<Control-g>z<F3>z<<find-in-files>>z<Alt-F3>z<<find-selection>>z<Control-F3>z<<find>>z<Control-f>z<<replace>>z<Control-h>z
<<goto-line>>z<Alt-g>z<<smart-backspace>>z<Key-BackSpace>z<<newline-and-indent>>z<Key-Return>z<Key-KP_Enter>z<<smart-indent>>z	<Key-Tab>z<<indent-region>>z<Control-Key-bracketright>z<<dedent-region>>z<Control-Key-bracketleft>z<<comment-region>>z<Alt-Key-3>z<<uncomment-region>>z<Alt-Key-4>z<<tabify-region>>z<Alt-Key-5>z<<untabify-region>>z<Alt-Key-6>z<<toggle-tabs>>z<Alt-Key-t>z<<change-indentwidth>>z<Alt-Key-u>z<<del-word-left>>z<Control-Key-BackSpace>z<<del-word-right>>z<Control-Key-Delete>z�
 Warning: configHandler.py - IdleConf.GetCoreKeys -
 problem retrieving key binding for event %r
 from key set %r.
 returning default value: %rr)r�rOrIrPr6)rr�ZkeyBindingsrxr�rXr
r
rr�Esz
																																										


	zIdleConf.GetCoreKeysc	Csg}|dkr"|jd}n(|dkr>|jd}ntd��|jd�}x�|D]�}|jd|dd�}|jd�d
kr�d}d}n/|jd�}|d	j�}|dj�}|r`|r`|j|||f�q`W|j	d
dd��|S)NrZr;rzInvalid configSet specifiedZ	HelpFiles�;r�rcr�keycSs|dS)Nr�r
)r�r
r
r�<lambda>�sz1IdleConf.GetExtraHelpSourceList.<locals>.<lambda>���)
rAr@rr"r�findr��striprjrt)	rr[ZhelpSourcesr\r!rr-ZmenuItemZhelpPathr
r
r�GetExtraHelpSourceList�s&

	zIdleConf.GetExtraHelpSourceListcCs |jd�|jd�}|S)NrrZ)r�)rZallHelpSourcesr
r
r�GetAllExtraHelpSourcesList�sz#IdleConf.GetAllExtraHelpSourcesListc	Cs�|j||ddd�}|j||ddddd�}|j||ddd	dd
�}|dkr�tdkr~d
}n`tddddd|�}tj|�}|d}|d}|d	kr�d}|ddk}|||r�dndfS)NZfontrZcourierz	font-sizerrZ10z	font-boldrrZTkFixedFontg!@ZCourierrdr1T�root�family�size�
Zweight�boldZnormal)rYrr�actual)	rr�rVrr�r�r��fZ
actualFontr
r
r�GetFont�s 			

zIdleConf.GetFontcCs:x3|jD](}|j|j�|j|j�q
WdS)N)r@r$rA)rr�r
r
rrD�szIdleConf.LoadCfgFilescCs)x"|jD]}|j|j�q
WdS)N)rAr9)rr�r
r
r�SaveUserCfgFiles�szIdleConf.SaveUserCfgFiles)rrr	rrCrJrYr.r]rbr_rfrgrnriryrvr�r�r�rzr�r�r�r�r�r�rDr�r
r
r
rr:�s6	-@#

M 	r:rE)�crc32cCs?t|�}td7at|jdd�t�at|�dS)Nr��encodingzutf-8)�str�liner��encode�crcrO)�objZtxtr
r
r�sprint�s
r�cCs�td|d�x�t|j��D]�}||j�}t|�t|�xh|D]`}||j|�}t|�t|�x0|D](}t|d||j||��q�WqTWq#WdS)N�
z = )rO�sortedr>r(r�r!r)rBr�r(rr!rr
r
r�dumpCfg�s





r�z	
lines = z, crc = �seprc)r/rI�configparserr�tkinterrZtkinter.fontrr�	Exceptionrrr
rrr%r:ZidleConfr�zlibr�r�r�r�r�r@rArOr
r
r
r�<module>s,'G��W