%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/orca/backends/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/orca/backends/__pycache__/json_backend.cpython-312.pyc

�

g
f	 ��X�dZdZdZdZdZdZddlmZmZddl	Z	dd	l
mZmZGd
�d�Z
y)zJSON backend for Orca settingsz$Id$z
$Revision$z$Date$z7Copyright (c) 2010-2011 Consorcio Fernando de los Rios.�LGPL�)�load�dumpN)�settings�acssc�h�eZdZd�Zd�Zd�Zd�Zd�Zd�Zdd�Z	dd	�Z
dd
�Zd�Zd�Z
dd
�Zd�Zd�Zy)�Backendc��i|_i|_i|_i|_tj
j
|d�|_tj
j
|d�|_dtjiid�i|_y)z& Initialize the JSON Backend.
        zuser-settings.confzapp-settings�default)�profile�pronunciations�keybindingsN)�generalr
r�profiles�os�path�join�settingsFile�appPrefsDirrr�_defaultProfiles)�self�prefsDirs  �</usr/lib/python3/dist-packages/orca/backends/json_backend.py�__init__zBackend.__init__$sq����� ��������
��G�G�L�L��3G�H����7�7�<�<��.�A���!*�(�:J�:J�LN�IK�-.�!"���c���||j||d�}||_|j|_||_||_t|jd�}t||d��|j�y)zN Save default settings for all the properties from
            orca.settings. )rrr
r�w���indentN)	rrrr
r�openrr�close)rrr
r�prefsrs      r�saveDefaultSettingszBackend.saveDefaultSettings4sm��$�!�2�2�#1� +�-��
����-�-��
�,���&����D�-�-�s�3���U�L��+����rc���tjj|j|�d��}tjj	|�r)t|d�}t
|�}|j�|Si}|S)N�.conf�r)rrrr�existsr!rr")r�appName�fileNamerr#s     r�getAppSettingszBackend.getAppSettingsEsh���7�7�<�<�� 0� 0�W�I�U�2C�D��
�7�7�>�>�(�#���#�.�L���&�E���� ����E��rc��|j|�}|jdi�}|||d�||<||d<tjj	|j
|�d��}t
|d�}	t||	d��|	j�y)Nr)rr
rr&rrr)	r+�getrrrrr!rr")
rr)rrr
rr#rr*rs
          r�saveAppSettingszBackend.saveAppSettingsPs����#�#�G�,���9�9�Z��,��(/�/=�,7�9����%��j���7�7�<�<�� 0� 0�W�I�U�2C�D���H�c�*���U�L��+����rc��|�d}||d<||d<t|jd�5}t|�}||d|<|jd�|j	�t||d�	�ddd�y#1swYyxYw)
zS Save minimal subset defined in the profile against current 
            defaults. Nrr
r�r+rrrr)r!rr�seek�truncater)rrrr
rrr#s       r�saveProfileSettingszBackend.saveProfileSettings]s����?��G�$2�� �!�!,��
��
�$�#�#�T�
*�	0�l���&�E�)0�E�*��g�&����a� ��!�!�#����Q�/�	0�	0�	0�s�AA1�1A:c���t|j�}	t|�}|dj	�|_|d|_|d|_|dj	�|_y#t$rYywxYw)z$ Load from config file all settings Nrr
rr)	r!rr�
ValueError�copyrr
rr)rrr#s   r�_getSettingszBackend._getSettingsns|���D�-�-�.��	���&�E��Y�'�,�,�.���#�$4�5��� ��/����j�)�.�.�0��
���	��	�s�A'�'	A3�2A3Nc��|j�|jj�}|jdddg�}|�|d}|j|j�}|j�D]D\}}|dk(r0|j�D]\}}t
j|�||<�|dvs�@|||<�F	|d|d<|S#t$r	||d<Y|SwxYw)	zZ Get general settings from default settings and
            override with profile values. �startingProfile�Defaultr��voices)r9�
activeProfilerr=)	r7rr6r-r�itemsr�ACSS�KeyError)	rr�generalSettings�defaultProfile�profileSettings�key�value�	voiceType�voiceDefs	         r�
getGeneralzBackend.getGeneralzs��	
�����,�,�+�+�-��(�,�,�->�.7��-C�E���?�$�Q�'�G��-�-��0�5�5�7��)�/�/�1�	-�J�C���h��+0�;�;�=�;�'�I�x�'+�y�y��':�E�)�$�;��>�>�',���$�	-�	>�/>�y�/I�O�O�,�����	>�/=�O�O�,���	>�s�;C�C�Cc��|j�|jj�}|j|j�}d|vr|d}|S)z` Get pronunciation settings from default settings and
            override with profile values. r
)r7r
r6r)rrr
rCs    r�getPronunciationszBackend.getPronunciations�sT��	
�����,�,�1�1�3���-�-��0�5�5�7����.�,�-=�>�N��rc��|j�|jj�}|j|j�}d|vr|d}|S)z^ Get keybindings settings from default settings and
            override with profile values. r)r7rr6r)rrrrCs    r�getKeybindingszBackend.getKeybindings�sS��	
�����&�&�+�+�-���-�-��0�5�5�7���O�+�)�-�8�K��rc�V�tjj|j�S)z  Check if we're in first start. )rrr(r)rs r�isFirstStartzBackend.isFirstStart�s ���7�7�>�>�$�"3�"3�4�4�4rc��||j|<t|jd�5}t|�}||d|<|j	d�|j�t
||d��ddd�y#1swYyxYw)Nr0rrrr)rr!rrr1r2r)rrDrErr#s     r�_setProfileKeyzBackend._setProfileKey�sv��!����S��
�$�#�#�T�
*�	0�l���&�E�$)�E�)��S�!����a� ��!�!�#����Q�/�	0�	0�	0�s�AA2�2A;c�F�||jd<|jd|�y)z�Set firstStart. This user-configurable setting is primarily
        intended to serve as an indication as to whether or not initial
        configuration is needed.�
firstStartN)rrP)rrEs  r�
setFirstStartzBackend.setFirstStart�s"��&+����\�"����L�%�0rc���|j�g}|jj�D]?}|j|j�}|j	|jd���A|S)z List available profiles. r)r7r�keysr6�appendr-)rr�profileName�profileDicts    r�availableProfileszBackend.availableProfiles�sb���������=�=�-�-�/�	8�K��-�-��4�9�9�;�K��O�O�K�O�O�I�6�7�	8��rc�B�����fd�}��jvr|�j�t�jd�5}t|�}�|dvr:||d�|j	d�|j�t
||d��ddd�y#1swYyxYw)zRemove an existing profilec���|�=t|�dk(r2�jD]"}�j|j�||<�$yy)Nr)�lenrr6)�dictrWrrs  ��r�removeProfileFromz0Backend.removeProfile.<locals>.removeProfileFrom�sO����W�
��4�y�A�~�#'�#8�#8�R�K�(,�(=�(=�k�(J�(O�(O�(Q�D��%�R�rr0rrrrN)rr!rrr1r2r)rrr^rr#s``   r�
removeProfilezBackend.removeProfile�s����	R��d�m�m�#��d�m�m�,�
�$�#�#�T�
*�	4�l���&�E��%�
�+�+�!�%�
�"3�4��!�!�!�$��%�%�'��U�L��3�
	4�	4�	4�s�A
B�B)N)r)F)�__name__�
__module__�__qualname__rr$r+r.r3r7rHrJrLrNrPrSrYr_�rrr	r	"sH��"� �"	��0�"
1��,��5�
0�1�	�4rr	)�__doc__�__id__�__version__�__date__�
__copyright__�__license__�jsonrrr�orcarrr	rcrr�<module>rls8��,%�������I�
����	��u4�u4r

Zerion Mini Shell 1.0