o
    i                  
   @  s&  d dl mZ d dlZd dlmZmZmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZ ee d d	lmZ W d   n1 sHw   Y  ermd d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ e dddd dddddd+d&d'Ze dddd dddddd,d)d*Z dS )-    )annotationsN)IOTYPE_CHECKINGLiteral)unstable)wrap_ldf)get_sources)!_init_credential_provider_builder)ScanOptions)PyLazyFrame)Path)StorageOptionsDict)	DataFrame)CredentialProviderFunction)	LazyFramelinesTautonamen_rowsrow_index_namerow_index_offsetglobstorage_optionscredential_providerinclude_file_pathssourcecstr | Path | IO[str] | IO[bytes] | bytes | list[str] | list[Path] | list[IO[str]] | list[IO[bytes]]r   strr   
int | Noner   
str | Noner   intr   boolr   StorageOptionsDict | Noner   3CredentialProviderFunction | Literal['auto'] | Noner   returnr   c          	      C  s   t | ||||||||d	 S )uh	  
    Read lines into a string column from a file.

    .. warning::
        This functionality is considered **unstable**. It may be changed
        at any point without it being considered a breaking change.

    Parameters
    ----------
    source
        Path(s) to a file or directory
        When needing to authenticate for scanning cloud locations, see the
        `storage_options` parameter.
    name
        Name to use for the output column.
    n_rows
        Stop reading from parquet file after reading `n_rows`.
    row_index_name
        If not None, this will insert a row index column with the given name into the
        DataFrame
    row_index_offset
        Offset to start the row index column (only used if the name is set)
    glob
        Expand path given via globbing rules.
    storage_options
        Options that indicate how to connect to a cloud provider.

        The cloud providers currently supported are AWS, GCP, and Azure.
        See supported keys here:

        * `aws <https://docs.rs/object_store/latest/object_store/aws/enum.AmazonS3ConfigKey.html>`_
        * `gcp <https://docs.rs/object_store/latest/object_store/gcp/enum.GoogleConfigKey.html>`_
        * `azure <https://docs.rs/object_store/latest/object_store/azure/enum.AzureConfigKey.html>`_
        * Hugging Face (`hf://`): Accepts an API key under the `token` parameter: \
          `{'token': '...'}`, or by setting the `HF_TOKEN` environment variable.

        If `storage_options` is not provided, Polars will try to infer the information
        from environment variables.
    credential_provider
        Provide a function that can be called to provide cloud storage
        credentials. The function is expected to return a dictionary of
        credential keys along with an optional credential expiry time.

        .. warning::
            This functionality is considered **unstable**. It may be changed
            at any point without it being considered a breaking change.
    include_file_paths
        Include the path of the source file(s) as a column with this name.

    See Also
    --------
    scan_lines

    Examples
    --------
    >>> pl.read_lines(b"Hello\nworld")
    shape: (2, 1)
    ┌───────┐
    │ lines │
    │ ---   │
    │ str   │
    ╞═══════╡
    │ Hello │
    │ world │
    └───────┘
    r   )
scan_linesZcollect)	r   r   r   r   r   r   r   r   r    r'   F/home/app/Keep/.python/lib/python3.10/site-packages/polars/io/lines.py
read_lines   s   Y
r)   r   c             
   C  s`   t | }	t||	|d}
~tj|	t|dur||fnd|dur!d|fnd||||
d|d}t|S )u	  
    Construct a LazyFrame which scans lines into a string column from a file.

    .. warning::
        This functionality is considered **unstable**. It may be changed
        at any point without it being considered a breaking change.

    Parameters
    ----------
    source
        Path(s) to a file or directory
        When needing to authenticate for scanning cloud locations, see the
        `storage_options` parameter.
    name
        Name to use for the output column.
    n_rows
        Stop reading from parquet file after reading `n_rows`.
    row_index_name
        If not None, this will insert a row index column with the given name into the
        DataFrame
    row_index_offset
        Offset to start the row index column (only used if the name is set)
    glob
        Expand path given via globbing rules.
    storage_options
        Options that indicate how to connect to a cloud provider.

        The cloud providers currently supported are AWS, GCP, and Azure.
        See supported keys here:

        * `aws <https://docs.rs/object_store/latest/object_store/aws/enum.AmazonS3ConfigKey.html>`_
        * `gcp <https://docs.rs/object_store/latest/object_store/gcp/enum.GoogleConfigKey.html>`_
        * `azure <https://docs.rs/object_store/latest/object_store/azure/enum.AzureConfigKey.html>`_
        * Hugging Face (`hf://`): Accepts an API key under the `token` parameter: \
          `{'token': '...'}`, or by setting the `HF_TOKEN` environment variable.

        If `storage_options` is not provided, Polars will try to infer the information
        from environment variables.
    credential_provider
        Provide a function that can be called to provide cloud storage
        credentials. The function is expected to return a dictionary of
        credential keys along with an optional credential expiry time.

        .. warning::
            This functionality is considered **unstable**. It may be changed
            at any point without it being considered a breaking change.
    include_file_paths
        Include the path of the source file(s) as a column with this name.

    See Also
    --------
    read_lines

    Examples
    --------
    >>> pl.scan_lines(b"Hello\nworld").collect()
    shape: (2, 1)
    ┌───────┐
    │ lines │
    │ ---   │
    │ str   │
    ╞═══════╡
    │ Hello │
    │ world │
    └───────┘
    r&   Nr   )Z	row_indexZ	pre_slicer   r   r   r   )sourcesZscan_optionsr   )r   r	   r   Znew_from_scan_linesr
   r   )r   r   r   r   r   r   r   r   r   r*   Zcredential_provider_builderZpylfr'   r'   r(   r&      s(   Yr&   )r   r   r   r   r   r   r   r    r   r!   r   r"   r   r#   r   r$   r   r    r%   r   )r   r   r   r   r   r   r   r    r   r!   r   r"   r   r#   r   r$   r   r    r%   r   )!
__future__r   
contextlibtypingr   r   r   Zpolars._utils.unstabler   Zpolars._utils.wrapr   Zpolars.io._utilsr   Z,polars.io.cloud.credential_provider._builderr	   Zpolars.io.scan_options._optionsr
   suppressImportErrorZpolars._plrr   pathlibr   Zpolars._typingr   Zpolars.dataframe.framer   Zpolars.io.cloudr   Zpolars.lazyframe.framer   r)   r&   r'   r'   r'   r(   <module>   sJ    e