
    Ogx                       d dl mZ d dlZd dlZd dlmZmZmZmZmZm	Z	m
Z
 d dlZd dlZd dlmZ d dlmZ d dlZd dlmZ d dlmZ d dlmZmZmZmZ d d	lmZmZmZmZmZm Z m!Z! d d
l"m#Z#m$Z$ d dl%m&Z& d dl'm(Z( d dl)m*Z*m+Z+ erd dl,m-Z- d dl.m/Z/ ddgZ0h dZ1 ejd                  d      Z3	 d,	 	 	 	 	 d-dZ4d,d.dZ5	 d/	 	 	 	 	 d-dZ6d0dZ7 G d d      Z8d1dZ9d2dZ:d3dZ;	 	 	 d4	 	 	 	 	 	 	 	 	 d5dZ< ejz                  d      Z> ejz                  d       Z?d6d!Z@ ejz                  d"      ZA ejz                  d#      ZBd7d$ZCej                  d8d%       ZEd8d&ZFd'ZGd(ZHd9d)ZId:d*ZJej                  ej                  ddf	 	 	 	 	 	 	 d;d+       ZLy)<    )annotationsN)TYPE_CHECKINGBinaryIOIterableIteratorCallableUnionOptional)defaultdict)Path)const)repair)has_dxf_unicodedecode_dxf_unicodehas_mif_encodingdecode_mif_to_unicode)DXFTag	DXFVertexDXFBinaryTagPOINT_CODESBINARY_DATA
TYPE_TABLEMAX_GROUP_CODE)
group_tagsTags)entity_structure_validator)
toencoding)Auditor
AuditErrorDrawing)SectionDictreadreadfile>   EOFTABLEENDBLKENDSECENDTABSEQENDSECTIONezdxfsurrogateescapec                    t        |       } t        | d      5 }t        ||      \  }}ddd       | _        |fS # 1 sw Y   xY w)u  Read a DXF document from file system similar to :func:`ezdxf.readfile`,
    but this function will repair as many flaws as possible, runs the required
    audit process automatically the DXF document and the :class:`Auditor`.

    Args:
        filename: file-system name of the DXF document to load
        errors: specify decoding error handler

            - "surrogateescape" to preserve possible binary data (default)
            - "ignore" to use the replacement char U+FFFD "�" for invalid data
            - "strict" to raise an :class:`UnicodeDecodeError` exception for invalid data

    Raises:
        DXFStructureError: for invalid or corrupted DXF structures
        UnicodeDecodeError: if `errors` is "strict" and a decoding error occurs

    rbmodeerrorsN)stropenr#   filename)r6   r3   fpdocauditors        R/var/www/html/public_html/myphp/venv/lib/python3.12/site-packages/ezdxf/recover.pyr$   r$   >   sO    ( 8}H	hT	" /bBv.W/CL</ /s	   =Ac                F    t         j                  | |      }t        |      S )u(  Read a DXF document from a binary-stream similar to :func:`ezdxf.read`,
    but this function will detect the text encoding automatically and repair
    as many flaws as possible, runs the required audit process afterwards
    and returns the DXF document and the :class:`Auditor`.

    Args:
        stream: data stream to load in binary read mode
        errors: specify decoding error handler

            - "surrogateescape" to preserve possible binary data (default)
            - "ignore" to use the replacement char U+FFFD "�" for invalid data
            - "strict" to raise an :class:`UnicodeDecodeError` exception for invalid data

    Raises:
        DXFStructureError: for invalid or corrupted DXF structures
        UnicodeDecodeError: if `errors` is "strict" and a decoding error occurs

    r2   )Recoverrun_load_and_audit_document)streamr3   recover_tools      r:   r#   r#   Y   s!    & ;;vf;5L#L11    c                    t        |       } t        | d      5 }t        j                  ||t              }t        |      \  }}ddd       | _        |fS # 1 sw Y   xY w)uU  Read a DXF document from file system similar to :func:`readfile`,
    but this function will use a special tag loader, which tries to recover the
    tag stream if invalid tags occur.  This function is intended to load
    corrupted DXF files and should only be used to explore such files, data loss
    is very likely.

    Args:
        filename: file-system name of the DXF document to load
        errors: specify decoding error handler

            - "surrogateescape" to preserve possible binary data (default)
            - "ignore" to use the replacement char U+FFFD "�" for invalid data
            - "strict" to raise an :class:`UnicodeDecodeError` exception for invalid data

    Raises:
        DXFStructureError: for invalid or corrupted DXF structures
        UnicodeDecodeError: if `errors` is "strict" and a decoding error occurs

    r/   r0   )r3   loaderN)r4   r5   r<   r=   synced_bytes_loaderr>   r6   )r6   r3   r7   r@   r8   r9   s         r:   explorerE   p   sd    , 8}H	hT	" >b{{2f=P{Q/=W> CL<	> >s   +AA c                (   ddl m}  |       }|j                  | j                         t	        |      }| j
                  D ]  \  }}|j                  ||        | j                  D ]  \  }}|j                  ||        |j                          ||fS )Nr   r    )
ezdxf.documentr!   _load_section_dictsection_dictr   r3   	add_errorfixesfixed_errorr=   )r@   r!   r8   r9   codemsgs         r:   r>   r>      s    &
)C<445clG!(( %	c$$%!'' '	cD#&'KKM<rA   c                      e Zd ZdZdddZe	 	 d	 	 	 	 	 	 	 dd       ZddZddZddZ	ddZ
	 	 	 	 	 	 dd	Zdd
Zd Zd Zy)r<   zLoose coupled recovering tools.Nc                    |xs t         | _        t               | _        g | _        g | _        t        j                  | _        y N)	bytes_loader
tag_loaderdictrI   r3   rK   r   DXF12
dxfversion)selfrC   s     r:   __init__zRecover.__init__   s9    
 !0L ,06 .0,.
  ++rA   c                   t        |      }|j                  ||      }|j                  |      }|j                  |       |j                  j                  d      }|r |j                  |      }||j                  d<   |j                  dkD  r |j                          |j                          |j                  }|j                  dk  }	|j                         D ](  \  }
}|
dv st        |j                  ||	            ||
<   * |S )zExecute the recover process.TABLESAC1009>   BLOCKSrZ   OBJECTSENTITIES)r<   	load_tagsrebuild_sectionsload_section_dictrI   getrebuild_tablesrV   recover_rootdictfix_broken_layout_linksitemslistcheck_entities)clsr?   rC   r3   r@   tagssectionstablesrI   is_r12nameentitiess               r:   r=   zRecover.run   s    v%%ff5006&&x0**..x8!008F28L%%h/""X-))+002#00((H4*002 	ND(BB%) //&A&T"	 rA   c                H    t        || j                  | j                  |      S )Nmessagesr3   )safe_tag_loaderrS   r3   )rW   r?   r3   s      r:   r_   zRecover.load_tags   s     DOOdkk&
 	
rA   c                    	
 
 fd fd fd}	 fdg 	g 
g d|D ]  \  dk(  r |                  
j                  	       
S )aA  Collect tags between SECTION and ENDSEC or next SECTION tag
        as list of DXFTag objects, collects tags outside of sections
        as an extra section.

        Returns:
            List of sections as list of DXFTag() objects, the last section
            contains orphaned tags found outside of sections

        c                     rj                          n+j                  j                  t        j                  df       g  dy )Nz)DXF structure error: missing SECTION tag.F)appendrK   r   MISSING_SECTION_TAG)	collectorinside_sectionrk   rW   s   r:   close_sectionz/Recover.rebuild_sections.<locals>.close_section   sE     	* 

!!"66C I"NrA   c                     r2j                   j                  t        j                  df                 j                         dy )N(DXF structure error: missing ENDSEC tag.TrK   rv   r   MISSING_ENDSEC_TAG)rz   rx   ry   rW   tags   r:   open_sectionz.Recover.rebuild_sections.<locals>.open_section   sC    

!!"55B S!!NrA   c                     dk(  r         y dk(  r          y dk(  r6r3j                   j                  t        j                  df                 y y          y )Nr+   r(   r%   r|   r}   )rz   collectry   r   rW   values   r:   process_structure_tagz7Recover.rebuild_sections.<locals>.process_structure_tag   s]    	!("%!JJ%%&99F "O " 	rA   c                     rj                         y j                  j                  t        j                  d  d df       j                         y )Nz1DXF structure error: found tag outside section: (z, ))rv   rK   r   FOUND_TAG_OUTSIDE_SECTION)rM   rx   ry   orphansrW   r   r   s   r:   r   z)Recover.rebuild_sections.<locals>.collect  sY      %

!!"<< 6E7!- s#rA   Fr   rv   )rW   rj   r   rz   rM   r   rx   ry   r   r   rk   r   r   s   `  @@@@@@@@@@r:   r`   zRecover.rebuild_sections   sz    	# 	" 	"	 	"	$ 	$ !#')"$	 	CKD%qy%'		 	 rA   c                   
 d
fd}d fd}d fd}|j                         }|r|d   dk(  r|j                  |       g }t               
|D ]D  }|d   \  }}|dk(  r
 |||        j                  j                  t        j
                  df       F 
j                  d	t        dd
      t        dd	      g      }	 j                  |	|       t        |	       _
         j                  t        j                  k  r |
        |
       y)zMerge sections of same type.c                H    | v r|    j                  |dd         y || <   y )N   )extend)rn   rj   rI   s     r:   add_sectionz.Recover.load_section_dict.<locals>.add_section-  s.    |#T"))$qr(3%)T"rA   c                    | j                         D ]:  \  }}|t        j                  v st        t	        |d            j
                  |<   < y Nr   )rf   r   MANAGED_SECTIONSrg   r   rI   )drn   sectionrW   s      r:   _build_section_dictz6Recover.load_section_dict.<locals>._build_section_dict3  sH    !" Kg5111.2:gq3I.JD%%d+KrA   c                    dD ]9  }|| v s| |= j                   j                  t        j                  d| df       ; y )N)CLASSESr]   ACDSDATAzRemoved unsupported z section for DXF R12.)rK   rv   r   REMOVED_UNSUPPORTED_SECTION)r   rn   rW   s     r:   _remove_unsupported_sectionsz?Recover.load_section_dict.<locals>._remove_unsupported_sections8  sM    : 19$JJ%%&BB24&8MNrA   r   )r   r+      r   z>DXF structure error: missing section name tag, ignore section.HEADERr+   N)rn   r4   returnNone)r   rT   r   r   )r   rT   )poprv   rT   rK   r   MISSING_SECTION_NAME_TAG
setdefaultr   rescue_orphaned_header_vars_detect_dxf_versionrV   r   rU   )rW   rk   r   r   r   r   r   rM   rn   headerrI   s   `         @r:   ra   zRecover.load_section_dict*  s   	*	K
		 ,,.wqz^3OOG$G&*f 
	G JD$qyD'*

!!";;X
	 ((q)$q(#
 	((9-f5??ekk)(6L)rA   c                  	 d
	fd}t               	t        t              t        t        j
                        }D ]a  }|d   j                  j                         }|dk(  r$	 |d   j                  j                         }|	|<   I||v sN|   j                  |       c t        t        dd      t        dd      g      gt        t        j
                        }| j                  t        j                  k  r@|j                  d       dv r+| j                   j                  t"        j$                  d	f       |D ]
  } ||        S # t        t        f$ r Y w xY w)zRebuild TABLES section.c           	     ,   | vry j                  |       }|rj                  |       n0j                  t        t        dd      t        d|       g             j	                  |           j                  t        t        dd      g             y )Nr   r&   r   r)   )rb   rv   r   r   r   )rn   headcontentheadsrl   s     r:   append_tablez,Recover.rebuild_tables.<locals>.append_tablek  sz    7"99T?Dd# dF1g$6q$#HIJMM'$-(MM$q( 3456rA   r   r&   r   r+   r   rZ   BLOCK_RECORDz3Removed unsupported BLOCK_RECORD table for DXF R12.)rn   r4   )rT   r   rg   setr   TABLE_NAMES_ACAD_ORDERr   upper
IndexErrorAttributeErrorrv   r   r   rV   rU   removerK   r   REMOVED_UNSUPPORTED_TABLE)
rW   rl   r   valid_tablesentryrn   
table_namenamesr   r   s
    `      @@r:   rc   zRecover.rebuild_tablesd  sH   	7 d#5778 
	,E8>>'')Dw.!&q!5!5!7J ).E*%%$$U+
	, q),fQ.ABCDU112??ekk)LL((

!!"<<M  	D	- #N3 s   &EE E c                ~    d }|D ]6  }|\  }}|dk(  r|}||j                  |       |j                  |       d }8 y )N	   r   )rW   r   r   var_namer   rM   r   s          r:   r   z#Recover.rescue_orphaned_header_vars  sP      	 CKD%qy%h'c"	 rA   c              #     K   d}|D ]B  }|d   \  }}|t         v r| t        t        |            }|r|j                  |       | D y w)N)d   r   )EXCLUDE_STRUCTURE_CHECKr   r   remove_tags)rW   ro   rm   subclass_markersentity_dxftyperj   s           r:   rh   zRecover.check_entities  sa     ! 	FJAw11 6v>? $$%56
	s   AAc                l   | j                   j                  d      }|rt        |      dk  ry t        |d         ry t	        |      \  }}|rN|d   ||<   ||d<   	 |j                         }| j                  j                  t        j                  d| df       y y # t        j                  $ r d}Y Hw xY w)Nr]   r   r   r   z%Recovered misplaced root DICTIONARY(#z).)rI   rb   len_is_rootdict_find_rootdict
get_handler   DXFValueErrorrK   rv   r   MISPLACED_ROOT_DICT)rW   objectsindexrootdicthandles        r:   rd   zRecover.recover_rootdict  s    ##''	2#g,* 
#(1x$QZGEN!GAJ !,,. JJ22;F82F 
 &&   s   B B32B3c                     y)zFixes broke links (block_record_handle) between LAYOUT and BLOCK_RECORD
        entities. See issue #997 for more information.
        N )rW   s    r:   re   zRecover.fix_broken_layout_links  s     	rA   rQ   )rC   Optional[Callable])Nr-   )r?   r   rC   r   r3   r4   r   r<   )r?   r   r3   r4   r   Iterator[DXFTag])rj   Iterable[DXFTag]r   list[list[DXFTag]])rk   r   r   r   )rl   
list[Tags]r   r   )r   zlist[DXFTag]r   r   r   r   )ro   r   rm   boolr   zIterator[Tags])__name__
__module____qualname____doc__rX   classmethodr=   r_   r`   ra   rc   r   rh   rd   re   r   rA   r:   r<   r<      s    )&"  &*'	 # 	
 
 :

Sj8*t3j " -= 	 .rA   r<   c                    d}| D ]S  }|rGt        |d         j                         }t        j                  d|      r|c S  t        j
                  S |dk(  sRd}U t        j
                  S )NFr   z
AC[0-9]{4})r   z$ACADVERT)r4   stripre	fullmatchr   rU   )r   next_is_dxf_versionr   rV   s       r:   r   r     so     'SV**,J||M:6!! ;; /!"&' ;;rA   c                8    | d   dk7  ryt        d | D              S )Nr   )r   
DICTIONARYFc              3  &   K   | ]	  }|d k(    yw))   
ACAD_GROUPNr   ).0r   s     r:   	<genexpr>z_is_rootdict.<locals>.<genexpr>  s     :Cs'':s   )any)r   s    r:   r   r     s#    ay%%:6:::rA   c                b    t        |       D ]  \  }}t        |      s||fc S  dt               fS r   )	enumerater   r   )r   r   r   s      r:   r   r     s:    "7+ !v&= ! df9rA   c                   |t         }t        j                   ||       d      \  }}t        |      }t	        j
                  |      }t	        j                  |      }t	        j                  |      }t        ||||      S )u  Yields :class:``DXFTag`` objects from a bytes `stream`
    (untrusted external  source), skips all comment tags (group code == 999).

    - Fixes unordered and invalid vertex tags.
    - Pass :func:`synced_bytes_loader` as argument `loader` to brute force
      load invalid tag structure.

    Args:
        stream: input data stream as bytes
        loader: low level tag loader, default loader is :func:`bytes_loader`
        messages: list to store error messages
        errors: specify decoding error handler

            - "surrogateescape" to preserve possible binary data (default)
            - "ignore" to use the replacement char U+FFFD "�" for invalid data
            - "strict" to raise an :class:`UnicodeDecodeError` exception for invalid data

    r   rq   )	rR   	itertoolsteedetect_encodingr   tag_reorder_layerfilter_invalid_point_codesfilter_invalid_handlesbyte_tag_compiler)r?   rC   rr   r3   rj   detector_streamencodings          r:   rs   rs     st    0 ~%MM&.!<D//H ##D)D,,T2D((.DT8hvNNrA   z[+-]?\d+s   [+-]?\d+c                    t        j                  t        | t              rt        nt
        |       }|r|j                         } t        |       S )zEmulate the behavior of the C function stoll(), which just stop
    converting strings to integers at the first invalid char without raising
    an exception. e.g. "42xyz" is a valid integer 42

    )r   search
isinstancer4   INT_PATTERN_SINT_PATTERN_Bgroupintsress     r:   _search_intr     s;     ))#As+C IIKq6MrA   z#[+-]?\d+(:?\.\d*)?(:?[eE][+-]?\d+)?s#   [+-]?\d+(:?\.\d*)?(:?[eE][+-]?\d+)?c                    t        j                  t        | t              rt        nt
        |       }|r|j                         } t        |       S )zEmulate the behavior of the C function stod(), which just stop
    converting strings to doubles at the first invalid char without raising
    an exception. e.g. "47.11xyz" is a valid double 47.11

    )r   r   r   r4   FLOAT_PATTERN_SFLOAT_PATTERN_Br   floatr   s     r:   _search_floatr  )  s;     ))%a-?AC IIK8OrA   c           	   #    K   d}d}| j                   }|s[ |       }|r	 t        |      }ny	 |       }|r6|j                  d
      }|dk(  r|dk(  rd}|dk7  rt        ||       |dz  }ny	|sZy	y	# t        $ rZ 	 t        |      }nJ# t        $ r> |j	                  d      j                  d      }t        j                  d| d| d      w xY wY w xY ww)a  Yields :class:``DXFTag`` objects from a bytes `stream`
    (untrusted external  source), skips all comment tags (group code == 999).

    ``DXFTag.code`` is always an ``int`` and ``DXFTag.value`` is always a
    raw bytes value without line endings. Works with file system streams and
    :class:`BytesIO` streams.

    Raises:
        DXFStructureError: Found invalid group code.

    Fr   ignorer2   z
zInvalid group code "z
" at line .N   
r   s   EOFT  r   )	readliner   
ValueErrorr   decoderstripr   DXFStructureErrorr   )r?   eofliner  rM   r   s         r:   rR   rR   7  s      CDHz	4y 
LL)EqyUf_s{T5))AID7   &t,D! ;;h;7>>vFD11.tfJtfAF  sG   CA1 AC/C1	C;BCACCCCCc              #    K   d}t         dz   }| j                  }	 d}|r* |       }|r	 t        |      }d|cxk  r|k  rn nd}ny|r* |       }|r#|dk7  rt	        ||j                  d             ny\# t        $ r Y <w xY ww)a=  Yields :class:``DXFTag`` objects from a bytes `stream`
    (untrusted external source), skips all comment tags (group code == 999).

    ``DXFTag.code`` is always an ``int`` and ``DXFTag.value`` is always a
    raw bytes value without line endings. Works with file system streams and
    :class:`BytesIO` streams.

    Does not raise DXFStructureError on invalid group codes, instead skips
    lines until a valid group code or EOF is found.

    This can remove invalid lines before group codes, but can not
    detect invalid lines between group code and tag value.

    r  r   Tr   FNr  )r   r  r   r  r   r
  )r?   rM   upper_boundaryr  seeking_valid_group_coder   s         r:   rD   rD   e  s      D#a'NH
#' &:D9&t,D D1>1380 ' 
s{T5<<#899'  " s-   &BA7 B	.B7	B BBBs   $DWGCODEPAGEs   $ACADVERc                    t        t        j                        }dj                  | D cg c]	  }||vs| c}      S c c}w )N )r   string
whitespacejoin)r   wscs      r:   _strip_whitespacer    s5    	V	B77q0!ARKA0110s   	>>c                   d}d}d}| D ]  \  }}|dk(  r |t         k(  rt         }nx|t        k(  rot        }nh|dk(  r4|t         k(  r+t        |j                  t        j
                              }d}n/|dk(  r*|t        k(  r!|j                  t        j
                        }d}|s|s|t        j                  k\  rdc S |c S  t        j
                  S )a  Detect text encoding from header variables $DWGCODEPAGE and $ACADVER
    out of a stream of DXFTag objects.

    Assuming a malformed DXF file:

    The header variables could reside outside of the HEADER section,
    an ENDSEC tag is not a reliable fact that no $DWGCODEPAGE or
    $ACADVER header variable will show up in the remaining tag stream.

    Worst case: DXF file without a $ACADVER var, and a $DWGCODEPAGE
    unequal to "ANSI_1252" at the end of the file.

    Nr   r   r   utf8)DWGCODEPAGEACADVERr   r	  r   DEFAULT_ENCODINGDXF2007)rj   r   rV   next_tagrM   r   s         r:   r   r     s     HJH Ge19#&'!"QY8{2!%,,u/E/E"FGHHQY8w.e&<&<=JH
'5==86FhFG  !!!rA   c              #    K   fd}dfd}dfd}t        t              sJ t        |t              sJ g t        |       } d}d	 	 ||}d}nt        |       }dz  |j                  }	|	t
        v rt        |       }
dz  |
j                  |	dz   k7  rt        j                  d d	      t        |       }dz  	 |j                  |	d
z   k(  r@	 t        |j                        t        |
j                        t        |j                        f}n-	 t        |j                        t        |
j                        f}|}t        |	|       n|	t        v r9t        |t              r|}n!	 t        j                  |	|j                        }| nt        j                   |	t              }|j                  }|t        u r|	dk(  r(|j                  j#                         j%                         }	 |j'                  d      }|	r-t1        |      rt3        |      }nt5        |      rt7        |      }t9        |	|       n	 t9        |	 ||             # t        $ r9  ||j                         ||
j                         ||j                        f}Y Vw xY w# t        $ r(  ||j                         ||
j                        f}Y w xY w# t        $ r t        j                  d d	      w xY w# t        $ r t        j                  d d	      w xY w# t(        $ r; |j'                  |      }j+                  t,        j.                  d f       Y ]w xY w# t        $ r |t:        u rH	 t9        |	 ||j                               n# t        $ r t        j                   ||            w xY w|t        u rH	 t9        |	 ||j                               nC# t        $ r t        j                   ||            w xY wt        j                   ||            Y w xY w# t<        $ r Y yw xY ww)u`  Compiles DXF tag values imported by bytes_loader() into Python types.

    Raises DXFStructureError() for invalid float values and invalid coordinate
    values.

    Expects DXF coordinates written in x, y[, z] order, see function
    :func:`safe_tag_loader` for usage with applied repair filters.

    Args:
        tags: DXF tag generator, yielding tag values as bytes like bytes_loader()
        encoding: text encoding
        messages: list to store error messages
        errors: specify decoding error handler

            - "surrogateescape" to preserve possible binary data (default)
            - "ignore" to use the replacement char U+FFFD "�" for invalid data
            - "strict" to raise an :class:`UnicodeDecodeError` exception for invalid data

    Raises:
        DXFStructureError: Found invalid DXF tag or unexpected coordinate order.

    c                j    | j                   }| j                  j                        }d| d| d dS )NzInvalid tag (z, "z") near line: r  )rM   r   r	  )r   rM   r   r   r  s      r:   	error_msgz$byte_tag_compiler.<locals>.error_msg  s;    xx		  *tfCwnTF!DDrA   c                    t        | t              r| j                  dd      } t        |       }d|  d d| d}j	                  t
        j                  |f       t        j                  |       |S )Nr  r  r   r3   z!recovered invalid integer value "" near line  as "")	r   bytesr	  r   rv   r   INVALID_INTEGER_VALUEloggerwarningr   r   rN   r  rr   s      r:   recover_intz&byte_tag_compiler.<locals>.recover_int  sk    a&:AA1!LeE7RST993?@srA   c                    t        | t              r| j                  dd      } t        |       } t	        |       }d|  d d| d}j                  t        j                  |f       t        j                  |       |S )Nr  r  r$  z(recovered invalid floating point value "r%  r&  r'  )
r   r(  r	  r  r  rv   r   INVALID_FLOATING_POINT_VALUEr*  r+  r,  s      r:   recover_floatz(byte_tag_compiler.<locals>.recover_float  sx    a&:Aa a 8<vUSXRYYZ[@@#FGsrA   Nr   r   
   z)Missing required y-coordinate near line: r     z)Invalid floating point values near line: zInvalid binary data near line: strictr2   z'Fixed unicode decoding error near line r   Union[str, bytes]r   r   r   r5  r   r   )r   r4   iternextrM   r   r   r  r   r   r  r   r   r   from_stringr   rb   r   r   r	  UnicodeDecodeErrorrv   r   DECODING_ERRORr   r   r   r   r   r   StopIteration)rj   r   rr   r3   r"  r-  r0  undo_tagxrM   yzpointr   type_r   str_r  s    ``              @r:   r   r     s    <E
 h$$$fc""":DHD
j	#J	66D{"J	66TBY&11CD6K  J	vv* %agg %agg %agg%E%*177^U177^$DE $%
  e,,$a.C*66tQWWE
 	"tS1 wwC<qy ! 5 5 7	$||HX|F *40#5d#;D-d3#8#>D t,,H$T5<88w :  *  -agg 6 -agg 6 -agg 6%E  *  -agg 6 -agg 6%E " 11CD6K  & #55=dV1E  . $||HV|D  * 9 9"I$ P, & H C<L&,T;qww3G&H H#- L&+&=&=il&K KL"e^L&,T=3I&J J#- L&+&=&=il&K KL #("9"9)A,"GGH  		s  AQA6P5 
K >I K *J# K 	+P5 5 K= A P5 6L# 	>P5 M* Q>J K J  K #-KK KK #K::P5 =#L  P5 #A M'#P5 &M''P5 *P2<NP2%O  P2O+*P2+%PP2.P5 1P22P5 5	Q>Q QQ)r-   )r6   zUnion[str, Path]r3   r4   r   tuple[Drawing, Auditor])r?   r   r3   r4   r   rD  )r  )r   rD  )r   rg   r   r4   )r   r   r   r   )r   r   r   ztuple[int, Tags])NNr-   )
r?   r   rC   r   rr   Optional[list]r3   r4   r   r   r4  r6  )r?   r   r   r   )r   r4   r   r4   )rj   r   r   r4   )rj   r   rr   rE  r3   r4   r   r   )M
__future__r   r  typingr   r   r   r   r   r	   r
   r   r   collectionsr   pathlibr   loggingezdxf.lldxfr   r   ezdxf.lldxf.encodingr   r   r   r   ezdxf.lldxf.typesr   r   r   r   r   r   r   ezdxf.lldxf.tagsr   r   ezdxf.lldxf.validatorr   ezdxf.tools.codepager   ezdxf.auditr   r   rG   r!   ezdxf.eztypesr"   __all__r   	getLoggerr*  r$   r#   rE   r>   r<   r   r   r   rs   compiler   r   r   r   r   r  no_type_checkrR   rD   r  r  r  r   r  r   r   rA   r:   <module>rW     s   #      	 #        . < + +&):
  
		7	# /@(+620 /7(+< r rj	; "&##	!O!O!O !O 	!O
 !OH 

;'

<( "**CD"**DE * *Z%P 
2
""J  ####	h
h h 	h
 h hrA   