
    Ogh'                       d dl mZ d dlmZmZmZmZmZ d dlZd dl	Z	d dl
Z
d dlZd dlmZ d dlmZ d dlmZ erd dlmZ edd	f	 	 	 	 	 	 	 dd
ZddZ	 	 d	 	 	 	 	 	 	 ddZddZddZ	 	 d	 	 	 	 	 	 	 ddZdddZ	 d	 	 	 	 	 ddZy)    )annotations)TextIOTYPE_CHECKINGUnionSequenceOptionalN)setup_drawing)DXF2013Drawing)DXFInfoF   c                    t        j                  |       }||_        |dv rdnd|j                  d<   |rt	        ||       |S )a  Create a new :class:`~ezdxf.drawing.Drawing` from scratch, `dxfversion`
    can be either "AC1009" the official DXF version name or "R12" the
    AutoCAD release name.

    :func:`new` can create drawings for following DXF versions:

    ======= ========================
    Version AutoCAD Release
    ======= ========================
    AC1009  AutoCAD R12
    AC1015  AutoCAD R2000
    AC1018  AutoCAD R2004
    AC1021  AutoCAD R2007
    AC1024  AutoCAD R2010
    AC1027  AutoCAD R2013
    AC1032  AutoCAD R2018
    ======= ========================

    The `units` argument defines th document and modelspace units. The header
    variable $MEASUREMENT will be set according to the given `units`, 0 for
    inch, feet, miles, ... and 1 for metric units. For more information go to
    module :mod:`ezdxf.units`

    Args:
        dxfversion: DXF version specifier as string, default is "AC1027"
            respectively "R2013"
        setup: setup default styles, ``False`` for no setup,
            ``True`` to setup everything or a list of topics as strings,
            e.g. ["linetypes", "styles"] to setup only some topics:

            ================== ========================================
            Topic              Description
            ================== ========================================
            linetypes          setup line types
            styles             setup text styles
            dimstyles          setup default `ezdxf` dimension styles
            visualstyles       setup 25 standard visual styles
            ================== ========================================
        units: document and modelspace units, default is 6 for meters

    )            	   
   r   r   z$MEASUREMENT)topics)r   newunitsheaderr	   )
dxfversionsetupr   docs       Y/var/www/html/public_html/myphp/venv/lib/python3.12/site-packages/ezdxf/filemanagement.pyr   r      sD    \ ++j
!CCI&+/B&BCJJ~c%(J    c                2    ddl m}  |j                  |       S )aC  Read a DXF document from a text-stream. Open stream in text mode
    (``mode='rt'``) and set correct text encoding, the stream requires at least
    a :meth:`readline` method.

    Since DXF version R2007 (AC1021) file encoding is always "utf-8",
    use the helper function :func:`dxf_stream_info` to detect the required
    text encoding for prior DXF versions. To preserve possible binary data in
    use :code:`errors='surrogateescape'` as error handler for the import stream.

    If this function struggles to load the DXF document and raises a
    :class:`DXFStructureError` exception, try the :func:`ezdxf.recover.read`
    function to load this corrupt DXF document.

    Args:
        stream: input text stream opened with correct encoding

    Raises:
        DXFStructureError: for invalid or corrupted DXF structures

    r   r   )ezdxf.documentr   read)streamr   s     r   r!   r!   H   s    * '7<<r   c                    ddl m}m} ddlm} ddlm} t        |       }  ||       rNt        | d      5 }|j                         } |||      }	t        j                  |	      }
| |
_        |
cddd       S  ||       st        d|  d	      t        |       }|||_        t        | d
|j                  |      5 }t        |      }
ddd       | 
_        | ||      r||
_        |
S # 1 sw Y   {xY w# 1 sw Y   /xY w)u:  Read the DXF document `filename` from the file-system.

    This is the preferred method to load existing ASCII or Binary DXF files,
    the required text encoding will be detected automatically and decoding
    errors will be ignored.

    Override encoding detection by setting argument `encoding` to the
    estimated encoding. (use Python encoding names like in the :func:`open`
    function).

    If this function struggles to load the DXF document and raises a
    :class:`DXFStructureError` exception, try the :func:`ezdxf.recover.readfile`
    function to load this corrupt DXF document.

    Args:
        filename: filename of the ASCII- or Binary DXF document
        encoding: use ``None`` for auto detect (default), or set a specific
            encoding like "utf-8", argument is ignored for Binary DXF files
        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:
        IOError: not a DXF file or file does not exist
        DXFStructureError: for invalid or corrupted DXF structures
        UnicodeDecodeError: if `errors` is "strict" and a decoding error occurs

    r   )is_dxf_fileis_binary_dxf_file)is_supported_encoding)binary_tags_loaderrberrorsNzFile 'z' is not a DXF file.rtmodeencodingr*   )ezdxf.lldxf.validatorr$   r%   ezdxf.tools.codepager&   ezdxf.lldxf.taggerr'   stropenr!   r   loadfilenameIOErrordxf_file_infor.   )r5   r.   r*   r$   r%   r&   r'   fpdataloaderr   infos               r   readfiler<   b   s   F F:58}H(#(D! 	R779D'V<F,,v&C#CL	 	 x xj(<=>>"D 	hTDMM&	I R2h CL 5h ?  J/	 	 s   8C(:C4(C14C=c                x    t        |       } t        | ddd      5 }t        |      cddd       S # 1 sw Y   yxY w)zbReads basic file information from a DXF document: DXF version, encoding
    and handle seed.

    r+   utf-8ignorer,   N)r2   r3   dxf_stream_info)r5   r8   s     r   r7   r7      s:    
 8}H	hTGH	E #r"# # #s   09c                N    ddl m}  ||       }|j                  dk\  rd|_        |S )z`Reads basic DXF information from a text stream: DXF version, encoding
    and handle seed.

    r   )dxf_infoAC1021r>   )r/   rB   versionr.   )r"   rB   r;   s      r   r@   r@      s)    
 /FD||xKr   c                    ddl m}  |t        |       ||      5 }t        |      }|j                  |_        ddd       |S # 1 sw Y   S xY w)ut  Load a DXF document specified by `filename` from a zip archive, or if
    `filename` is ``None`` the first DXF document in the zip archive.

    Args:
        zipfile: name of the zip archive
        filename: filename of DXF file, or ``None`` to load the first DXF
            document from the zip archive.
        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:
        IOError: not a DXF file or file does not exist or
            if `filename` is ``None`` - no DXF file found
        DXFStructureError: for invalid or corrupted DXF structures
        UnicodeDecodeError: if `errors` is "strict" and a decoding error occurs

    r   )ctxZipReaderr)   N)ezdxf.tools.zipmanagerrF   r2   r!   dxf_file_namer5   )zipfiler5   r*   rF   	zipstreamr   s         r   readziprK      sM    2 4	c'lHV	< /	9o ../ J/ Js   AAc                t   t        j                  |       }|j                  dd      }|j                  dd      }t	        j
                  |      }t        |      }|j                          |j                  |j                  |      }t	        j
                  |      }t        |      }|j                          |S )um  Load a DXF document from base64 encoded binary data, like uploaded data
    to web applications.

    Args:
        data: DXF document base64 encoded binary data
        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

    s   
   
r>   r?   r)   )
base64	b64decodereplacedecodeioStringIOr@   closer.   r!   )r9   r*   binary_datatextr"   r;   r   s          r   decode_base64rW      s    ( ""4(K %%gu5K
 gh7D[[F6"D
LLN dmmF;D[[F v,C
LLNJr   c                   t        j                  |       j                         r| S |g }|D ]V  }|j                  d      }t        j                  |      j	                         | z  }|j                         sKt        |      c S  | S )z1Find file `filename` in the support directories`.z"')pathlibPathexistsstrip
expanduserr2   )r5   support_dirs	directoryfilepaths       r   find_support_filera   	  s}     ||H$$&! !	OOE*	<<	*557(B??x= 	!
 Or   )r   r2   r   zUnion[str, bool, Sequence[str]]r   intreturnr   )r"   r   rc   r   )Nsurrogateescape)r5   str | os.PathLiker.   Optional[str]r*   r2   rc   r   )r5   re   rc   r   )r"   r   rc   r   )rI   re   r5   rf   r*   r2   rc   r   )rd   )r9   bytesr*   r2   rc   r   )N)r5   r2   r^   zOptional[Sequence[str]]rc   r2   )
__future__r   typingr   r   r   r   r   rN   rR   rY   osezdxf.tools.standardsr	   ezdxf.lldxf.constr
   r    r   r/   r   r   r!   r<   r7   r@   rK   rW   ra    r   r   <module>rn      s   # C C  	  	 / % "- -233*3 3 	3l 8 ##@@@ @ 	@F#  ##  	B(X <@!8r   