__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
�

p��O�W���SSKJr SSKJr SSKrSSKJrJr SSKr"SS\5r"SS\5r	"S	S
\5r
"SS\5r"S
S\5r
g)�)�print_function)�unicode_literalsN)�stdout�stderrc��\rSrSrSrSrg)�IdentifierException�z#Raise if no identifier can be found�N��__name__�
__module__�__qualname__�__firstlineno__�__doc__�__static_attributes__r
��1/usr/lib/python3/dist-packages/xkit/xorgparser.pyrrs��-�rrc��\rSrSrSrSrg)�OptionException�z&Raise when an option is not available.r
Nrr
rrrr���0�rrc��\rSrSrSrSrg)�SectionException�"z&Raise when a section is not available.r
Nrr
rrrr"rrrc��\rSrSrSrSrg)�ParseException�&z&Raise when a postion is not available.r
Nrr
rrrr&rrrc��\rSrSrSrS1SjrSrSr\"\\5r	Sr
SrS	rS
r
SrSrS1S
jrSrS2SjrS3SjrS3SjrS1SjrS4SjrS1SjrS1SjrS1SjrS1SjrS1SjrS4SjrS1SjrS1SjrSrS4Sjr S3Sjr!S4Sjr"S r#S!r$S"r%S#r&S1S$jr'S%r(S&r)S'r*S(r+S)r,S*r-S4S+jr.S,r/S3S-jr0S1S.jr1S/r2S0r3g)5�Parser�*zVOnly low-level methods here.

See the xutils.XUtils subclass for higher-level methods.Nc���SUlSUlXlSSSSSSS	S
SSS
SSSURUR4UlURSSUl/SQUl/SQUl0RUR
5Ul/Ul	0RURS5Ul
URHn0URU'M UR5 g)asource = can be an object or a file. If set to None (default)
         Parser will start from scratch with an empty
         configuration.

Public:

comments = name of the section which stores the commented lines
           located outside of the sections in the xorg.conf.

globaldict = a global dictionary containing all the sections and
             options. For further information on globaldict, have a
             look at __check_sanity() and at get_value().

globaldict['Comments'] = stores the commented lines located inside of
                         the sections in the xorg.conf.

require_id = a list of the sections which require to have an
            "Identifier" set in the xorg.conf (e.g. Device sections).

identifiers = a dictionary of the sections which require identifiers.

sections = a tuple containing the names of all the sections in
           globaldict. Their names are not guaranteed to be all legal
           in xorg.conf (see "valid_sections").

valid_sections = a tuple containing the names of all the sections
                 which __check_sanity() will look for in the
                 xorg.conf. Sections with other names will be ignored
                 by self._check_sanity().

references = a list containing the names of all the possible
             references.�
SubSection�Comments�InputDevice�Device�Module�Monitor�Screen�ServerLayout�ServerFlags�
Extensions�Files�
InputClass�DRI�VideoAdaptor�Vendor�ModesN���)r-r$r%r'r(r))r%r$r'r(r)�
subsection�commentsection�source�sections�valid_sections�
require_id�
references�fromkeys�identifiers�comments�_gdict�
_check_sanity)�selfr5�elems   r�__init__�Parser.__init__.s���D'���(�����&�!�!�"�!�'�&�%� �%��'�!� �����,�,�.��
�"#�m�m�C�R�0����������;�;�t���7�����
��k�k�$�-�-��3����K�K�D� "�D�K�K��� �	
���rc��UR$�N�r=)r?s r�_get_global�Parser._get_global~s���{�{�rc��XlgrDrE)r?�global_dicts  r�_set_global�Parser._set_global�s��!�rc���URnUS:Xa/nON[US5(d-[US5nUR5nUR	5 OUR5n0RURS5nSnSnSnSnSn	Sn
SnUGHcnUR5RS5(Ga�US:XaURRU5 GOXHn
US:Xa�URURRU05 URURUnURU
05 X�RS	S5 X�RS
U
5 X�RSS5 X�RS/5 X�SRUR55 O�X@RnURURRUR05 URURURnURU05 X�RS	W5 X�RS
U
5 X�RSU5 X�RS/5 X�SRUR55 AGOLUR5R5RS5(a�SnUR H@nUR5R#S
UR5-S
-5S:wdM<SnUn O U(dSU-n[%U5eUS:Xa
U	S-
n	WnSnSnGO�Sn[%U5eUR5R5RS5S:Xa0U	S-
n	US:XaUS:XaXH==S-
ss'SnSnGO=Sn[%U5eUR5R5RS5S:Xa�U
S-
n
US:Xa�US:Xa�SnX�R#S
5S-UR'S
5R5nURRUR05 X@Rn0URURU'URURUnX�S'XHUS
'UUS	'/US'AGO4Sn[%U5eUR5R5RS5S:Xa1U
S-
n
US:XaSnX@R==S-
ss'O�Sn[%U5eUS:wa�UR5S:wa�US:XaCURURWSRSUR5-S-5 ObURRU05 XHnURURU/5RSUR5-S-5 US-
nGMf U(d@U	S-S:wd	U
S-S:wa
Sn[%U5eUR+5 UR-5 gUR+5 g![(a ASn[%U5ef=f)a�Perform a sanity check of the file and fill self.globaldict with
all the sections and subsections in the xorg.conf


empty = is the file empty? If yes, then don't check if:
    * the last section is not complete
    * there are duplicates

has_section:
    * == True: a section is already open
    * == False: a section is closed and/or a new section can be opened
    
has_subsection:
    * == True: a subsection is already open
    * == False: a section is closed and/or a new section can be opened
    
section_flag:
    * == '':a section is closed and/or a new section can be opened
    * == the name the current section

section_tags = counter of the number of Section and EndSection strings

subsection_tags = counter of the number of SubSection and EndSubSection
                 strings

lines_list = the list of the lines in the source object.

global_iters = counts how many times each kind of section
                     (section_flag) is found in the xorg.confN�write�rrTF��#�
identifier�position�section�options�"r2z;The name in the following line is invalid for a section:
%s�z,Sections cannot be nested in other sections.�
endsectionz$An EndSection is in the wrong place.r3z7SubSections can be nested only in well formed sections.�
endsubsectionz=SubSections can be closed only after being previously opened.�	�
�zThe last section is incomplete.)r5�hasattr�open�	readlines�closer:r6�strip�
startswithr<�appendr=r4�
setdefaultr3�lowerr7�findr�rfind�KeyError�_fill_identifiers�
_check_syntax)r?�file�
lines_list�myfile�global_iters�empty�has_section�has_subsection�section_flag�section_tags�subsection_tags�it�line�section_pos�	temp_dict�	curlength�
subsection_id�test_line_found�sectrS�errors                     rr>�Parser._check_sanity�s	��B�{�{���4�<��J��4��)�)��d�C���#�-�-�/�
�����!�^�^�-�
��{�{�4�=�=�!�4��������������
���D��z�z�|�&�&�s�+�+��%�'��M�M�(�(��.�".�"<�K�%��.����D�$7�$7�8�C�C�L�RT�U�$(�K�K��0C�0C�$D�\�$R�	�!�,�,�[�"�=�!�.�9�9�,��M�!�.�9�9�*�k�R�!�.�9�9�)�T�J�!�.�9�9�)�R�H�!�.�y�9�@�@�����N�$0���$A�	����D�$7�$7�8�C�C�D�O�O�UW�X�$(�K�K��0C�0C�$D�T�_�_�$U�	�!�,�,�Y��;�!�,�7�7��m�T�!�,�7�7�
�K�P�!�,�7�7�	�<�P�!�,�7�7�	�2�F�!�,�Y�7�>�>�t�z�z�|�L�!�
����#�#�%�0�0��;�;�"'�� �/�/�D��z�z�|�(�(��t�z�z�|�);�c�)A�B�b�H�*.��"&���	0�
'�,�/3�5�E�(��/�/�"�e�+�$��)��'.�� %��&*�� N��,�U�3�3�����#�#�%�0�0��>�$�F���!���$�&�>�U�+B� �.�!�3�.�#%�L�"'�K�B�E�(��/�/�����#�#�%�0�0��>�$�F��1�$���$�&�>�U�+B�%)�N�$(���3��!�);�)-���C��%:�:?�%�'�"��K�K�*�*�4�?�?�B�?� ,�_�_� =�I�>@�D�K�K����0��;�!%���D�O�O� <�Y� G�I�+7�i�(�4�0<�0J�	�*�-�/<�I�l�+�+-�I�i�(�!�)�E�(��/�/�����#�#�%�0�0��A�T�I��1�$��!�T�)�%*�N� ���1�Q�6�1�2�E�(��/�/��2�%��z�z�|�r�)�)�T�1�!�K�K����8��C�!*�,�,2�F�4�$�*�*�,�3F��3M�,N� �K�K�2�2�<��D�(4�(B�I� �K�K��5�@�@��(*�,�,2�F�4�$�*�*�,�3F��3M�,N��!�G�B�M�P��a��1�$��!�(;�q�(@�9��$�U�+�+�
�"�"�$�
��� �
�"�"�$��}$�4�%�"4��,�U�3�3�	4�s�&Y�Y)c�l�[UR55S:�a'S[UR55-n[U5eUR	5 UR5nSnUHnU[X$5-
nM US:�aS[U5-n[U5eURHBn[URU5[URU5:wdM7Sn[U5e [URS5S:�aGURSH4nURSUS/S9n[US5S:XdM)Sn[U5e UR5n[U5S:�aB[U5S	:�a
S
n[U5eURSUSS9(d
Sn[U5eg
g
)zmThis method contains the several checks which can guarantee
compliance with the syntax rules of the xorg.confrz&There cannot be Duplicate Sections:
%sz%There cannot be Broken References:
%szDNot all the sections which require an identifier have an identifier.r)r()�reflistzNThe ServerLayout section must have at least 1 reference to a "Screen" section.rVzRNo more than one default ServerLayout can be specified in the ServerFlags section.�rR�(The default ServerLayout does not exist.N)�len�get_duplicate_sections�strr�_validate_options�get_broken_referencesr8r=r;�get_references�get_default_serverlayout�
is_section)r?r|�brokenrtrS�screen_references�default_layouts       rri�Parser._check_syntax]s���>�t�*�*�,�-��1�>��D�7�7�9�:�<�E� ��'�'�
	
��� �&�+�+�-��
���G��#�f�o�&�&�B��
��6�<��F��L�E� ��'�'����G��4�;�;�w�'�(�C��0@�0@��0I�,J�J�/��$�U�+�+�	'��t�{�{�>�*�+�a�/��;�;�~�6��$(�$7�$7��8?�AI�
�%8�%L�!��(��2�3�q�8�H�E�(��/�/�7��6�6�8���~���"��>�"�Q�&�A��$�U�+�+��?�?�>�N�1�<M�?�N�B��$�U�+�+�O�
#rc��URHyn/URU'SnURUHRnURUSU5nURS5 USnURURXB45 US-
nMT M{ g![[
4a SX4-n[
U5ef=f![a N^f=f)a;Fill self.identifiers

self.identifiers has the section types as keys and a list of tuples
as values. The tuples contain the identifier and the position of
each section.

Here's a basic scheme:

self.identifiers = {section_type1: [
                                (identifier1, position1),
                                (identifier2, position2)
                              ], etc.
                   }

Concrete example:

self.identifiers = {'Device': [
                                ('Configured Video Device', 0),
                                ('Another Video Device', 1)
                              ],
                    'Screen': [
                                ('Configured Screen Device', 0),
                                ('Another Screen Device', 1)
                              ],
                   } r�
Identifierz8No Identifier for section %s, position %d, can be found.rOrVN)	r8r;r=�	get_valuerrrrb�AttributeError)r?r{rtr@rQr|s      rrh�Parser._fill_identifiers�s���6�O�O�D�%'�D���T�"��B����D�)��0�!%����l�B�!G�J���%�%�b�)�!+�A��J�� � ��&�-�-�z�.>�?��a���*�$��(�)9�:�0�-�04�|�<�E�(��/�/�	0��&����s�B�B0�"B-�0
B=�<B=c�|�SS/nS/nURGH$nX1;dMURUGHnX0R:XaURUUSnOURUUnUH�nUR5nUR	S5S:waUSUR	S5nSUR5-nURUS	S
9n[
U5S:Xa0USR5R5U;a[U5eUSSR5(aM�[U5e GM GM' g)
z�One word entries are not acceptable as either options or references

If a one word entry is found, ParseException will be raised.r,r#�endmoderTrPr2rz#The following option is invalid: %sT)�include_nullrVN)
r6r=r3r`re�_clean_duplicatesr�rdr�isalpha)	r?�sections_whitelist�options_whitelistrSrRrT�optionr|�optbitss	         rr��Parser._validate_options�s<��&�z�2��&�K���}�}�G��0� $���G� 4�H��/�/�1�"&�+�+�g�"6�x�"@��"K��"&�+�+�g�"6�x�"@��#*��!'�����!�;�;�s�+�r�1�%+�A�v�{�{�3�/?�%@�F�!F�$*�L�L�N�"4��#'�"8�"8��FJ�#9�#L�� ��L�A�-�#�A�J�,�,�.�4�4�6�,�-�"0��"7�7�&�q�z�!�}�4�4�6�6�"0��"7�7�##*�!5�%rc��/SQn/n/nUS:XaURUUSnOURUUnUH�nUR5nURS5S:waUSURS5nURU5nUSR	5U;aURUS5 M{USR	5S:Xa3[
U5S:�a"USS	:waURUS5 M�M�M�M� 0n	UH/nU	RU5S	:waURU5 M+XyU'M1 U$![[4a GMf=f)
z�See if there are duplicate options in a section

It is ok to have duplicated references e.g. several Load options, or
Screen, etc. though)�driver�busidrQr"rTrPr2rr�rVN)
r=r`rer�rdrbr�r��
IndexError�get)
r?rSrR�	blacklist�total�
duplicatesrTr�r��finals
          r�get_duplicate_options�Parser.get_duplicate_optionssc��6�	����
��l�"��k�k�'�*�8�4�Y�?�G��k�k�'�*�8�4�G��F��\�\�^�F��{�{�3��2�%���6�;�;�s�#3�4���,�,�V�4�G�
��1�:�#�#�%��2��L�L����,��Q�Z�%�%�'�8�3��7�|�a�'�G�A�J�$�,>�����W�Q�Z�0�-?�'�4��0���F��y�y�� �D�(��!�!�&�)� &�f�
�	�
���#�J�/�
��
�s�+D;�4AD;�;E�Ec���0nURH]nURUHGnURX#5n[U5S:�dM%URU05RUU5 MI M_ U$)z5Look for and return duplicate options in all sectionsr)r=r�r�rc)r?r�rSr@�duplopts     r�check_duplicate_options�Parser.check_duplicate_optionsMso���
��{�{�G����G�,���4�4�W�C���w�<�!�#��)�)�'�2�6�A�A�$�BI�K�-�#��rc���/nSnSnSnURS5nUS:�a�UH�nUR5(dUS:XaUS-
nO5XH-
nO0US-S:waXH-
nO"[U5S:�aURU5 SnU[U5S-
:XaUS:waURU5 US-
nM� O�UH�nUR5(dXH-
nO"[U5S:�aURU5 SnU[U5S-
:Xa2US:waURU5 OU(aSnURU5 US-
nM� U(a([U5US-S-:waSnURU5 U$)z�Clean the option and return all its components in a list

include_null - is used only by _validate_options() and makes
sure that options with a null value assigned in quotation
marks are not considered as one-word optionsrOrrUrVr[)�count�isspacer�rb)	r?r�r�r��optbitrt�	quotation�optcount�is	         rr��Parser._clean_duplicatesZsd������
���	��<�<��$���a�<����y�y�{�{��C�x�!�Q��	����!�1�}��)�����v�;��?�#�N�N�6�2�%'�F���V��q��(���|����v�.��a���-�0���y�y�{�{��K�F��6�{�Q�����v�.�!#����V��q��(���|����v�.�(�%'�F�#�N�N�6�2��a���%�(�C��L�H�Q�J��M�9��F��N�N�6�"��rc�*�0nURH�n/nURUHnURUS5 M UHKnURU5S:�dMURU05RUURU55 MM M� U$)zhReturn a dictionary with the duplicate sections i.e. sections
of the same kind, with the same identifierrrV)r;rbr�rc)r?r�rS�tempr{r@s      rr��Parser.get_duplicate_sections�s����
��'�'�G��D��(�(��1�����D��G�$�2����:�:�d�#�a�'��)�)�'�2�6�A�A�$�7;�z�z�$�7G�I��	(��rc���S/nUS:waRURURU5S:Xa[eU(aURXUUS9 O"URXUS9 OURX5 US:Xa|US:XaSU-S-U-[	U5-U-S-n	O�UR5R
5U;aSU-S-U-[	U5-U-S-n	OASU-S-[	U5-S-n	O)SU-S-S-U-S-S-U-[	U5-U-S-n	[URU5S:XaY0URU'/URUS'XR;a)S	U-S
-n
URUSRU
5 US:Xa8URUH$nURUURU	5 M& gURUURU	5 g)anAdd an option to a section

section= the section which will have the option added
option= the option to add
value= the value which will be assigned to the option
position= e.g. 0 (i.e. the first element in the list of Screen
              sections)
option_type= if set to "Option" it will cause the option to look like
            the following:
            Option "NameOfTheOption" "Value"
            
            Otherwise it will look like the following:
            NameOfTheOption "Value"
position= e.g. 0 (i.e. the first element in the list of Screen
              sections)
reference= used only in a particular case of reference (see
           add_reference)

prefix= usually quotation marks are used for the values (e.g. "True")
        however sometimes they don't have to be used
        (e.g. DefaultDepth 24) and prefix should be set to '' instead
        of '"'  �deviceN��valuerRr�rYrZrUrz	Identifier	"Default z"
)
r=r�r�
remove_optionr�r`rdr�r8rb)r?rSr�r��option_typerR�	reference�prefix�refSections�toaddrQr@s            r�
add_option�Parser.add_option�s��0 �j���t���{�{�7�#�'�'��1�T�9�&�&���"�"�7�%�+3�#�5��"�"�7�X�"�F�
���w�/��$���D� �����-��6��U��C�f�L�� ���=�=�?�(�(�*�+�=�!�F�]�T�1�F�:�S��Z�G�%�&�(,�-�E�
!�6�M�D�0�3�u�:�=��D�E��K�'�$�.��4�v�=��C�d�J��� #�E�
�+�-3�4�6:�;�E��t�{�{�7�#�$��)�#%�D�K�K�� �&(�D�K�K�� ��#��/�/�)�6��@�5�H�
����G�$�Q�'�.�.�z�:��t�����G�,�����G�$�T�*�1�1�%�8�-�
�K�K�� ��*�1�1�%�8rc��0n[URU5S:wGa<US:XGaURUGHnSnURUUH�n	US:wa�U	R5RUR55S:waRU	R5RUR55S:wa!UR	U/5RU5 ORU	R5RUR55S:wa!UR	U/5RU5 US-
nM� GM U$URUR
U5S:XagSnURUUH�n	US:wa�U	R5RUR55S:waRU	R5RUR55S:wa!UR	U/5RU5 ORU	R5RUR55S:wa!UR	U/5RU5 US-
nM� U$)z=Private method shared by remove_option and comment_out_optionrNr2rV)r�r=rdrercrbr�)
r?rSr�r�rRr��	to_remover@rtrus
          r�_get_options_to_blacklist� Parser._get_options_to_blacklist�s����	��t�{�{�7�#�$��)��4�� �K�K��0�D��B� $���G� 4�T� :�� �D�=�!%�
�
�� 1� 1�&�,�,�.� A�R� G� $�
�
�� 1� 1�%�+�+�-� @�B� F� )� 4� 4�T�2� >� E� E�b� I��#�z�z�|�0�0�����@�B�F� )� 4� 4�T�2� >� E� E�b� I��a���!;�1�H��-�;�;�w�'�+�+�H�5��=���B� $���G� 4�X� >�� �D�=�!%�
�
�� 1� 1�&�,�,�.� A�R� G� $�
�
�� 1� 1�%�+�+�-� @�B� F� )� 4� 4�X�r� B� I� I�"� M�� $�z�z�|�0�0�����@�B�F� )� 4� 4�X�r� B� I� I�"� M��a���!?� �rc��URXUXE5nUH,nSnXgHn	X�-
n
URUUU
	US-
nM! M. g)aRemove an option from a section.

section= the section which will have the option removed
option= the option to remove
value= if you want to remove an option only if it has a certain value
position= e.g. 0 (i.e. the first element in the list of Screen
              sections)rrVN)r�r=)r?rSr�r�rRr�r��part�moddedru�realposs           rr��Parser.remove_option&s]���2�2�7�E�2:�G�	��D��F�!����-���K�K��(��.�w�7��!���(�rc�$�[URU5nXR;a�US:wa�SnSnURUHpnURXU5(dMURUUU5R	5R5UR	5R5:XaSn OMr U(aB/URUU'URXUUS9 URURX#45 U$[SU-5e/URUU'U$![ac URXU5HHnUR	5R5UR	5R5:XdMCSn GMG GMMf=f)a�Create a new section and return the position of the section

The position is relative to the list of sections of the same type
(e.g. "Screen") so as to make it available in case the user wants
to add some options to it.

The identifier and the position of the new section is added to 
self.identifiers[section]

section= the section to create
identifier= the identifier of a section (if the section requires
            an identifier)Nr�TFr�z!%s Section requires an identifier)r�r=r8r�r`rdr�r�r;rbr)r?rSrQrRr��create�subr@s        r�make_section�Parser.make_section9s�������G�,�-���o�o�%��T�!�%�����;�;�w�/�C��~�~�g�s�;�;�
*� $���w�.4�.1�!3�38�5�7�5�5�7�1;�1A�1A�1C�1I�1I�1K�!L�*/�� %�!L�0�"�57�D�K�K��(��2��O�O�G�:�-5�$�7��$�$�W�-�4�4�j�5K�L���	*�+N�-4�,6�8�8�.0�D�K�K�� ��*����1 .�*�(,���w��(L��$(�J�J�L�$6�$6�$8�'1�'7�'7�'9�'?�'?�'A�%B�-2�F�$)�)M�*�s �AD"�"AF�F�F�Fc���0nU(a%URX5nURUS5 OdUS:wa'URXS9(aURUS5 O7[	UR
UR
55n0RU5nXR;agSnURUHRn[	UR
55RUS5n	Xt[	UR
55U	'US-
nMT [	UR
55n
U
R5 SnU
H~nURX5n
U
HnUR
URU	M  UR!X5 UR
UU	XLnUS:wdMeX�-
nURUU	US-
nM� g![a GN3f=f![a N�f=f![a M�f=f)z/Remove Sections by identifier, position or typeNr�rrV)�get_positionrcrr��listr=�keysr:r8r;�index�
ValueError�sort�get_subsectionsr3rg�_remove_comment_entries)r?rSrQrRr��pos�allkeysrtr��ref�
sorted_remover�r{�subsectionsr��identrefr�s                 r�remove_section�Parser.remove_sectionrs���
�	��
��'�'��<���$�$�S�$�/�
��
����w��:��$�$�X�t�4���4�;�;�w�/�4�4�6�7�G����G�,�I��o�o�%��B�!�-�-�g�6�	���y�~�~�/�0�6�6�y��|�D�C�=?�d�9�>�>�#3�4�S�9�:��a���
7��Y�^�^�-�.�
�������!�D��.�.�w�=�K�#������D�O�O�4�S�9�#�
�(�(��7����G�$�T�*�!��H��4��"�+���$�$�W�-�g�6��!���1"��='�
��
��,"����� ����s6�#F9�7A	G
�G�9
G�G�

G�G�
G(�'G(c�(�URXUUSS9 g)a�Add a reference to a section from another section.

For example:
to put a reference to the Screen section named "Default Screen"
in the ServerLayout section you should do:

section='ServerLayout'
reference='Screen'
identifier='Default Screen'
position=0 #the first ServerLayout section

NOTE: if position is set to None it will add such reference to any
instance of the section (e.g. to any ServerLayout section)T�r�rRr�N)r��r?rSr�rQrRs     r�
add_reference�Parser.add_reference�s��	
����*�!)�T�	�	;rc�(�URXUUSS9 g)a�Remove a reference to a section from another section.

For example:
to remove a reference to Screen "Default Screen" from the
ServerLayout section you should do:

section='ServerLayout'
reference='Screen'
identifier='Default Screen'
position=0 #the first ServerLayout section

NOTE: if position is set to None it will remove such reference from
any instance of the section (e.g. from any ServerLayout section)Tr�N)r�r�s     r�remove_reference�Parser.remove_reference�s ��	
���7�Z�$,��	�	>rc��US:Xa
URnOURS5 US	Un0RU5nUH�n/XV'0nURXUSS9nU(dM$URS5 US	UH;n	U	RS5 U	S	U	Hn
U	(dMURU
5 M M= [UR55HnXVRU5 M M� U$![a /nN�f=f![a U	(aURU	5 M�M�f=f![a U(aURU5 N�f=f)aGet references to other sections which are located in a section.

section= the section (e.g. "Screen")
position= e.g. 0 stands for the 1st Screen section
reflist= a list of references which this function should look for.
         The default list of references is self.require_id but this
         list can be overridden by the reflist argument so that, for
         example, if reflist is set to ['Device'], this function will
         look for references to other devices only (references to,
         say, screens, will be ignored).NrOr2T�r�)	r8rbr:r�rrcr�r�r�)r?rSrRrrTr9r��reference_dictr�r@�extrefr�s            rr��Parser.get_references�s\���d�?��o�o�G�

�N�N�2������G��[�[��)�
��F�!#�J���N�
��n�n�W�h�$�n�O���s�7��J�J�r�N��B�� #��@� �K�K��O� $�R��*.��#'�4�$2�$=�$=�f�$E�+/�	!$�"&�n�&9�&9�&;�!<�I��&�-�-�i�8�"=�3�6���-#�
���
�� .�@�#� .� 9� 9�$� ?� $�@��&�7��&�1�1�#�6��7�sN�C0�"D.�<D�D�3D.�0C?�>C?�"D+�$D.�*D+�+D.�."E�Ec�H�[URUR5nUS:XGaURUH�nSnURURH�nURURURS5U:XdM4URURURS5U:XdMeURURURS5U:XdM�SnM� U(dM�0=o�RURU'XS'X(S'/US'XXS'AUS-
nM� gSnURURH�nURURURS5U:XdM4URURURS5U:XdMeURURURS5U:XdM�SnM� U(a00=o�RURU'XS'X(S'/US'X8S'Agg)	a�Create a new subsection inside of a section.

section= the section to which the subsection will belong
identifier= the name of the subsection
position= the position of the section in the dictionary with the
          sections (e.g. the 1st "Screen" section would be 0).
          If set to None, it will create a new subsection in all
          the instances of the said section (e.g. in all the
          "Screen" sections)NTrSrQrRFrTrV)r�r=r3r�)	r?rSrQrRrxr@r�r�rws	         r�make_subsection�Parser.make_subsections������D�O�O�4�5�	��t�����G�,�����;�;�t���7�C����D�O�O�4�S�9�=�=�i�H�� ����D�O�O�4�S�9�=�=�l�K�"�#����D�O�O�4�S�9�=�=�j�I���!&��8��6�JL�L�I���D�O�O� <�Y� G�+2�i�(�.8�l�+�+-�I�i�(�,0�j�)�!���N�I�)-�0�F��{�{�4�?�?�3���K�K����0��5�9�9�)�D����K�K����0��5�9�9�,�G����K�K����0��5�9�9�*�E���"�F�4��FH�H�	�K�K����8��C�'.�)�$�*4�,�'�')�	�)�$�(0�*�%��
rc�N�[URUR5n/nUS:Xa�URURHvnURURURS5U:XdM4URURURS5U:XdMeUR	U5 Mx O�URURH�nURURURS5U:XdM4URURURS5U:XdMeURURURS5U:XdM�UR	U5 M� UHnURURU	M g)a�Remove a subsection from one or more sections.

section= the section to which the subsection belongs
identifier= the name of the subsection
position= the position of the section in the dictionary with the
          sections (e.g. the 1st "Screen" section would be 0).
          If set to None it will remove a subsection from all the
          instances of the said section (e.g. in all the "Screen"
          sections)NrSrQrR)r�r=r3r�rb)r?rSrQrRrxr�r@�items        r�remove_subsection�Parser.remove_subsectionDs]������D�O�O�4�5�	��	��t�����D�O�O�4���K�K����0��6�:�:�9�E����K�K����0��6�:�:�<�H����$�$�T�*�5����D�O�O�4���K�K����0��6�:�:�9�E����K�K����0��6�:�:�<�H����K�K����0��6�:�:�:�F����$�$�T�*�5��D����D�O�O�,�T�2�rc��Sn/n/n	US:XaURXU5 OURXUUS9 US:XaSU-S-[U5-S-n
O)SU-S-U-U-U-S-U-[U5-U-S-n
[URUR5nUS:Xa UU/S.URURS'US:XGa�[URU5nSn
X�:a�URURH�nURURURS5U
:XdM4URURURS	5U:XdMeURURURS
5U:XdM�UR
U
5 M� U
S-
n
X�:aM�[US-5HnX�;dM
URXUS9 M URURHvnURURURS
5U:XdM4URURURS	5U:XdMeU	R
U5 Mx GOURURHvnURURURS5U:XdM4URURURS
5U:XdMeU	R
U5 Mx [U	5S:Xas[URUR5nX/US.URUR[URUR5'U	R
U5 U	H1nURURUS
R
U
5 M3 g)a}Add an option to one or more subsections.

section= the section which contains the subsection
identifier= the identifier of the SubSection (e.g. Display)
option= the option to add
value= the value which will be assigned to the option
option_type= if set to "Option" it will cause the option to look like
             the following:
             Option "NameOfTheOption" "Value"
            
             Otherwise it will look like the following:
             NameOfTheOption "Value"
position= e.g. 0 (i.e. the option will be added to a subsection which
          is located in the first element in the list of Screen
          sections)rUNr�rYrZr)rSrQrTrRrSrQrV)rSrQrTrRrT)	�remove_suboptionr�r�r=r3r�rb�ranger�)r?rSrQr�r�r�rRr��
not_to_create�	to_modifyr�rx�cursect_lengthrtr@r�s                r�
add_suboption�Parser.add_suboptionds���$���
��	��t���!�!�'�v�>��!�!�'�v�*2�
"�
4��$���6�M�D�(�3�u�:�5��<�E��K�'�$�.��7�&�@�6�I���"�#�%(��Z�0�28�9�;?�@�E�����D�O�O�4�5�	���>�:A�$��/5�D�K�K����(��+��t��!����W�!5�6�N��B��%� �K�K����8�D����D�O�O�4�T�:�>�>�z�J������D�O�O�4�T�:�>�>�y�I�� ����D�O�O�4�T�:�>�>�|�L�"�#�%�,�,�R�0�9��a����%��>�A�-�.���)��(�(��q�(�I�/����D�O�O�4���K�K����0��6�:�:�<�H����K�K����0��6�:�:�9�E����$�$�T�*�5����D�O�O�4���K�K����0��6�:�:�:�F����K�K����0��6�:�:�<�H����$�$�T�*�5��9�~��"�����D�O�O� <�=�	�$��H�6����D�O�O�,��D�K�K����0�1�3�� � ��+��D��K�K����(��.�y�9�@�@��G�rc���0n[URU5S:wGa�[URUR5S:wGa�URURGH�nURURUnUS:Xa�URS5U:Xa�URS5U:Xa�SnUSHvn	U	R	5R5R
UR	5R55S:wa!URU/5RU5 US-
nMx O�URS5U:Xa�URS5U:Xa�URS5U:Xa�SnUSHvn	U	R	5R5R
UR	5R55S:wa!URU/5RU5 US-
nMx AGM� U$)	z�Get a dictionay of the suboptions to blacklist.

See add_suboption() for an explanation on the arguments.

Used in both remove_option() and remove_suboption()rNrSrQrTr2rVrR)	r�r=r3r�r`rdrercrb)
r?rSrQr�rRr�r@�	temp_elemrt�opts
          r�_get_suboptions_to_blacklist�#Parser._get_suboptions_to_blacklist�s����	��t�{�{�7�#�$��)��4�;�;�t���/�0�A�5� �K�K����8�D� $���D�O�O� <�T� B�I��4�'�%�M�M�)�4��?�%�M�M�,�7�:�E�!"�B�'0��';��$'�I�I�K�$5�$5�$7�%)�T�&�,�,�.�*>�*>�*@�%A�R�%H�$-�$8�$8��r�$B�$I�$I�"�$M� "�a���	(<��&�M�M�)�4��?�%�M�M�,�7�:�E�%�M�M�*�5��A�!"�B�'0��';��$'�I�I�K�$5�$5�$7�%)�T�&�,�,�.�*>�*>�*@�%A�R�%H�$-�$8�$8��r�$B�$I�$I�"�$M� "�a���	(<�
"�+9�,�rc��URXX45nUH9nSnXVH,nX�-
n	URURUSU		US-
nM. M; g)z#Remove an option from a subsection.rrTrVN)rr=r3)
r?rSrQr�rRr�r@r�r��real_poss
          rr��Parser.remove_suboption�sd���5�5�g�6<�H�	��D��F�!����=���K�K����0��6�y�A�(�K��!���(�rc��SX4-nURUHnUSU:XdMUSs $ [U5e![a [ef=f)z;Get the identifier of a specific section from its position.z1No identifier can be found for section "%s" No %drVr)r;rgrr)r?rSrR�	error_msgr{s     r�get_identifier�Parser.get_identifier�sh��I��)�*�	�	#��(�(��1����7�h�&���7�N�2�
"�)�,�,���	#�"�"�	#�s�9�9�9�A
c�d	�U(arSUR5R5;agUR5R5RUR5R55(dg/nSnSnSnURS5n	U	S:�Ga
UGHn
U	S;atUS:XanU
R	5(dKU
S:Xa7US:wa+US-S:wa"[U5S:�aUR
U5 SnUS	-
nOrUS-S:waXj-
nOdUS-S:waXj-
nOVU
R	5(dU
S:XaUS	-
nO5Xj-
nO0US-S:waXj-
nO"[U5S:�aUR
U5 SnU[U5S	-
:XaUS:waUR
U5 US	-
nGM OsUHmn
U
R	5(dXj-
nO"[U5S:�aUR
U5 SnU[U5S	-
:XaUS:waUR
U5 US	-
nMo [U5nUS	:�GaOURVs/sH o�R5R5PM" n
nUS:wa�US:Xa�US:Xa�USR5R5U
;a�Sn[US	R55nURHHnUSR5R5UR5R5:XdMFUn O URX�5nU/$U	S
:wa>US:wa8SnUH)nUR5UR5:XdM'SnM+ US:XagUS:Xa&USR5R5S:XagURVs/sH o�R5R5PM" nnU	S
:XaoUS:XaiUR5R5S
:Xa[U5S:XaUS		0nUHnURU5 M [UR!55$U	S:�a
U	S
::aX[S	-
$U	S
:�aUS	U$U	S:XaUS	SR#U5$gU	S;aUS:XaU$gs snf![a gf=f![a GN�f=fs snf)z�Clean the option and return the value

This returns the last item of the list which this method generates.

If no value can be found, return False.r�FrOrrU)r[�r)r[rVrT�True�inputdevice� N)r`rdrar�r�r�rbr9�intr8rrr�r6rcr�r��join)r?r��optnamer�rSr�r�rtr�r�r��optlen�x�references_listr{r�r�rQ�statusr@r6�server_dicts                      r�
_clean_option�Parser._clean_option�sx����6�<�<�>�/�/�1�1���<�<�>�'�'�)�4�4�W�]�]�_�5J�5J�5L�M�M������
���	��<�<��$���a�<����v�%�'�^�*C��9�9�;�;���8�(�A�~�)�a�-�1�2D�#&�v�;��?�$+�N�N�6�$:�-/�F�%��N�I�(�1�}��1� &����%�q�=�A�-�"�K�F���9�9�;�;���8�%��N�I�"�K�F�%�q�=�A�-�"�K�F� #�6�{�Q�� '���v� 6�)+����V��q��(���|����v�.��a���M�P���y�y�{�{��K�F��6�{�Q�����v�.�!#����V��q��(���|����v�.��a���� �W����A�:�
;?�/�/�J�/�Q�w�w�y���0�/�O�J��>�)��Q��6�Q�;���
� � �"�(�(�*�o�=�
��D����
� 0� 0� 2�3�E� $����"�1�:�+�+�-�3�3�5�����9K�9K�9M�M�#'�D�!�!0�%�%)�%8�%8��%E�
� *�|�+��1�}��N�!:���#�D��z�z�|�w�}�}��6�!%��$��U�?� ���{�w�q�z�/�/�1�7�7�9�X�E��9=���G���
�
��*�*�,��H�G��1�}��N�!:��M�M�O�)�)�+�}�<���L�A�%���
� ��#�D��*�*�4�0�$��K�,�,�.�/�/��A��(�a�-��q�y�)�)��A���A�J����Q���A�J��x�x��(�(���6�!�g��&?�����IK��(0�%�$�%��!�����"HsC�7'R�A,R�R�R�!'R-�
R�R�R�R�
R*�)R*c��/nURURU5S:Xa[eURUURS5 g![Ga� US:Xa[S5eURUGHXnURUURS5U:XdM+URUURS5U:XdMRURUURS5U:XdMyURUUSH�n	UR
5R5U	R
5R5;dMCU	R
5RS5S	:wa1U	R
5S
U	R
5RS5n
OU	R
5n
URURU
X&S95 M� GM[ [U5S
:Xa[e[U5S:�aUs$US
s$![a gf=f[Ga URUUH�nUR
5R5UR
5R5;dMCUR
5RS5S	:wa1UR
5S
UR
5RS5n
OUR
5n
URURX�XaS
95 M� [U5S
:Xa[e[U5S:�aUs$US
s$![a gf=f[a [ef=f)a�
Get the value which is assigned to an option.

Return types:
  * string (if only one value is available)
    - usually in options
  * list (if more than one option is found)
    - having multiple references of the same type is allowed.
      for example it is not unusual to have 2 references to
      Screen sections in the ServerLayout section (in case of
      Xinerama)
    - if the options are actually options and not references
      then there are duplicate options, which should be detected
      in advance with get_duplicate_options()   
  * None (if no value can be found) - Not always true -> See below.

Use-case for returning None
  * When dealing with incomplete references. For example:
        Screen "Configured Screen"
      is different from:
        Screen
        (which is an incomplete reference)
  * When dealing with incomplete options. For example:
        Depth 24
      is different from:
        Depth
        (which is an incomplete option)
  * Exception:
      Some options (with the "Option" prefix) (not references)
      can be used with no value (explicitly) assigned and are
      considered as True by the Xserver. In such case get_value()
      will return "True". For example:
        Option "AddARGBGLXVisuals" 
      is the same as:
        Option "AddARGBGLXVisuals" "True"

Meaning of keys in Sections and SubSections:
  * When dealing with a Section:
      section= e.g. 'Screen', 'Device', etc.
      option= the option
      position= e.g. 0 (i.e. the first element in the list of Screen
                sections)
      reference= used only by get_references()

  * When dealing with a SubSection:
      section= 'SubSection' (this is mandatory)
      option= the option
      position= e.g. 0 would mean that the subsection belongs to 
                the 1st item of the list of, say, "Screen" sections.
                (i.e. the first element in the list of Screen 
                sections)
                ["position" is a key of an item of the list of 
                subsections see below]
      identifier= the name of the subsection e.g. 'Display'
      sect = the 'section' key of an item of the list of 
             subsections e.g. the "Display" subsection can be 
             found in the "Screen" section ('sect' is the latter)

Anatomy of Sections and SubSections:
  * Anatomy of subsections:
      self.globaldict['SubSection'] =
          {0: {'section': 'Screen', 'identifier': 'Display', 
           'position': 0, 'options': [option1, option2, etc.], 
           etc.}
          In this case we refer to the 'Display' subsection 
          which is located in the first 'Screen' section.

  * Anatomy of a section:
      self.globaldict['Screen'] =
          {0: [option1, option2, etc.], 1: [...], ...}
      0, 1, etc. is the position N�fooz)An identifier is required for subsectionsrQrRrSrTrPr2rr�rV)r�rS)r=r�rr�r��	Exceptionr`rdrerbrr�rr�r�rg)r?rSr�rRrQr{r��valuesr@r�stropts           rr��Parser.get_value�s���R���;�;�w��#�#�H�-��5�"�"�=
&����G�$�X�.�4�4�U�;��!� 
(���%�#�%2�3�3�!%���G� 4�� �K�K��0��6�:�:�<�H�&�'� �K�K��0��6�:�:�:�F�$�%� �K�K��0��6�:�:�9�E��M�'+�{�{�7�';�D�'A�)�'L��$*�L�L�N�$8�$8�$:�$'�I�I�K�$5�$5�$7�%8�'*�y�y�{�'7�'7��'<��'B�14����Q��=B�U�W�T�T�#�Y�2P��25�����$*�M�M�$�2D�2D�V�28�3E�3O�%P�(M�
!5�$�6�{�a�'�-�-��6�{�Q��%�
�(�#)�!�9�,��)�(�#'�(���
$� �K�K��0��:�D��|�|�~�+�+�-�����1C�1C�1E�E��:�:�<�,�,�S�1�R�7�%)�Z�Z�\�!�T�Z�Z�\�5F�5F�s�5K�%L�F�%)�Z�Z�\�F��
�
�d�&8�&8��09�'9�'L�M�;��v�;�!�#�)�)��v�;��?�!�M�$�%�a�y�(��%�$�#�$���
&�%�%�
&�sv�!A�AM�$#M�#M�2AM�
B2M�?H�M�
H�M�H�AM�6B-M�&L-�*M�-
L;�7M�:L;�;Mc��US:waURX5 gUS:wa!URURU5S:g$Sn[	U5e![a gf=f)ziSee if a section with a certain identifier exists.

NOTE: either identifier or position must be provided.NTFz.Either identifier or position must be provided)r�rr=r�r)r?rSrQrRrs     rr��Parser.is_section#so��
���
��!�!�'�6����
��;�;�w�'�+�+�H�5��=�=�H�I��I�&�&��
'�
��
�s�A�
A�Ac��SU<SU<S3nURUHLnUSR5R5UR5R5:XaUSs $MN [	U5e![a Mhf=f)z;Get the position of a specific section from its identifier.zNo z section named "z" can be foundrrV)r;r`rdr�r)r?rSrQrr{s     rr��Parser.get_position4s����z�+�	��$�$�W�-�D�
���7�=�=�?�(�(�*�j�.>�.>�.@�.F�.F�.H�H���7�N�I�.�"�)�,�,��"�
��
�s�AA6�6
B�Bc�L�0RUR5n0nURH8n0X#'0X'URUHnURUU5X#U'M M: UH�nX#H�nX#UH�n[	X#UU5S:�dMX#UUHunUR
H7nUR
5UR5R
5:XdM5UnM9 URXg5(aMbXRU5 Mw M� M� M� U$)a4Look for references to sections which don't exist

This returns a dictionary having the items of self.require_id as keys
and a dictionary with the identifiers of the sections which are
being referred to by the broken references.

For example:

broken_references = {
                    'InputDevice': {'InputDevice 1': None,
                                    'Another input device': None},
                    'Device': {...},
                    'Monitor' {...},
                    'Screen' {...},
                    'ServerLayout' {...}
                    }r)
r:r8r=r�r�r6rdr`r�rc)r?�broken_references�references_treerSr{r@�refsectr�s        rr��Parser.get_broken_referencesAs%��$�K�K����8�������G�')�O�$�)+��&����G�,��15�1D�1D�W�EI�2K��(��.�-�'�'�G�'�0��.�7��=�G��?�3�D�9�'�B�C�a�G�#2�#;�D�#A�'�#J�C�(,�
�
��#'�:�:�<�7�=�=�?�3H�3H�3J�#J�.2�G�)6�$(�?�?�7�#@�#@�!2� :� E� E�c� J�$K� >�1�'� !� rc��/nURSnSnUH�nURSSU5nU(a�SnURSH_nUSR5R	5UR5R	5:XdMFURUS5 US-
nMa US:Xa
Sn[
U5eUS-
nM� U$![a Nf=f)z�Return a list with the position of default ServerLayout sections

NOTE: If the section set as the default ServerLayout doesn't exist
      it will raise a ParseException.r*r�DefaultServerLayoutr)rVr�)r=r�r;rdr`rbrr)	r?�default�serverflagsrt�flagr��def_itrQr|s	         rr��Parser.get_default_serverlayoutos������k�k�-�0��
���D�
�!%���
�/D�b�"J��!��F�&*�&6�&6�~�&F�
�&�q�M�/�/�1�7�7�9�*�0�0�2�8�8�:�;�#�N�N�:�a�=�9�"�a�K�F�	'G�
��{�!K��,�U�3�3�
�!�G�B�% �&���#�
��
�s�A-C�0C�
C�Cc���USH�nUSUSnUSUSnUSURS5nUSUSnXRU/5RSU-S-S-5 [U5S	:�a-XURS
S
R	U5-S-5 M�XURS
R	U5S-5 M� US	U$![
a U$f=f)z<Put SubSections back into the sections to which they belong.r"rSrQrRrTz
	SubSection "rUrZrrYz	EndSubSection
)r�rcrbr�rrg)r?rwr{rSrQrRrTs       r�_merge_subsections�Parser._merge_subsections�sG���l�+�D���-�d�3�I�>�G�"�<�0��6�|�D�J� ��.�t�4�8�8��D�H���-�d�3�I�>�G���)�)�(�B�7�>�>�=@�BL�=M�<?�=@�BF�=G�
H��7�|�a���"�8�,�3�3�D�48�I�I�g�4F�5G�4G�5H�I��"�8�,�3�3�D�I�I�g�4F�4G�5H�I�,� 	��,�'�����	����	�s�C�
C)�(C)c	�l�[R"UR5nURU5nUR	U5n/nSRUR5S-nURU5 UHtnX`R:wdM[X65S:�dM'X6HEnURSU-S-S-5 URSRX6U5S-5 MG Mv A[US5(dQU(a
[US5nO[US	5nURSRU55 UR5 gUR[[SRU5S
555 g![ a# URSRU55 gf=f)
aqWrite the changes to the destination

The destination can be either a file (e.g. /etc/X11/xorg.conf)
or a file object (e.g. sys.stdout).

destination = the destination file or file object (mandatory)
test = if set to True write will append the result to the
       destination file instead of overwriting it. It has no
       effect on file objects. Useful for testing.rOrZrz	Section "rUzEndSection

rM�a�wzUTF-8rN)�copy�deepcopyr=�_merge_commented_optionsr0rr<rbr4r�r\r]rMr_r��bytes�	TypeError)r?�destination�testrw�linesr<rSr@s        rrM�Parser.write�ss���M�M�$�+�+�.�	��1�1�)�<�	��+�+�I�6�	����7�7�4�=�=�)�D�0��
���X�� �G��-�-�-��y�)�*�Q�.� )� 2�����%5��%?�#�%E��%L�M����R�W�W�Y�-?��-E�%F�%5�&6�7�!3�!�
��{�G�,�,��"�;��4��"�;��4�����b�g�g�e�n�-�����
3��!�!�#�e�B�G�G�E�N�G�&D�"E�F���
3��!�!�#�(�(�5�/�2�
3�s�3F�*F3�2F3c��/nURURH^nURURUSU:XdM(URURUSU:XdMMURU5 M` U$)z.Get all the subsections contained in a sectionrSrR)r=r3rb)r?rSrRr�r�s     rr��Parser.get_subsections�st�����;�;�t���/�C����D�O�O�,�S�1�)�<��G��K�K����0��5�j�A�X�M��"�"�3�'�0�
�rc�p�UGHnURURUSnURURUSnURURURS5nURURUSnURR	SU-S-S-5 UHLnSUR5-nURR	U5 URR	S	5 MN URURU	GM  g
![a GM1f=f)aPut SubSections back into their sections and comment them out

This alters globaldict and should be used only in
comment_out_section() i.e. when the whole section is being
commented out.

subsections = the list of the indices subsections to merge and
removerSrQrRrTz#	SubSection "rUrZ�#		%s
�#	EndSubSection
N)r=r3r�r<rbr`rg)	r?r�r{rSrQrRrTr�rs	         r�_permanent_merge_subsections�#Parser._permanent_merge_subsections�s�� �D��k�k�$�/�/�2�4�8��C�G����T�_�_�5�d�;�L�I�J��{�{�4�?�?�3�D�9�=�=�j�I�H��k�k�$�/�/�2�4�8��C�G��M�M� � �!7�*�!D�s�!J�!%�"&�
'�"��!�V�\�\�^�4���
�
�$�$�S�)��
�
�$�$�%9�:�"�

��K�K����0��6� ���
��
�s�D&�&
D5�4D5c�4�/nURURRU5(ahURURUHHnURURUURS5U:XdM7URU5 MJ U$)zBReturn the index of the entry in the Comments section of a sectionrR)r=r4r�rb)r?rSrRr<r{s     r�
_get_comments�Parser._get_comments�s������;�;�t�*�*�+�/�/��8�8����D�$7�$7�8��A���K�K�� 3� 3�4�W�=�d�C��S��_��1��O�O�D�)�B�
�rc�Z�SnUGH�nURURUSnURURUSnURURURS5nURURUSnSU-nURXF5n	U	(dn0URURU'0URURUU'URURUUn
SU
S'XjS'SU
S'/U
S'A
URURUUSnURU5 UH'nSUR
5-n
URU
5 M) URU5 URURU	GM� g)	a3Put SubSections back into their sections and comment them out

This alters globaldict and should be used only to comment out
subsections (i.e. in comment_out_subsection()) when the whole section
is not being commented out.

subsections = the list of the indices subsections to merge and
              removerBrSrQrRrTz#	SubSection "%s"
NrA)r=r3r�rFr4rbr`)r?r��end_subsectionr{rSrQrRrT�start_subsectionr<rw�comments_optionsr�rs              r� _merge_subsections_with_comments�'Parser._merge_subsections_with_comments
s���.���D��k�k�$�/�/�2�4�8��C�G����T�_�_�5�d�;�L�I�J��{�{�4�?�?�3�D�9�=�=�j�I�H��k�k�$�/�/�2�4�8��C�G�5��D���)�)�'�<�H��<>����D�/�/�0��9�FH����D�/�/�0��9�(�C� �K�K��(;�(;�<�W�E�h�O�	�*.�	�,�'�(0�*�%�'+�	�)�$�')�	�)�$��#�{�{�4�+>�+>�?�� -�-5� 7�7@� B��
�#�#�$4�5�!��!�V�\�\�^�4�� �'�'��,�"�
�#�#�N�3����D�O�O�,�T�2�= rc�H�URX5nURU5 g)z-Comment out all the subsections of a section.N)r�rC)r?rSrRr�s    r�_comment_out_subsections�Parser._comment_out_subsections6s"���*�*�7�=���)�)�+�6rc�r�URX5nUH nURURUU	M" g)zBRemove comment sections of a "section" from the "Comments" sectionN)rFr=r4)r?rSrRr<�comment_sections     rr��Parser._remove_comment_entries<s:���%�%�g�8��'�O����D�/�/�0��9�/�J� (rc�x�SU-nSn0nU(a%URX5nURUS5 OdUS:wa'URXS9(aURUS5 O7[	UR
UR
55n0RU5nXR;agSn	URUHRn
[	UR
55RU
S5nX�[	UR
55U'U	S-
n	MT [	UR
55nUR5 Sn
UH�nURRU5 UR
UUH1nSUR5-nURRU5 M3 UR!X5 URRU5 UR#X5 UR
UU	XnnUS:wdM�UU
-
nURUU	U
S-
n
M� g![a GN�f=f![a GN1f=f)z.Comment out a section and all its subsections.z
#Section "%s"
z#EndSection
Nr�rrVz#	%s
)r�rcrr�r�r=r�r:r8r;r�r�r�r<rbr`rOr�)r?rSrQrR�
start_section�end_sectionr�r��all_keysrtr�r�r�r�r{r��commented_option�	ident_refr�s                   r�comment_out_section�Parser.comment_out_sectionCs%��,�w�7�
�%��
�	��
��'�'��<���$�$�S�$�/�
��
����w��:��$�$�X�t�4���D�K�K��0�5�5�7�8�H����H�-�I��o�o�%��B�!�-�-�g�6�	���y�~�~�/�0�6�6�y��|�D�C�=?�d�9�>�>�#3�4�S�9�:��a���
7��Y�^�^�-�.�
�������!�D��M�M� � ��/��+�+�g�.�t�4��#,�����#?� ��
�
�$�$�%5�6�5�
�)�)�'�8��M�M� � ��-�
�(�(��7����G�$�T�*�"��I��D� �#�f�,���$�$�W�-�g�6��!���3"��='�
��
��,"����s$�#H�>A	H+�
H(�'H(�+
H9�8H9c��/nURURHNnURURUnUSU:Xa%USU:XaUSU:XaURU5  OAMP URU5 g)z�Comment out a subsection.

section= the type of the section which contains the subsection
identifier= the identifier of the subsection
position= the position of the sectionrSrQrRN)r=r3rbrL)r?rSrQrRr�r3rws       r�comment_out_subsection�Parser.comment_out_subsection�s������+�+�d�o�o�6�J����D�O�O�4�Z�@�I��)�$��/��,�'�:�5��*�%��1��"�"�:�.���7�	
�-�-�k�:rc���URXUXE5nUGH^nSnXgGHOn	X�-
n
SURUUU
R5-URUUU
'URURR	U05 [URURU5nURURUnUR	U05 X�R	SS5 X�R	SU5 X�R	SS5 X�R	S/5 X�SR
URUUU
5 AURUUU
	US-
nGMR GMa g)	a-Comment out an option in a section.

section= the section which will have the option commented out
option= the option to comment out
value= if you want to comment out an option only if it has a
       certain value
position= e.g. 0 (i.e. the first element in the list of Screen
              sections)r�#%srQNrRrSrTrV)r�r=r`r4rcr�rb)
r?rSr�r�rRr�r�r�r�rur�rxrws
             r�comment_out_option�Parser.comment_out_option�s{���2�2�7�E�3;�H�	��D��F�!����-��7<����G�,�T�2�7�;�A�A�C�8E����G�$�T�*�7�3����D�/�/�0�;�;�G�R�H�����D�,?�,?� @�� I�J�	� �K�K��(;�(;�<�W�E�	��$�$�T�2�.���*�*�<��>���*�*�:�t�<���*�*�9�d�;���*�*�9�b�9���	�*�1�1�*.�+�+�g�*>�t�*D�W�*M�O���K�K��(��.�w�7��!���+(�rc�@�URXX45nUGH�nSnXVGHvnX�-
n	SURURUSU	R5-URURUSU	'URURRUR05 URURURn
U
RU05 X�RSU5 X�RSU5 X�RSU5 X�RS/5 X�SnURURUSU	nUR
U5 A
URURUSU		US-
nGMy GM� g)	a@Comment out an option in a subsection.

section= the section which contains the subsection
identifier= the identifier of the subsection
option= the option to comment out
position= the position of the section which contains the subsection
          e.g. 0 (i.e. the first element in the list of Screen
          sections)rr`rTrQrRrSrVN)rr=r3r`r4rcrb)
r?rSrQr�rRr�r@r�r�r�rwrKrXs
             r�comment_out_suboption�Parser.comment_out_suboption�s����5�5�g�6<�H�	��D��F�!����-��JO��{�{�4�?�?�3�D�9�)�D�W�M��U�W�K����D�O�O�,�T�2�9�=�g�F����D�/�/�0�;�;�D�O�O�<>�@� �K�K��(;�(;�<�T�_�_�M�	��$�$�T�2�.���*�*�<��D���*�*�:�t�<���*�*�9�g�>���*�*�9�b�9�#,�?�9�#=� �#'�;�;�t���#?��#E�.7�$9�9@�$B� � �'�'�(8�9���K�K����0��6�y�A�'�J��!���5(�rc��XRGHinSnXRUH�nXRUURS5nXRUURS5nXRUURS5nXRUUSnXPR:Xa@XH6n	XU	n
U
SU:XdMU
SU:XdM U
SU:XdM+XU	Sn M� M�XRU5nM� U(dGM
WHYnSUR5-nX R:Xa#UR	S/5RU5 MHURU5 M[ GMl U$)zAPut commented out options back into their sections or subsectionsNrSrQrRrTz	%s
)r4r�r3r`rcrb)r?rwr{�section_options�section_instancerSrQrRrTr�r3r�s            rr7�Parser._merge_commented_options�s����1�1�2�D�"�O�$-�.A�.A�$B�4�$H� �#�$7�$7�8��>�$4�6�69�c�)�n��&�':�':�;�D�A�'7�9�9<��\�9J��$�%8�%8�9�$�?�%5�7�7:�s�:���#�$7�$7�8��>�$4�6�6?�A���o�o�-�(���%.�_�S�%9�
�&�|�4�
�B�&�z�2�h�>�&�y�1�W�<�.7�o�c�.B�9�.M�O�!�
 /�'0�o�&9�&9�(�&C�O�%%I�(��%�F�%�����8�F����.�'�2�2�9�35�7�7=�v�f�~�'�.�.�v�6�
&�/3�>�r)
r=r<r4r;r9r8r6r5r3r7rD)NNNrU)NNN)NN)4rr
rrrrArFrJ�property�
globaldictr>rirhr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�rrr�r�r�r�r�r0rMr�rCrFrLrOr�rZr]rardr7rr
rrrr*sP��@�N�`�"��+�{�3�J�T%�ll,�\-�^"8�H-�^�C�J�">B�9<�F9�P@D�;?�,�\CG�#��&7�r@�F;�$>�$1�f6�p3�B26�NH�d/3� �F
�-�\�|?C�'+�Q&�f'�"-�+!�\�>�8*3�X
��8
�*3�X7�K�E�P;�(HL�%)�$�N(�V"rr)�
__future__rr�sysrrr5rrrrr�objectrr
rr�<module>rosT��(&�'�
���	�)�	�	�i�	�	�y�	�	�Y�	�i�V�ir

Filemanager

Name Type Size Permission Actions
__init__.cpython-313.pyc File 144 B 0644
xorgparser.cpython-313.pyc File 73.45 KB 0644
xutils.cpython-313.pyc File 6.5 KB 0644
Filemanager