File: //lib/python3/dist-packages/genshi/__pycache__/output.cpython-310.pyc
o
!�b�z � @ s8 d Z ddlmZ ddlZddlZddlmZmZmZm Z m
Z
ddlmZmZm
Z
mZmZmZmZmZmZmZmZmZ g d�ZdZd"d d
�Zd#dd�Zd$dd�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�Z G dd� de�Z!G dd� de�Z"e"j#Z#G dd� de�Z$G dd� de�Z%G d d!� d!e�Z&dS )%zUThis module provides different kinds of serialization methods for XML event
streams.
� )�chainN)�escape�Attrs�Markup�QName�StreamEventKind)�START�END�TEXT�XML_DECL�DOCTYPE�START_NS�END_NS�START_CDATA� END_CDATA�PI�COMMENT�
XML_NAMESPACE)�encode�get_serializer�DocType�
XMLSerializer�XHTMLSerializer�HTMLSerializer�TextSerializerzrestructuredtext en�xmlc sp � durd�|dkrt |t�sd�� �fdd�}ndd� }|du r*|d�t| ���S | D ] }|�||�� q,dS ) a� Encode serializer output into a string.
:param iterator: the iterator returned from serializing a stream (basically
any iterator that yields unicode objects)
:param method: the serialization method; determines how characters not
representable in the specified encoding are treated
:param encoding: how the output string should be encoded; if set to `None`,
this method returns a `unicode` object
:param out: a file-like object that the output should be written to
instead of being returned as one big string; note that if
this is a file or socket (or similar), the `encoding` must
not be `None` (that is, the output must be encoded)
:return: a `str` or `unicode` object (depending on the `encoding`
parameter), or `None` if the `out` parameter is provided
:since: version 0.4.1
:note: Changed in 0.5: added the `out` parameter
N�replace�text�xmlcharrefreplacec s | � � ��S �N)r ��string��encoding�errors� �//usr/lib/python3/dist-packages/genshi/output.py�<lambda>7 s zencode.<locals>.<lambda>c S s | S r r% r r% r% r&