%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/louis/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/louis/__pycache__/__init__.cpython-312.pyc

�

��f�Q���dZddlmZmZmZddlmZddlmZm	Z	m
Z
mZmZm
Z
mZmZmZ	ddlmZmZeecZZedZedk(Zej1�Zded	zzZerd
ne�ZdedzzZd
�Zd5d�ZdZeefd�Z eejB�eejD_#e
ej0_#eee�ee
�ee�ee
�ee�ee�e
fejH_%eee�ee
�ee�ee
�ee�ee�ee
�ee
�ee
�e
fejL_%eee�ee
�ee�ee
�ee�ee�e
fejN_%eee�ee
�ee�ee
�ee�ee�ee
�ee
�ee
�e
fejP_%eee�e
ee�e
fejR_%efejT_%eefejV_%eefejX_%eee�ee�e
e
fejZ_%eee�ee�e
e
fej\_%ede
e�Z/dej`_#dejb_#e
fejb_%d�Z2d�Z3d6d�Z4d7d�Z5d6d�Z6d7d�Z7d8d�Z8d�Z9d�Z:d�Z;d�Z<d8d�Z=d�Z>d�Z?dZ@d xZAxZBZCd	xZDxZEZFdxZGxZHZIdZJd!ZKd"ZLd#ZMd$ZNd%ZOd&ZPd'ZQd(ZRd)ZSd ZTd	ZUdZVd"ZWd#ZXd$ZYeYZZd%Z[dZ\d*Z]d+Z^d,Z_d-Z`d.Zad/Zbe\e]e^e_e`eaebfZcedd0k(r eee2��eee4d1gd2d3�4��yy#e$r	e
e	cZZY��$wxYw)9a�Liblouis Python ctypes bindings
These bindings allow you to use the liblouis braille translator and back-translator library
from within Python.
This documentation is only related to the Python helper.
Please see the liblouis documentation for more information.

Most of these functions take a C{tableList}      argument which specifies
a list of translation tables to use. Please see the liblouis documentation
concerning the C{tableList} parameter to the C{lou_translateString}
function for information about how liblouis searches for these tables.

@author: Michael Curran <mick@kulgan.net>
@author: James Teh <jamie@jantrid.net>
@author: Eitan Isaacson <eitan@ascender.com>
@author: Michael Whapples <mwhapples@aim.com>
@author: Davy Kager <mail@davykager.nl>
@author: Leonard de Ruijter <alderuijter@gmail.com>
@author: Babbage B.V. <info@babbage.com>
@author: Andre-Abush Clause <dev@andreabc.net>
�)�getfilesystemencoding�platform�version_info)�register)	�c_ushort�	CFUNCTYPE�cdll�c_char_p�c_char�c_int�POINTER�byref�create_string_buffer)�WINFUNCTYPE�windllzliblouis.so.20�win32���mbcsz	utf_%d_le�c	��dj|D�cgc]2}t|t�r|jt�n
t|���4c}�Scc}w)z*Creates a tables string for liblouis calls�,)�join�
isinstance�str�encode�fileSystemEncoding�bytes)�
tablesList�xs  �0/usr/lib/python3/dist-packages/louis/__init__.py�_createTablesStringr"UsL���9�9� �	
��-7�q�#�,>�A�H�H�'�(�E�!�H�L�	
����	
s�7ANc�6�|rt|z|�St|z�S)z,Creates a typeform buffer for liblouis calls)r)�length�typeforms  r!�_createTypeformbufr&_s!��-5�H�v���)�P�H�v�<M�;P�P��
surrogatepassc�8�t|�j||�S�N)rr)r �encoding�errorss   r!�createEncodedByteStringr-gs���q�6�=�=��6�*�*r'c�H�tj�jd�S)z�Obtain version information for liblouis.
    @return: The version of liblouis, plus other information, such as
        the release date and perhaps notable changes.
    @rtype: str
    �ASCII)�liblouis�lou_version�decode�r'r!�versionr4�s�����!�(�(��1�1r'c�*�tj�S)z�Obtain charSize information for liblouis.
    @return: The size of the widechar with which liblouis was compiled.
    @rtype: int
    )r0�lou_charSizer3r'r!�charSizer7�s��
� � �"�"r'c� �t|�}t|�}tt|�tz�}t|j
tz�}t|j
tz�}d}	|rt|j
|�}	t|j
z�}
t|j
z�}t|�}tj||t|�|t|�|	d||
t|�|�std|�d|�d|�d|�d|��
��t|t�rt|	�|dd|jd|j
tzj!t"t$��|
d|j
|d|j
|j
fS)a�Translate a string of characters, providing position information.
    @param tableList: A list of translation tables.
    @type tableList: list of str
    @param inbuf: The string to translate.
    @type inbuf: str
    @param typeform: A list of typeform constants indicating the typeform for each position in inbuf,
        C{None} for no typeform information.
    @type typeform: list of int
    @param cursorPos: The position of the cursor in inbuf.
    @type cursorPos: int
    @param mode: The translation mode; add multiple values for a combined mode.
    @type mode: int
    @return: A tuple of: the translated string,
        a list of input positions for each position in the output,
        a list of output positions for each position in the input, and
        the position of the cursor in the output.
    @rtype: (str, list of int, list of int, int)
    @raise RuntimeError: If a complete translation could not be done.
    @see: lou_translate in the liblouis documentation
    N�Can't translate: tables �, inbuf �, typeform z, cursorPos �, mode �r,)r"r-r�len�
wideCharBytes�value�outlenMultiplierrr&r0�
lou_translater�RuntimeErrorr�list�rawr2�conversionEncoding�ENCODING_ERROR_HANDLER��	tableList�inbufr%�	cursorPos�mode�tablesString�inlen�outlen�outbuf�typeformbuf�inPos�outPoss            r!�	translaterT�sh��*'�y�1�L�#�E�*�E��#�e�*�
�-�.�E�
�5�;�;�!1�1�
2�F�
!�&�,�,��">�
?�F��K��(����x�@��
�V�\�\�
!�$�E��e�k�k�!�
$�F��i� �I��!�!��
�
�e���
�f�
����
�
�i������%��9�d�
<�
�	
��(�D�!��;�'�����
�
�1�V�\�\�M�1�2�9�9��'=�	:�	
�	�n������}��������
�r'c
�@�t|�}t|�}tt|�tz�}t|j
tz�}t|j
tz�}d}|rt|j
|�}tj||t|�|t|�|d|�std|�d|�d|�d|����t|t�rt|�|dd|jd|j
tzj!t"t$��S)a�Translate a string of characters.
    @param tableList: A list of translation tables.
    @type tableList: list of str
    @param inbuf: The string to translate.
    @type inbuf: str
    @param typeform: A list of typeform constants indicating the typeform for each position in inbuf,
        C{None} for no typeform information.
    @type typeform: list of int
    @param mode: The translation mode; add multiple values for a combined mode.
    @type mode: int
    @return: The translated string.
    @rtype: str
    @raise RuntimeError: If a complete translation could not be done.
    @see: lou_translateString in the liblouis documentation
    Nr9r:r;r<r=)r"r-rr>r?r@rArr&r0�lou_translateStringrrCrrDrEr2rFrG�	rIrJr%rLrMrNrOrPrQs	         r!�translateStringrXs�� '�y�1�L�#�E�*�E��#�e�*�
�-�.�E�
�5�;�;�!1�1�
2�F�
!�&�,�,��">�
?�F��K��(����x�@���'�'��
�
�e���
�f�
����	���%��4�
1�
�	
��(�D�!��;�'�����:�:�4����}�4�5�<�<��#9�=��r'c�,�t|�}t|�}tt|�tz�}t|j
tz�}t|j
tz�}d}	t|t�rt|j
�}	t|j
z�}
t|j
z�}t|�}tj||t|�|t|�|	d||
t|�|�std|||||fz��t|t�rt|	�|dd|jd|j
tzj!t"t$��|
d|j
|d|j
|j
fS)agBack translates a string of characters, providing position information.
    @param tableList: A list of translation tables.
    @type tableList: list of str
    @param inbuf: Braille to back translate.
    @type inbuf: str
    @param typeform: List where typeform constants will be placed.
    @type typeform: list
    @param cursorPos: Position of cursor.
    @type cursorPos: int
    @param mode: Translation mode.
    @type mode: int
    @return: A tuple: A string of the back translation,
        a list of input positions for each position in the output,
        a list of the output positions for each position in the input and
        the position of the cursor in the output.
    @rtype: (str, list of int, list of int, int)
    @raise RuntimeError: If a complete back translation could not be done.
    @see: lou_backTranslate in the liblouis documentation.
    NzMCan't back translate: tables %s, inbuf %s, typeform %s, cursorPos %d, mode %dr=)r"r-rr>r?r@rArrrDr&r0�lou_backTranslaterrCrEr2rFrGrHs            r!�
backTranslater[Fss��('�y�1�L�#�E�*�E��#�e�*�
�-�.�E�
�5�;�;�!1�1�
2�F�
!�&�,�,��">�
?�F��K��(�D�!�(����6��
�V�\�\�
!�$�E��e�k�k�!�
$�F��i� �I��%�%��
�
�e���
�f�
����
�
�i�����[��%��9�d�;�
<�
�	
��(�D�!��;�'�����
�
�1�V�\�\�M�1�2�9�9��'=�	:�	
�	�n������}��������
�r'c
�N�t|�}t|�}tt|�tz�}t|j
tz�}t|j
tz�}d}t|t�rt|j
�}tj||t|�|t|�|d|�std|||fz��t|t�rt|�|dd|jd|j
tzj!t"t$��S)aMBack translate from Braille.
    @param tableList: A list of translation tables.
    @type tableList: list of str
    @param inbuf: The Braille to back translate.
    @type inbuf: str
    @param typeform: List for typeform constants to be put in.
        If you don't want typeform data then give None
    @type typeform: list
    @param mode: The translation mode
    @type mode: int
    @return: The back translation of inbuf.
    @rtype: str
    @raise RuntimeError: If a complete back translation could not be done.
    @see: lou_backTranslateString in the liblouis documentation.
    Nz2Can't back translate: tables %s, inbuf %s, mode %dr=)r"r-rr>r?r@rArrrDr&r0�lou_backTranslateStringrrCrEr2rFrGrWs	         r!�backTranslateStringr^�s�� '�y�1�L�#�E�*�E��#�e�*�
�-�.�E�
�5�;�;�!1�1�
2�F�
!�&�,�,��">�
?�F��K��(�D�!�(����6���+�+��
�
�e���
�f�
����	��@��%��&�
'�
�	
��(�D�!��;�'�����:�:�4����}�4�5�<�<��#9�=��r'c��t|�}t|�}tt|�tz�}t|jdz�}tj|||||�std|||fz��|jjd�S)a�Get information for hyphenation.
    @param tableList: A list of translation tables and hyphenation
        dictionaries.
    @type tableList: list of str
    @param inbuf: The text to get hyphenation information about.
        This should be a single word and leading/trailing whitespace
        and punctuation is ignored.
    @type inbuf: str
    @param mode: Lets liblouis know if inbuf is plain text or Braille.
        Set to 0 for text and anyother value for Braille.
    @type mode: int
    @return: A string with '1' at the beginning of every syllable
        and '0' elsewhere.
    @rtype: str
    @raise RuntimeError: If hyphenation data could not be produced.
    @see: lou_hyphenate in the liblouis documentation.
    �z-Can't hyphenate: tables %s, inbuf %s, mode %dr/)r"r-rr>r?rr@r0�
lou_hyphenaterCr2)rIrJrLrMrN�
hyphen_strings      r!�	hyphenaterc�s���$'�y�1�L�#�E�*�E��#�e�*�
�-�.�E�(����q��9�M��!�!�,��u�m�T�R��;�y�%�QU�>V�V�
�	
����%�%�g�.�.r'c�`�t|�}tj|�std|z��y)a�Check if the specified tables can be found and compiled.
        This can be used to check if a list of tables contains errors
        before sending it to other liblouis functions
        that accept a list of tables.
    @param tableList: A list of translation tables.
    @type tableList: list of str
    @raise RuntimeError: If compilation failed.
    @see: lou_checkTable in the liblouis documentation
    zCan't compile: tables %sN)r"r0�lou_checkTablerC)rIrMs  r!�
checkTablerf�s2��'�y�1�L��"�"�<�0��5�	�A�B�B�1r'c��t|�}t|t�r|jd�n
t	|�}t
j
||�std|�d|����y)aHCompile a table entry on the fly at run-time.
    @param tableList: A list of translation tables.
    @type tableList: list of str
    @param inString: The table entry to be added.
    @type inString: str
    @raise RuntimeError: If compilation of the entry failed.
    @see: lou_compileString in the liblouis documentation
    r/zCan't compile entry: tables z, inString N)r"rrrrr0�lou_compileStringrC)rI�inStringrM�inBytess    r!�
compileStringrk�sU��'�y�1�L�*4�X�s�*C�h�o�o�g�&��x��G��%�%�l�G�<��=F��Q�
�	
�=r'c�f�t|�}|jd�}tj||�S)aGet the typeform bit for the named emphasis class.
    @param tableList: A list of translation tables.
    @type tableList: list of str
    @param emphClass: An emphasis class name.
    @type emphClass: str
    @see: lou_getTypeformForEmphClass in the liblouis documentation
    r/)r"rr0�lou_getTypeformForEmphClass)rI�	emphClassrMs   r!�getTypeformForEmphClassro�s1��'�y�1�L�� � ��)�I��/�/��i�H�Hr'c�b�t|�}t|�}tt|�tz�}t|jtz�}tj||||d�std|�d|����|jd|jtzjtt��S)a�"Convert a string of dot patterns to a string of characters according to the specifications in tableList.
    @param tableList: A list of translation tables.
    @type tableList: list of str
    @param inbuf: a string of dot patterns, either in liblouis format or Unicode braille.
    @type inbuf: str
    @raise RuntimeError: If a complete conversion could not be done.
    @see: lou_dotsToChar in the liblouis documentation
    rz#Can't convert dots to char: tables r:Nr=)r"r-rr>r?rr@r0�lou_dotsToCharrCrEr2rFrG)rIrJrMr$rPs     r!�
dotsToCharrr�s���'�y�1�L�#�E�*�E�
�3�u�:��.�
/�F�
!�&�,�,��">�
?�F��"�"�<�����J��AJ�E�R�
�	
��:�:�4����}�4�5�<�<��#9�=��r'c�b�t|�}t|�}tt|�tz�}t|jtz�}tj|||||�std|||fz��|jd|jtzjtt��S)a�"Convert a string of characterss to a string of dot patterns according to the specifications in tableList.
    @param tableList: A list of translation tables.
    @type tableList: list of str
    @param inbuf: a string of characters.
    @type inbuf: str
    @param mode: The translation mode; add multiple values for a combined mode.
    @type mode: int
    @raise RuntimeError: If a complete conversion could not be done.
    @see: lou_charToDots in the liblouis documentation
    z8Can't convert char to dots: tables %s, inbuf %s, mode %dNr=)r"r-rr>r?rr@r0�lou_charToDotsrCrEr2rFrG)rIrJrLrMr$rPs      r!�
charToDotsrus���'�y�1�L�#�E�*�E�
�3�u�:��.�
/�F�
!�&�,�,��">�
?�F��"�"�<�����M��F��%��&�
'�
�	
��:�:�4����}�4�5�<�<��#9�=��r'c��|�8t|t�s(tdjtj���t
j
|�S)a|Register logging callbacks.
    Set to C{None} for default callback.
    @param logCallback: The callback to use.
        The callback must take two arguments:
        @param level: The log level on which a message is logged.
        @type level: int
        @param message: The logged message.
            Note that the callback should provide its own ASCII decoding routine.
        @type message: bytes

        Example callback:

        @louis.LogCallback
        def incomingLouisLog(level, message):
            print("Message %s logged at level %d" % (message.decode("ASCII"), level))

    @type logCallback: L{LogCallback}
    z,logCallback should be of type {} or NoneType)r�LogCallback�	TypeError�format�__name__r0�lou_registerLogCallback)�logCallbacks r!�registerLogCallbackr}(sG��&��z�+�{�'K��:�A�A�+�BV�BV�W�
�	
��+�+�K�8�8r'c�X�|tvrtd|z��tj|�S)z�Set the level for logging callback to be called at.
    @param level: one of the C{LOG_*} constants.
    @type level: int
    @raise ValueError: If an invalid log level is provided.
    z Level %d is an invalid log level)�	logLevels�
ValueErrorr0�lou_setLogLevel)�levels r!�setLogLevelr�Bs.��
�I���;�e�C�D�D��#�#�E�*�*r'r`�� �@��iiiii'i Ni0ui@�iP�i`��__main__s../tables/en-us-g2.ctbzHello world!�)rKr*)Nrr)Nr)r)f�__doc__�sysrrr�atexitr�ctypesrrr	r
rrr
rrrr�_loader�	_functype�ImportErrorr0�_is_windowsr6r?rArrFr"r&rGr-�lou_freer1�restyperV�argtypesrBr]rZrarerhrmrqrtrwr{r�r4r7rTrXr[r^rcrfrkrorrrur}r��
plain_text�emph_1�comp_emph_1�italic�emph_2�comp_emph_2�	underline�emph_3�comp_emph_3�bold�emph_4�emph_5�emph_6�emph_7�emph_8�emph_9�emph_10�computer_braille�no_translate�no_contract�noContractions�compbrlAtCursor�dotsIO�compbrlLeftCursor�ucBrl�noUndefined�noUndefinedDots�partialTrans�LOG_ALL�	LOG_DEBUG�LOG_INFO�LOG_WARN�	LOG_ERROR�	LOG_FATAL�LOG_OFFrrz�printr3r'r!�<module>r�sg��*�*>�=��
�
�
�)�*����G�Y��#�$���'�!���%�%�'�
��}�q�(�(�� +�V�0E�0G��!�M�A�$5�6���Q�
)��#�+A�+�	��	�	��'����� %�����
��F�O��E�N��F�O��E�N��H���F�O�	�	)����%�
��F�O��E�N��F�O��E�N��H���F�O��E�N��E�N��E�N�	�#�����
��F�O��E�N��F�O��E�N��H���F�O�	�	-�� � �)�
��F�O��E�N��F�O��E�N��H���F�O��E�N��E�N��E�N�	�'����#�
��F�O�	��F�O�	�#�����%-�;���� �'/��&:����#�19�8�0D��$�$�-�
��F�O��F�O�	�	�$���� �
��F�O��F�O�	�	�$���� ���e�X�.��+/�� � �(�#'���� �%*�H����!�2�#�:�z*�Z9�x*�Z/�:C�
�"
I��,�29�4+��
� &�&��&��v�#)�)��)��y�$�$��$��t�	��	��	��	��	��	��
������������	
����
�����������	������	��	�
���i��8�Y�	�7�S�	��z��	�'�)��	�)�.�/��1�
M�N���u�)��y��G�Y�)�s�
M�
M�M

Zerion Mini Shell 1.0