
    hI^                       S SK Jr  S SKJrJrJrJrJrJr  S SK	r	S SK
r
S SKJr  S SKJr  S SKJrJrJr  S SKJrJr  S SKJr  \(       a  S S	KJr  S S
KJr  S SKJr  SS/r\	R>                  " S5      r Sr!Sr"SSSSS.r#\$" / SQ5      r% " S S5      r&        S,S jr'1 Skr( " S S5      r)SSSSSS S!S"S#S$S%S&S'S(S)S*.r*S-S+ jr+g).    )annotations)AnyOptionalUnionIterableTYPE_CHECKINGSetN)options)const)XTypeDXFAttributesDXFAttr)
cast_valuedxftag)Tags)ExtendedTags)	DXFEntity)AbstractTagWriterDXFNamespaceSubclassProcessorezdxfz(Invalid DXF attribute "{}" for entity {}z!DXF attribute "{}" does not existon_layer_changeon_linetype_changeon_style_changeon_dimstyle_change)layerlinetypestyledimstyle)_entityhandleownerc                     \ rS rSrSr  S    S!S jjrS"S jrS#S$S jjrS%S jrS&S jr	S	 r
  S        S'S
 jjrS(S jrS)S jrS*S jrS#S+S jjrS(S jrS)S jrS)S jrS,S jrSSS.     S-S jjrS*S jrS.S jrS.S jr\S/S j5       r\S0S j5       rS(S jr      S1S jr      S2S jr      S2S jrSrg)3r   '   ab  :class:`DXFNamespace` manages all named DXF attributes of an entity.

The DXFNamespace.__dict__ is used as DXF attribute storage, therefore only
valid Python names can be used as attrib name.

The namespace can only contain immutable objects: string, int, float, bool,
Vec3. Because of the immutability, copy and deepcopy are the same.

(internal class)
Nc                d   U(       a  UR                   nUS   R                  S:X  a  SOSnS nS nU HH  nUR                  nX:X  a  UR                  nU(       a    O#M+  US:X  d  M3  UR                  nU(       d  MH    O   U R                  X%U5        g U R	                  5         U R                  U5        g )Nr   DIMSTYLEi      J  )
base_classvaluecoderewirereset_handles)	self	processorentityr*   handle_coder!   r"   tag
group_codes	            F/var/www/html/env/lib/python3.13/site-packages/ezdxf/entities/dxfns.py__init__DXFNamespace.__init__3   s    
 "--J!+A!4!4
!B#K FE! XX
, YYF 3&IIEv " KK. KK    c                    U R                  5       nU R                  R                  5        H  u  p4XBR                  U'   M     UR                  U5        U$ N)	__class____dict__itemsr-   )r/   r1   	namespacekvs        r5   copyDXFNamespace.copyO   sI    NN$	MM'')DA$%q! * r8   c                8    U R                  U R                  5      $ r:   )rA   r    )r/   memodicts     r5   __deepcopy__DXFNamespace.__deepcopy__V   s    yy&&r8   c                    U R                   $ r:   r<   r/   s    r5   __getstate__DXFNamespace.__getstate__Y   s    }}r8   c                    [        U[        5      (       d!  [        S[        U5      R                   35      e[
        R                  U SU5        g )Nzinvalid state: r<   )
isinstancedict	TypeErrortype__name__object__setattr__)r/   states     r5   __setstate__DXFNamespace.__setstate__\   s>    %&&od5k.B.B-CDEE4U3r8   c                @    SU R                   S'   SU R                   S'   g)zReset handle and owner to None.Nr!   r"   rH   rI   s    r5   r.   DXFNamespace.reset_handlesb   s    "&h!%gr8   c                f    XR                   S'   Ub  X R                   S'   Ub  X0R                   S'   gg)zRewire DXF namespace with parent entity

Args:
    entity: new associated entity
    handle: new handle or None
    owner:  new entity owner handle or None

r    Nr!   r"   rH   )r/   r1   r!   r"   s       r5   r-   DXFNamespace.rewireg   s9     $*i &,MM(#%*MM'" r8   c                6   U R                   R                  U5      nU(       aE  UR                  [        R                  :X  a  UR                  U R                  5      $ UR                  $ [        R                  " [        R                  XR                  5      5      e)zCalled if DXF attribute `key` does not exist, returns the DXF
default value or ``None``.

Raises:
    DXFAttributeError: attribute `key` is not supported

)
dxfattribsgetxtyper   callbackget_callback_valuer    defaultr   DXFAttributeErrorERR_INVALID_DXF_ATTRIBformatdxftype)r/   key
attrib_defs      r5   __getattr__DXFNamespace.__getattr__|   ss     )-(;(;C(@
5>>1!44T\\BB!)))))&--c<<@ r8   c                  ^ ^^^ SU 4S jjmUUU4S jnT R                   R                  T5      mT(       aQ  TR                  [        R                  :X  a  TR                  T R                  U5        OJU" U5      T R                  T'   O4[        R                  " [        R                  TT R                  5      5      eT[        ;   a/  [        T R                  [        T   S5      nU(       a	  U" U5        ggg)fSet DXF attribute `key` to `value`.

Raises:
    DXFAttributeError: attribute `key` is not supported

c                    > TR                  S5      n TR                  nU(       a  UR                  5       SU  S3-   $ SU  3$ )Nr!   z(#)#)r]   r    re   )r!   r    r/   s     r5   r1   (DXFNamespace.__setattr__.<locals>.entity   sC    XXh'FllG(Rxq>996(|#r8   c           
     ^  > [        TR                  U 5      n TR                  U 5      (       d  TR                  (       a@  TR                  U 5      n [        R                  ST ST" 5        S[        U 5       S35        U $ [        R                  " S[        U 5       ST ST" 5        S35      eU $ )NzFixed invalid attribute "z" in entity z to "z".zInvalid value z for attribute ".)	r   r,   is_valid_valuefixerloggerdebugstrr   DXFValueError)r+   rg   r1   rf   s    r5   check'DXFNamespace.__setattr__.<locals>.check   s    z6E,,U33##&,,U3ELL3C5 9"H:U3u:,b: L	  --(U4DSE J""((1.  Lr8   Nreturnrv   )r\   r]   r^   r   r_   set_callback_valuer    r<   r   rb   rc   rd   re   SETTER_EVENTSgetattr)r/   rf   r+   rx   handlerrg   r1   s   ``   @@r5   rS   DXFNamespace.__setattr__   s    	$	  )-(;(;C(@
5>>1--dllEB%*5\c"))&--c4<<@  -dllM#,>EG   r8   c                    U R                  U5      (       a  U R                  U	 g[        R                  " [        R                  U5      5      e)z\Delete DXF attribute `key`.

Raises:
    DXFAttributeError: attribute `key` does not exist

N)hasattrr<   r   rb   ERR_DXF_ATTRIB_NOT_EXITSrd   r/   rf   s     r5   __delattr__DXFNamespace.__delattr__   s<     <<c"))*B*I*I#*NOOr8   c                l   U R                  U5      (       a  U R                  U   $ U R                  R                  U5      nU(       a;  UR                  [
        R                  :X  a  UR                  U R                  5      $ U$ [        R                  " [        R                  XR                  5      5      e)zReturns value of DXF attribute `key` or the given `default` value
not DXF default value for unset attributes.

Raises:
    DXFAttributeError: attribute `key` is not supported

)r   r<   r\   r]   r^   r   r_   r`   r    r   rb   rc   rd   re   )r/   rf   ra   rg   s       r5   r]   DXFNamespace.get   s     <<==%%*.//*=*=c*B
5>>1!44T\\BB))&--c<<@ r8   c                R    U R                  US5      nUc  U R                  U5      $ U$ )z8Returns DXF default value for unset DXF attribute `key`.N)r]   dxf_default_valuer/   rf   r+   s      r5   get_defaultDXFNamespace.get_default   s,    d#.3mt%%c*FFr8   c                &    U R                  X5        g)rk   N)rS   r   s      r5   setDXFNamespace.set   s     	$r8   c                     X R                   U'   g)zSet DXF attribute `key` to `value` without any validity checks.

Used for fast attribute setting without validity checks at loading time.

(internal API)
NrH   r   s      r5   unprotected_setDXFNamespace.unprotected_set   s     #cr8   c                6    [        U R                  5      nUS	 U$ )z@Returns all existing DXF attributes, except DXFEntity back-link.r    )rN   r<   )r/   attribss     r5   all_existing_dxf_attribs%DXFNamespace.all_existing_dxf_attribs   s    t}}%Ir8   F)excludeignore_errorsc                   Uc  [         nOS1U-  nU R                  nUR                  5        H  u  pVXR;  d  M   U" XV5        M     g! [        [        4 a    U(       d  e  M5  f = f)z,Update DXF namespace attributes from a dict.Nr    )EXCLUDE_FROM_UPDATErS   r=   AttributeError
ValueError)r/   r\   r   r   set_attributer?   r@   s          r5   updateDXFNamespace.update   sn     ?)G kG+G(($$&DA!!' ' '
3 ( )s   AA#"A#c                @     U R                   U	 g! [         a     gf = f)z:Delete DXF attribute `key` silently without any exception.N)r<   KeyErrorr   s     r5   discardDXFNamespace.discard  s%    	c" 		s    
c                    XR                   ;   $ )zReturns True if DXF attribute `key` is supported else False.
Does not grant that attribute `key` really exists and does not
check if the actual DXF version of the document supports this
attribute, unsupported attributes will be ignored at export.

)r\   r   s     r5   is_supportedDXFNamespace.is_supported  s     oo%%r8   c                    XR                   ;   $ )z9Returns True if attribute `key` really exists else False.rH   r   s     r5   r   DXFNamespace.hasattr&  s    mm##r8   c                .    U R                   R                  $ )zReturns the DXF entity type.)r    DXFTYPErI   s    r5   re   DXFNamespace.dxftype*  s     ||###r8   c                .    U R                   R                  $ )z%Returns the DXF attribute definition.)r    
DXFATTRIBSrI   s    r5   r\   DXFNamespace.dxfattribs/  s     ||&&&r8   c                `    U R                   R                  U5      nU(       a  UR                  $ g)z9Returns the default value as defined in the DXF standard.N)r\   r]   ra   )r/   rf   attribs      r5   r   DXFNamespace.dxf_default_value4  s&    $(OO$7$7$<>>!r8   c                    [        U[        5      (       a  U R                  X5        gU H  nU R                  X5        M     g)aj  Exports DXF attribute `name` by `tagwriter`. Non-optional attributes
are forced and optional tags are only written if different to default
value. DXF version check is always on: does not export DXF attribs
which are not supported by tagwriter.dxfversion.

Args:
    tagwriter: tag writer object
    attribs: DXF attribute name as string or an iterable of names

N)rM   rv   _export_dxf_attribute_optional)r/   	tagwriterr   names       r5   export_dxf_attribsDXFNamespace.export_dxf_attribs<  s7     gs##//	C33ID  r8   c                   U R                   R                  U5      nUc3  [        R                  " [        R                  X R                  5      5      eUR                  nUR                  nU R                  US5      nUc	  U(       d  UnUc  [        R                  SU S35        gU(       a  UR                  (       d	  Ub  XV:X  a  g[        XU5        g)zuExports DXF attribute `name` by `tagwriter`.

Optional tags are only written if they differ from the default value.

NDXF attribute ''' not written because its a None value.)r\   r]   r   rb   rc   rd   re   optionalra   rt   ru   force_optional_export_group_codes)r/   r   r   r   r   ra   r+   s          r5   r   +DXFNamespace._export_dxf_attribute_optionalO  s     %)OO$7$7$=>))&--dLLA  ??..t$ =E=LL!$'NO  --# Iu5r8   c                    U R                  U5      (       d  gU R                  R                  U5      nUc   SU S35       eU R                  U5      nUc  [        R	                  SU S35        g[        XU5        g)a#  Exports DXF attribute `name` by `tagwriter` if exists.

If the attribute exists, and it's not None it will be written, the optional-flag
is ignored.

No default value will be written if the attribute doesn't exist!
This method can not be used for attributes that are required (e.g. layer)!

Nzexisting DXF attribute 'z*' has no definition class - internal errorr   r   )r   r\   r]   rt   ru   r   )r/   r   r   r   r+   s        r5   export_dxf_attribute_if_exists+DXFNamespace.export_dxf_attribute_if_existsv  s     ||D!!$(OO$7$7$=	W%dV+UV	W =LL!$'NO Iu5r8    )NN)r0   zOptional[SubclassProcessor]r1   Optional[DXFEntity])r1   r   r:   )rD   zOptional[dict])r{   rR   )rT   rR   r{   None)r1   r   r!   Optional[str]r"   r   r{   r   )rf   rv   r{   r   )rf   rv   r+   r   r{   r   )rf   rv   r{   r   )rf   rv   ra   r   r{   r   )r{   rN   )r\   zdict[str, Any]r   zOptional[Set[str]]r{   r   )rf   rv   r{   boolrz   )r{   r   )r   r   r   zUnion[str, Iterable]r{   r   )r   r   r   rv   r{   r   ) rQ   
__module____qualname____firstlineno____doc__r6   rA   rE   rJ   rU   r.   r-   rh   rS   r   r]   r   r   r   r   r   r   r   r   propertyre   r\   r   r   r   r   __static_attributes__r   r8   r5   r   r   '   s^   	 26&* .  $ 8'4& !%#	+#+ + 	+
 
+*&/b
P.G
%# '+" $	 
,&$ $ $ ' 'E*E5IE	E&%6*%625%6	%6N6*6256	6r8   c                   Uc   eUc   eU R                   UR                   :  a  g UR                  [        R                  :X  a(  [	        U5      S:  a   UR
                  UR                  4n[        U[        5      (       a  SU;  d   S5       eSU;  d   S5       e[        UR                  U5      nU R                  U5        g ! [         a    US S n Nhf = f)N   
zline break '\n' not allowedzline break '\r' not allowed)
dxfversionr^   r   point2dlenxyr   rM   rv   r   r,   	write_tag)r   r   r+   r3   s       r5   r   r     s      f/// ||u}}$Ua	WWegg&E %5 @"@@ 5 @"@@ 
e
$C  	"1IE	s   C CC>   r   r(   r)   f   c                      \ rS rSrSrSSS jjr\S 5       r  S     SS jjrSS jr	SS jr
        SS	 jrS
SS.       SS jjrSS jr      SS jrSrg)r   i  z=Helper class for loading tags into entities. (internal class)Nc                   [        UR                  5      S:X  a  [        S5      e[        UR                  5      U l        UR                  =(       d    / U l        X l        U[        R                  :H  =(       d    [        U R                  5      S:H  U l        UR                  5       U l
        U    UR                  5       U l        g ! [        R                   a
    SU l         g f = f)Nr   zInvalid tags.   <?>)r   
subclassesr   listembedded_objectsr   r   DXF12r12re   r   
get_handler!   rw   )r/   tagsr   s      r5   r6   SubclassProcessor.__init__  s    t1$_--&*4??&;,0,A,A,GR)3 %3ST__9MQR9R		 //+DK"" 	 DK	 s   .C C"!C"c                     U R                   S   $ Nr   )r   rI   s    r5   r*   SubclassProcessor.base_class  s    q!!r8   c                    [         R                  (       a?  U H8  nSnU(       a  SU 3n[        R                  S[	        U5       SU 3U-   5        M:     g g )N z in entity #zignored z in subclass )r
   log_unprocessed_tagsrt   inforepr)r/   unprocessed_tagssubclassr!   r3   r1   s         r5   r   &SubclassProcessor.log_unprocessed_tags  sR     '''+F84FhtCykxjIFRS	 ( (r8   c                |    U R                    H,  n[        U5      (       d  M  US   R                  U:X  d  M*  Us  $    g r   )r   r   r+   )r/   r   r   s      r5   find_subclassSubclassProcessor.find_subclass  s4    H8}}!!2!2d!: ( r8   c                B     U R                   U   $ ! [         a     g f = fr:   )r   
IndexError)r/   indexs     r5   subclass_by_index#SubclassProcessor.subclass_by_index  s(    	??5)) 		s    
c                    U R                  U5      nU(       a0  [        U5      S:  a!  US   nUR                  U:X  a  UR                  $ U$ )Nr   )r   r   r,   r+   )r/   subclass_indexr4   ra   r   r3   s         r5   detect_implementation_version/SubclassProcessor.detect_implementation_version  sF     )).9H)1+Cxx:%yy r8   FT)recoverlogc                  U R                   (       a  U R                  S   nOP[        U[        5      (       a  U R	                  U5      nO)[        U[
        5      (       a  U R                  U5      nOUn[        5       nUb  [        U5      S:X  a  U$ [        5       nUR                  n	UR                  n
UR                  nUR                  nUS   R                  S;   a  SOSnXmS  H  nU	" UR                  5      n[        U[        5      (       a  UnSnU H  nUU;  d  M  UnU" U5          O   U(       a4  US   S:w  a)  U" U[!        UR                  UR"                  5      5        M  M  U
" U5        M     U R                   (       a  U$ U(       a  [        U5      (       a  [%        Xq5      n[        U5      (       a5  U(       a.  US   R"                  nU R'                  XoUR                  S5      S9  U$ )a  Load DXF attributes into the DXF namespace and returns the
unprocessed tags without leading subclass marker(100, AcDb...).
Bypasses the DXF attribute validity checks.

Args:
    dxf: entity DXF namespace
    group_code_mapping: group code to DXF attribute name mapping,
        callback attributes have to be marked with a leading "*"
    subclass: subclass by index, by name or as Tags()
    recover: recover graphic attributes
    log: enable/disable logging of unprocessed tags

r   N)r   d   r   *r!   )r   r!   )r   r   rM   intr   rv   r   r   r   r   r]   appendr   addr,   r   r   r+   recover_graphic_attributesr   )r/   dxfgroup_code_mappingr   r   r   r   r   processed_namesget_attrib_nameappend_unprocessed_tagunprotected_set_attribmark_attrib_as_processedstartr3   r   namesname_s                     r5   fast_load_dxfattribs&SubclassProcessor.fast_load_dxfattribs  s   , 88??1%D(C((--h7Hc**))(36<3t9>##$'E,00!1!8!8!$!4!4#2#6#6  !W\\X-1<C"388,D$%%  #EO3$07	 #
  7c>*j399= "
 's+-  0 88
 $# s+,,  ::JP  S7==D%%d#''(BS%Tr8   c                    U R                   (       a  gU R                  S   nUS   S:X  a&  UR                  S U R                  S    5       5        gg)zIt is valid to mix up the base class with AcDbEntity class.
This method appends all none base class group codes to the
AcDbEntity class.
Nr   r   )r   
AcDbEntityc              3  P   #    U  H  oR                   [        ;  d  M  Uv   M     g 7fr:   )r,   BASE_CLASS_CODES).0r3   s     r5   	<genexpr>ESubclassProcessor.append_base_class_to_acdb_entity.<locals>.<genexpr>U  s       $1XXEU5U1s   &	&)r   r   extend)r/   acdb_entity_tagss     r5    append_base_class_to_acdb_entity2SubclassProcessor.append_base_class_to_acdb_entityF  sT     88??1-A"55## $#q1$  6r8   c                h   [         R                  R                  U R                  5      nUR                  nUR
                  nU Hk  nU" UR                  5      n[        U[        5      (       d  M,  UR                  S5      (       a  MD  U" U[        UR                  UR                  5      5        Mm     g)a  Load DXF attributes from all subclasses into the DXF namespace.

Can not handle same group codes in different subclasses, does not remove
processed tags or log unprocessed tags and bypasses the DXF attribute
validity checks.

This method ignores the subclass structure and can load data from
very malformed DXF files, like such in issue #604.
This method works only for very simple DXF entities with unique group
codes in all subclasses, the old DXF R12 entities:

    - POINT
    - LINE
    - CIRCLE
    - ARC
    - INSERT
    - SHAPE
    - SOLID/TRACE/3DFACE
    - TEXT (ATTRIB/ATTDEF bypasses TEXT loader)
    - BLOCK/ENDBLK
    - POLYLINE/VERTEX/SEQEND
    - DIMENSION and subclasses
    - all table entries: LAYER, LTYPE, ...

And the newer DXF entities:

    - ELLIPSE
    - RAY/XLINE

The recover mode for graphical attributes is automatically included.
Logging of unprocessed tags is not possible but also not required for
this simple and well known entities.

Args:
    dxf: entity DXF namespace
    group_code_mapping: group code name mapping for all DXF attributes
        from all subclasses, callback attributes have to be marked with
        a leading "*"

r   N)	itertoolschainfrom_iterabler   r]   r   r,   rM   rv   
startswithr   r+   )r/   r  r  r   r  r
  r3   r   s           r5   simple_dxfattribs_loader*SubclassProcessor.simple_dxfattribs_loaderY  s    X ,,T__=,00!$!4!4C"388,D$$$T__S-A-A&tZ#))-LM r8   )r   r   r!   r   r   r   r:   )r   r   r   r   )r   N)r   r   r!   r   r{   r   )r   rv   r{   Optional[Tags])r   r  r{   r#  )r   r  r4   r  ra   r  r{   r  )r  r   r  zdict[int, Union[str, list]]r   zUnion[int, str, Tags]r{   r   )r{   r   )r  r   r  zdict[int, str]r{   r   )rQ   r   r   r   r   r6   r   r*   r   r   r   r   r  r  r!  r   r   r8   r5   r   r     s    G ( " "  $	T"T 	T
 
T	!	/2	=@			$ U U  8U  (	U  
U n&2N2N5C2N	2Nr8   r   r   color
paperspace
lineweightltscale	invisible
true_color
color_nametransparencyshadow_modematerial_handlevisualstyle_handleplotstyle_enumplotstyle_handle)      >   C   ir  0   <   i  i  i  i  i[  i\  i|  i  c                    [        5       nU  Hm  n[        R                  UR                  5      nU(       a3  UR	                  U5      (       d  UR                  XCR                  5        M\  UR                  U5        Mo     U$ r:   )r   GRAPHIC_ATTRIBUTES_TO_RECOVERr]   r,   r   r   r+   r  )r   r  r   r3   attrib_names        r5   r  r    sa    v377A s{{;77GGK+##C(  r8   )r   r   r   r   r+   r   r{   r   )r   r   r  r   r{   r   ),
__future__r   typingr   r   r   r   r   r	   loggingr  r   r
   ezdxf.lldxfr   ezdxf.lldxf.attributesr   r   r   ezdxf.lldxf.typesr   r   ezdxf.lldxf.tagsr   ezdxf.lldxf.extendedtagsr   ezdxf.entitiesr   ezdxf.lldxf.tagwriterr   __all__	getLoggerrt   rc   r   r}   	frozensetr   r   r   r  r   r8  r  r   r8   r5   <module>rG     s   # E E     @ @ 0 !5(7 .
/			7	#C >  $$	   >? i6 i6X *1:=	2 $ \N \N@ 									! *
r8   