a
    yn„fw	  ã                   @  sZ   d dl mZ d dlZd dlmZ d dlmZ dZedd�dd	ddd
œdd„ƒZ	dd„ Z
dS )é    )ÚannotationsN)Úhigh_level_function)ÚHighLevelContext)Úcenterzak.str)Úmoduleú T)Ú	highlevelÚbehaviorÚattrsc                c  s   | fV  t | |||||ƒS )aj  
    Args:
        array: Array-like data (anything #ak.to_layout recognizes).
        width (int): Desired string length.
        padding (str or bytes): What to pad the string with. Should be one
            codepoint or byte.
        highlevel (bool): If True, return an #ak.Array; otherwise, return
            a low-level #ak.contents.Content subclass.
        behavior (None or dict): Custom #ak.behavior for the output array, if
            high-level.
        attrs (None or dict): Custom attributes for the output array, if
            high-level.

    Replaces any string or bytestring-valued data with centered
    strings/bytestrings of a given `width`, padding both sides with the given
    `padding` codepoint or byte.

    If the data are strings, `width` is measured in codepoints and `padding`
    must be one codepoint.

    If the data are bytestrings, `width` is measured in bytes and `padding`
    must be one byte.

    Note: this function does not raise an error if the `array` does not
    contain any string or bytestring data.

    Requires the pyarrow library and calls
    [pyarrow.compute.utf8_center](https://arrow.apache.org/docs/python/generated/pyarrow.compute.utf8_center.html)
    or
    [pyarrow.compute.ascii_center](https://arrow.apache.org/docs/python/generated/pyarrow.compute.ascii_center.html)
    on strings and bytestrings, respectively.
    )Ú_impl)ÚarrayÚwidthÚpaddingr   r	   r
   © r   úf/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/awkward/operations/str/akstr_center.pyr      s    #r   c              
   C  s~   ddl m} |dƒ}t||d��}| | ¡}	W d   ƒ n1 s@0    Y  tj |	tjjj	|j
|j||dd�¡}
|j|
|d�S )Nr   )Úimport_pyarrow_computeÚr)r	   r
   T)Zbytestring_to_string)r   )Zawkward._connect.pyarrowr   r   ÚunwrapÚakZ_doZrecursively_applyÚ
operationsÚstrZ_get_ufunc_actionZutf8_centerZascii_centerÚwrap)r   r   r   r   r	   r
   r   ZpcÚctxZlayoutÚoutr   r   r   r   5   s    (ÿþr   )r   )Ú
__future__r   Zawkwardr   Zawkward._dispatchr   Zawkward._layoutr   Ú__all__r   r   r   r   r   r   Ú<module>   s   (