
    d{Igy                        d Z ddlmZmZ ddlmZmZ 	 ddlmZ n# e	$ r	 ddl
mZ Y nw xY wddlZddlZddlmZ ddlZddlmZ d	Z	 d
Z	 dZ	 dZ	 dZ	 dZ	 dZ	 dZ	 dZ	 dZ	 dZ	  G d de          Z G d de          Z G d de          Z  G d de          Z! G d de          Z" G d de#          Z$ G d de%          Z& G d de          Z' G d  d!e          Z( G d" d#e%          Z) G d$ d%e%          Z*dS )&z
Handle a region file, containing 32x32 chunks.

For more information about the region file format:
https://minecraft.gamepedia.com/Region_file_format
   )NBTFileMalformedFileError    )packunpack)MappingN)BytesIO)SEEK_ENDi      c                        e Zd ZdZddZd ZdS )RegionFileFormatErrorzBase class for all file format errors.
    Note: InconceivedChunk is not a child class, because it is not considered a format error. c                     || _         d S Nmsgselfr   s     L/var/www/CMSBlueprintStation/venv/lib/python3.11/site-packages/nbt/region.py__init__zRegionFileFormatError.__init__?           c                     | j         S r   r   r   s    r   __str__zRegionFileFormatError.__str__A   s	    xr   Nr   )__name__
__module____qualname____doc__r   r     r   r   r   r   <   sC        a a       r   r   c                       e Zd ZdZdS )NoRegionHeaderz=The size of the region file is too small to contain a header.Nr"   r#   r$   r%   r&   r   r   r(   r(   D   s        GGGGr   r(   c                       e Zd ZdZdS )RegionHeaderErrorz9Error in the header of the region file for a given chunk.Nr)   r&   r   r   r+   r+   G   s        CCCCr   r+   c                       e Zd ZdZdS )ChunkHeaderErrorzNError in the header of a chunk, included the bytes of length and byte version.Nr)   r&   r   r   r-   r-   J   s        XXXXr   r-   c                       e Zd ZdZdS )ChunkDataErrorzError in the data of a chunk.Nr)   r&   r   r   r/   r/   M   s        ''''r   r/   c                       e Zd ZdZddZdS )InconceivedChunkz+Specified chunk has not yet been generated.r   c                     || _         d S r   r   r   s     r   r   zInconceivedChunk.__init__R   r   r   Nr!   )r"   r#   r$   r%   r   r&   r   r   r1   r1   P   s.        55     r   r1   c                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )ChunkMetadataz_
    Metadata for a particular chunk found in the 8 kiByte header and 5-byte chunk header.
    c                     || _         	 || _        	 d| _        	 d| _        	 d| _        	 d| _        	 d | _        	 t          | _        d S Nr   )	xz
blockstartblocklength	timestamplengthcompressionSTATUS_CHUNK_NOT_CREATEDstatusr   r7   r8   s      r   r   zChunkMetadata.__init__[   sf    33	+B	&	B	!
 /		& 		&r   c           
          d| j         j        | j        | j        | j        | j        | j        | j        | j        | j	        f	z  S )Nz]%s(%d, %d, sector=%s, blocklength=%s, timestamp=%s, bytelength=%s, compression=%s, status=%s))
	__class__r"   r7   r8   r9   r:   r;   r<   r=   r?   r   s    r   r    zChunkMetadata.__str__|   sA    n^$dfdfdotGWY]YgK)4;88 	8r   c                 :    d| j         j        | j        | j        fz  S )Nz	%s(%d,%d))rB   r"   r7   r8   r   s    r   __repr__zChunkMetadata.__repr__   s    dn5tvtvFFFr   c                 6    | j         dz   t          z   t          z  S )N   )r<   SECTOR_LENGTHr   s    r   requiredblockszChunkMetadata.requiredblocks   s    a-/MAAr   c                     | j         dk    S )zreturn True if this chunk is created according to the header.
        This includes chunks which are not readable for other reasons.r   )r9   r   s    r   
is_createdzChunkMetadata.is_created   s     !##r   N)	r"   r#   r$   r%   r   r    rD   rH   rJ   r&   r   r   r4   r4   V   sp          &  &  &B8 8 8G G GB B B$ $ $ $ $r   r4   c                   *    e Zd ZdZd Zd Zd Zd ZdS )_HeaderWrapperzDWrapper around self.metadata to emulate the old self.header variablec                     || _         d S r   metadatar   rO   s     r   r   z_HeaderWrapper.__init__        r   c                 P    | j         |         }|j        |j        |j        |j        fS r   )rO   r9   r:   r;   r?   r   xzms      r   __getitem__z_HeaderWrapper.__getitem__   s%    M"amQ[!(CCr   c                 *    t          | j                  S r   iterrO   r   s    r   __iter__z_HeaderWrapper.__iter__       DM"""r   c                 *    t          | j                  S r   lenrO   r   s    r   __len__z_HeaderWrapper.__len__       4=!!!r   Nr"   r#   r$   r%   r   rV   rZ   r_   r&   r   r   rL   rL      sY        NN! ! !D D D# # #" " " " "r   rL   c                   *    e Zd ZdZd Zd Zd Zd ZdS )_ChunkHeaderWrapperzKWrapper around self.metadata to emulate the old self.chunk_headers variablec                     || _         d S r   rN   rP   s     r   r   z_ChunkHeaderWrapper.__init__   rQ   r   c                 ^    | j         |         }|j        dk    r|j        nd |j        |j        fS r6   )rO   r<   r=   r?   rS   s      r   rV   z_ChunkHeaderWrapper.__getitem__   s/    M"HqLLdAM18LLr   c                 *    t          | j                  S r   rX   r   s    r   rZ   z_ChunkHeaderWrapper.__iter__   r[   r   c                 *    t          | j                  S r   r]   r   s    r   r_   z_ChunkHeaderWrapper.__len__   r`   r   Nra   r&   r   r   rc   rc      sY        UU! ! !M M M# # #" " " " "r   rc   c                       e Zd ZddZd ZdS )LocationNc                 0    || _         || _        || _        d S r   )r7   yr8   )r   r7   rk   r8   s       r   r   zLocation.__init__   s    r   c                 P    | j         j        d| j        d| j        d| j        dS )Nz(x=z, y=z, z=))rB   r"   r7   rk   r8   r   s    r   r    zLocation.__str__   s2    )-)@)@)@$&&&$&&&RVRXRXRXYYr   NNN)r"   r#   r$   r   r    r&   r   r   ri   ri      s<           Z Z Z Z Zr   ri   c                   
   e Zd ZdZeZ	 eZ	 eZ	 eZ	 eZ	 e	Z		 e
Z
	 d!dZd Zeefd            Zd Zd Zd Zd	 Zd
 Zd Zd"dZd"dZd#dZd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#e$fdZ%d Z&d Z'd Z(d Z)d  Z*dS )$
RegionFilezSA convenience class for extracting NBT files from the Minecraft Beta Region Format.Nc                 *   d| _         d| _        d| _        d| _        	 || _        |r$|| _        t          |d          | _         d| _        n<|r$t          |d          r|j        | _        || _         n| j         st          d          i | _	        	 t          | j	                  | _        	 t          | j	                  | _        	 t                      | _        	 |                                  |                                  |                                  dS )z
        Read a region file by filename or file object. 
        If a fileobj is specified, it is not closed after use; it is the callers responibility to close it.
        NFzr+bTnamez@RegionFile(): Need to specify either a filename or a file object)filefilename
_closefileclosed
chunkclassopenhasattrrr   
ValueErrorrO   rL   headerrc   chunk_headersri   loc_init_header_parse_header_parse_chunk_headers)r   rt   fileobjrw   s       r   r   zRegionFile.__init__   s&   
 	M$ 		a$DMXu--DI"DOO 	aw'' - 'DII 	a_``` 	 %T]33	( 1??	 ::@!!#####r   c                 t    | j                             dt                     | j                                         S )z! Returns the file size in bytes. r   )rs   seekr
   tellr   s    r   get_sizezRegionFile.get_size  s,     		q(###y~~r   c                 B    t          | |          \  }}|dk    r|n|dz   S )a	  Given a size in bytes, return how many sections of length sectorlen are required to contain it.
        This is equivalent to ceil(bsize/sectorlen), if Python would use floating
        points for division, and integers for ceil(), rather than the other way around.r   r   )divmod)bsizesectorlengthsectors	remainders       r   _bytes_to_sectorzRegionFile._bytes_to_sector  s.    
 $E<88#q..wwgk9r   c                 |    | j         r4	 | j                                         d| _        dS # t          $ r Y dS w xY wdS )a  
        Clean up resources after use.
        
        Note that the instance is no longer readable nor writable after calling close().
        The method is automatically called by garbage collectors, but made public to
        allow explicit cleanup.
        TN)ru   rs   closerv   IOErrorr   s    r   r   zRegionFile.close  s\     ? 		!!!"   		 	s    + 
99c                 .    |                                   d S r   )r   r   s    r   __del__zRegionFile.__del__+  s    

r   c                     dt           z  }| j        |k    r| j                            |           | j                            d           | j                            |dz             || _        dS )zLInitialise the file header. This will erase any data previously in the file.r   r       N)rG   sizers   truncater   write)r   header_lengths     r   
_init_filezRegionFile._init_file/  sf    -9}$$I}---	q	g-...!			r   c                     t          d          D ].}t          d          D ]}t          ||          | j        ||f<   /d S )N    )ranger4   rO   r@   s      r   r~   zRegionFile._init_header8  sX    r 	9 	9A2YY 9 9%21a%8%8ac""9	9 	9r   c                 R   |                                  | _        | j        dk    rdS | j        dt          z  k     rt          d| j        z            t	          dt          d          D ]`}t          |dz            dz  }t          |dz            dz  }| j        ||f         }| j                            |           t          dd| j        
                    d          z             \  }}||c|_        |_        | j                            |t          z              t          d	| j        
                    d                    d         |_        |dk    r|dk    rt          |_        |dk    rt           |_        |dk     r|dk    rt"          |_        0t          |z  d
z   | j        k    rt$          |_        Tt&          |_        b|                                 dd         D ]A}t+          |          dk    r,|D ])}|j        t           t"          t$          fvrt,          |_        *BdS )z=Read the region header and stores: offset, length and status.r   Nr   z@The region file is %d bytes, too small in size to have a header.   r   >IBr   >I   r   )r   r   rG   r(   r   intrO   rs   r   r   readr9   r:   r;   r>   r?   STATUS_CHUNK_ZERO_LENGTHSTATUS_CHUNK_IN_HEADERSTATUS_CHUNK_OUT_OF_FILESTATUS_CHUNK_OK_sectorsr^   STATUS_CHUNK_OVERLAPPING)r   indexr7   r8   rU   offsetr<   chunkss           r   r   zRegionFile._parse_header=  s
    MMOO	9>> FY=(( !cfjfo!oppp1mQ// 	+ 	+EE1H"AE1Hr!Aad#AINN5!!!#E549>>!3D3D+DEENFF*0&'AL!-INN5=0111 ty~~a'8'899!<AK{{v{{313!!1'!+di773* mmooabb) 	< 	<F6{{Q < <Ax(@BX(@(B B B#;	< 	<r   c                    t          d          D ]b}t          d          D ]N}| j        ||f         }|j        t          t          t
          fvr.	 | j                            |j        t          z             t          d| j                            d                    }|d         |_        t          d| j                            d                    }|d         |_        n# t          $ r t          |_        Y w xY w|j        t          z  |j        z   dz   | j        k    rt          |_        |j        dk    rt"          |_        '|j        dz   |j        t          z  k    rt
          |_        Pdd S )Nr   r   r   r   >Br   )r   rO   r?   r   r   STATUS_CHUNK_MISMATCHED_LENGTHSrs   r   r9   rG   r   r   r<   r=   r   r   r   r   r:   )r   r7   r8   rU   r<   r=   s         r   r   zRegionFile._parse_chunk_headersl  sg   r 	? 	?A2YY ? ?M!Q$'8O5M$C$E E E INN1<#=>>>#D$)..*;*;<<F%ayAH"(dinnQ.?.?"@"@K$/NAMM   7AHH <-81<tyHH7AHHX]]7AHHX\AMM$AAA>AH-?	? 	?s   BC##C<;C<c                    |                      | j                  }d t          |          D             }d|d<   d|d<   | j                                        D ]}|                                s||k    r|j        r|j        r~|j        t          |j        |	                                          z   }t          t          |j        d          t          ||                    D ]}||                             |           |S )zd
        Return a list of all sectors, each sector is a list of chunks occupying the block.
        c                     g | ]}g S r&   r&   ).0ss     r   
<listcomp>z'RegionFile._sectors.<locals>.<listcomp>  s    111!2111r   Tr   r   r   )r   r   r   rO   valuesrJ   r:   r9   maxrH   minappend)r   ignore_chunk
sectorsizer   rU   blockendbs          r   r   zRegionFile._sectors  s    **4955
11uZ00111

%%'' 		) 		)A<<>> q  } ) )<#amQ=M=M=O=O*P*PPs1<33S:5N5NOO ) )AAJ%%a((((r   c                 F    |                      |          }d |D             S )z7Return a list of booleans, indicating the free sectors.r   c                     g | ]}| S r&   r&   )r   is     r   r   z3RegionFile._locate_free_sectors.<locals>.<listcomp>  s    '''!A'''r   )r   )r   r   r   s      r   _locate_free_sectorszRegionFile._locate_free_sectors  s)    --\-::''w''''r   r   c                     |rt          ||||z                      r|S d}|t          |          k     r3t          ||||z                      rn|dz  }|t          |          k     3|S )z
        Given a list of booleans, find a list of <required_sectors> consecutive True values.
        If no such list is found, return length(free_locations).
        Assumes first two values are always False.
        r   r   )allr^   )r   free_locationsrequired_sectors	preferredr   s        r   _find_free_locationzRegionFile._find_free_location  s      	^Ii@P6P,PQRR 	 #n%%%%>!A&6$6"6788 FA #n%%%% r   c                 H    d | j                                         D             S )z
        Return a list of the metadata of each chunk that is defined in te regionfile.
        This includes chunks which may not be readable for whatever reason,
        but excludes chunks that are not yet defined.
        c                 :    g | ]}|                                 |S r&   )rJ   )r   rU   s     r   r   z+RegionFile.get_metadata.<locals>.<listcomp>  s%    DDDaQ\\^^DDDDr   )rO   r   r   s    r   get_metadatazRegionFile.get_metadata  s'     ED4=//11DDDDr   c                 *    |                                  S )a  
        Return the x,z coordinates and length of the chunks that are defined in te regionfile.
        This includes chunks which may not be readable for whatever reason.

        Warning: despite the name, this function does not actually return the chunk,
        but merely it's metadata. Use get_chunk(x,z) to get the NBTFile, and then Chunk()
        to get the actual chunk.
        
        This method is deprecated. Use :meth:`get_metadata` instead.
        )get_chunk_coordsr   s    r   
get_chunkszRegionFile.get_chunks  s     $$&&&r   c                     g }t          d          D ]U}t          d          D ]C}| j        ||f         }|                                r|                    |||j        d           DV|S )a  
        Return the x,z coordinates and length of the chunks that are defined in te regionfile.
        This includes chunks which may not be readable for whatever reason.
        
        This method is deprecated. Use :meth:`get_metadata` instead.
        r   )r7   r8   r<   )r   rO   rJ   r   r:   )r   r   r7   r8   rU   s        r   r   zRegionFile.get_chunk_coords  s     r 	M 	MA2YY M MM!A#&<<>> MMMQ]"K"KLLLM r   c              #      K   |                                  D ]5}	 |                     |j        |j                  V  &# t          $ r Y 2w xY wdS )a%  
        Yield each readable chunk present in the region.
        Chunks that can not be read for whatever reason are silently skipped.
        Warning: this function returns a :class:`nbt.nbt.NBTFile` object, use ``Chunk(nbtfile)`` to get a
        :class:`nbt.chunk.Chunk` instance.
        N)r   	get_chunkr7   r8   r   r   rU   s     r   iter_chunkszRegionFile.iter_chunks  ss       ""$$ 	 	AnnQS!#......(   	 	s   "=
A
	A
c              #      K   |                                  D ]H}	 |                     |                     |j        |j                            V  9# t
          $ r Y Ew xY wdS )z
        Yield each readable chunk present in the region.
        Chunks that can not be read for whatever reason are silently skipped.
        This function returns a :class:`nbt.chunk.Chunk` instance.
        N)r   rw   r   r7   r8   r   r   s     r   iter_chunks_classzRegionFile.iter_chunks_class  s       ""$$ 	 	AoodnnQS!#&>&>??????(   	 	s   5A
AAc                 *    |                                  S r   )r   r   s    r   rZ   zRegionFile.__iter__  s    !!!r   c                 *    | j         ||f         j        S )a`  
        Return the timestamp of when this region file was last modified.
        
        Note that this returns the timestamp as-is. A timestamp may exist, 
        while the chunk does not, or it may return a timestamp of 0 even 
        while the chunk exists.
        
        To convert to an actual date, use `datetime.fromtimestamp()`.
        )rO   r;   r@   s      r   get_timestampzRegionFile.get_timestamp  s     }QqS!++r   c                 D    t          |                                           S )zNReturn the number of defined chunks. This includes potentially corrupt chunks.)r^   r   r   s    r   chunk_countzRegionFile.chunk_count  s    4$$&&'''r   c                 d   | j         ||f         }|j        t          k    rt          d||fz            |j        t          k    rt          d||fz            |j        t          k    r*|j        dk    s|j        dk    rt          d||fz            |j        t          k    r3|j
        dk    rt          d||fz            t          d||fz            |j        t          z  dz   | j        k    rt          d||fz            d}	 | j                            |j        t          z  dz              t#          |j        dz
  | j        |j        t          z  dz   z
            }| j                            |          }|j        t&          k    rXt)          j        t-          |          	          }t/          |                                          }|                                 nL|j        t2          k    rt5          j        |          }n'|j        t8          k    rt;          d
|j        z            |S # t<          $ r  t>          $ r}d|z  }Y d}~nd}~ww xY w|rW|j        t@          k    rt          d||fz            |j        tB          k    rt          d||fz            t;          |          dS )aY  
        Return the decompressed binary data representing a chunk.
        
        May raise a RegionFileFormatError().
        If decompression of the data succeeds, all available data is returned, 
        even if it is shorter than what is specified in the header (e.g. in case
        of a truncated while and non-compressed data).
        z$Chunk %d,%d is not present in regionz#Chunk %d,%d is in the region headerr   Nz4Chunk %d,%d is partially/completely outside the filer   zChunk %d,%d has zero lengthr   r   z%Unknown chunk compression/format (%s)%szXThe length in region header and the length in the header of chunk %d,%d are incompatiblez-Chunk %d,%d is overlapping with another chunk)"rO   r?   r>   r1   r   r+   r   r<   r=   r   r:   r-   r9   rG   r   rs   r   r   r   COMPRESSION_GZIPgzipGzipFiler	   bytesr   COMPRESSION_ZLIBzlib
decompressCOMPRESSION_NONEr/   r   	Exceptionr   r   )	r   r7   r8   rU   errr<   chunkfes	            r   get_blockdatazRegionFile.get_blockdata  s    M!Q$8///"#IQqE#QRRRX///#$IQqE$QRRRX111qx1}}Y]H]H]#$Z^_`a]b$bcccX111}!!'(E1(MNNN&'D!u'LMMM\M)A-::#$Z^_`a]b$bccc 	INN1<-7!;<<< AtyAL=4PST4T'UVVFINN6**E!111M'%..999affhh				-#333.."222$%Lq}%\]]]L$ 	 	 	 	 	 	 (CCCCCC	  		* x:::&  (B  FG  HI  EJ  (J  K  K  K555&'VZ[\]Y^'^___$S)))		* 		*s   D)H1 1IIIc                    |                      ||          }t          |          }d}	 t          |          }| j        j        dk    r|| j        j        dz  z  }| j        j        dk    r|| j        j        dz  z  }t          ||          |_        |S # t          $ r}d|z  }Y d}~nd}~ww xY w|rt          |          dS )z
        Return a NBTFile of the specified chunk.
        Raise InconceivedChunk if the chunk is not included in the file.
        Nbufferr   )r7   r8   r   )	r   r	   r   r}   r7   r8   ri   r   r/   )r   r7   r8   datar   nbtr   s          r   get_nbtzRegionFile.get_nbtO  s     !!!Q''t}}
	&&&CxzT!!TXZ]"xzT!!TXZ]"a(((CGJ! 	 	 	(CCCCCC	 	& %%%	& 	&s   A+B 
B.B))B.c                 .    |                      ||          S )a(  
        Return a NBTFile of the specified chunk.
        Raise InconceivedChunk if the chunk is not included in the file.
        
        Note: this function may be changed later to return a Chunk() rather 
        than a NBTFile() object. To keep the old functionality, use get_nbt().
        )r   r@   s      r   r   zRegionFile.get_chunkf  s     ||Aq!!!r   c           	      
   |t           k    rwt                      }t          j        |          }|                    |           |                                 |                    d           |                                }~n=|t          k    rt          j
        |          }n|t          k    rt          d|z            t          |          }|                     |dz             }|dk    rt          d|z            | j        dt"          z  k     r|                                  | j        ||f         }	|                     |	          }
|                     |
||	j        	          }| j        |t"          z  k     rt| j                            dt0                     | j                            |t"          z  | j        z
  d
z             | j                                        |t"          z  k    sJ | j                            |t"          z             | j                            t5          d|dz                        | j                            t5          d|                     | j                            |           t"          |z  |z
  dz
  }| j                            |d
z             | j                            d|d|z  z   z             | j                            t5          d||          dd                    | j                            t"          d|d|z  z   z  z              t7          t9          j                              }| j                            t5          d|                     |
                    ||z   t          |
          z
  dgz             t=          |||z             D ]}d|
|<   t?          tA          |
                    !                    d          }|dk    rIt"          t          |
          |z
  z  | _        | j        "                    | j                   |
d|          }
t=          |	j        tG          |	j        |	j$        z   t          |
                              D ]N}|
|         rD| j                            t"          |z             | j                            t"          d
z             OtK          ||z   t"          z  | j                  | _        | &                                | j        k    sJ ||	_        ||	_$        tN          |	_(        ||	_)        |dz   |	_*        t          |	_+        dS )z
        Compress the data, write it to file, and add pointers in the header so it 
        can be found as chunk(x,z).
        r   r   zUnknown compression type %dr      z3Chunk is too large (%d sectors exceeds 255 maximum)r   r   )r   r   r   r   r   r   r   r   NTF),r   r	   r   r   r   r   r   r   r   r   compressr   rz   r^   r   r/   r   rG   r   rO   r   r   r9   rs   r
   r   r   r   timeextendr   listreversedr   r   r   r:   r   r   r   r?   r;   r<   r=   )r   r7   r8   r   r=   compressed_filer   r<   nsectorscurrentfree_sectorssectorremaining_lengthr;   r   truncate_counts                   r   write_blockdatazRegionFile.write_blockdatap  s   
 ***%iiOo666AGGDMMMGGIII  ###"''))D,,,=&&DD,,,:[HIIIT ((!44s?? !VZb!cddd 9q&&OO -1%00g0FF)),GL^)__ 9vm+++INN1h'''IOOVM1DI=HIII9>>##vm';;;;; 		vm+,,,	T6A:..///	T;//000	 )83f<q@	(72333 		qA1H~&&&	UFH55abb9::: 		}qA1H~5666	$$		T9--... 	Vh.\1B1BBtfLMMMvv011 	$ 	$A#LOO h|4455;;EBBA%\):):^)KLDIIty)))'(8.(89L w)3w/AGDW/WY\]iYjYj+k+kll 	7 	7AA 7	}Q///	g 5666 (*M949EE	}}$)++++#&(%!.r   c                     t                      }|                    |           |                     |||                                           dS )z]
        Pack the NBT file as binary data, and write to file in a compressed format.
        r   N)r	   
write_filer   getvalue)r   r7   r8   nbt_filer   s        r   write_chunkzRegionFile.write_chunk  sJ     yy4(((Q4==??33333r   c           	         | j         dt          z  k     rdS | j                            d|d|z  z   z             | j                            t          ddd          dd                    | j                            t          d|d|z  z   z  z              | j                            t          dd                     | j        ||f         }|                     |	          }t          t          |                    
                    d
          }|dk    rIt          t          |          |z
  z  | _         | j                            | j                    |d|          }t          |j        t          |j        |j        z   t          |                              D ]N}||         rD| j                            t          |z             | j                            t          dz             Ot#          ||          | j        ||f<   dS )z
        Remove a chunk from the header of the region file.
        Fragmentation is not a problem, chunks are written to free sectors when possible.
        r   Nr   r   r   r   r   r   r   Fr   )r   rG   rs   r   r   r   rO   r   r   r   r   r^   r   r   r9   r   r:   r4   )r   r7   r8   r   r   r   r   s          r   unlink_chunkzRegionFile.unlink_chunk  s    9q&&F 		qA1H~&&&	UAq))!""-...	}qA1H~5666	T1&&& -1%00g0FFh|4455;;EBBA%\):):^)KLDIIty)))'(8.(89L w)3w/AGDW/WY\]iYjYj+k+kll 	7 	7AA 7	}Q///	g 5666 ,Aq11adr   c                 l    | j         j        dv r| j         j        S | j         j        d| j         j        S )z&Return the fully qualified class name.r   .)rB   r#   r"   r   s    r   
_classnamezRegionFile._classname  s;    >$//>**"n7779P9PQQr   c                     | j         r d|                                 d| j         dS d|                                 t          |           fz  S )N<(z)><%s object at %d>rt   r	  idr   s    r   r    zRegionFile.__str__  sT    = 	G 	G!%!2!2!2!2DMMMBB&$//*;*;RXX)FFFr   c                     | j         r|                                 d| j         dS d|                                 t          |           fz  S )Nr  rm   r  r  r   s    r   rD   zRegionFile.__repr__  sN    = 	G#0000$---@@&$//*;*;RXX)FFFr   rn   r   )r   N)+r"   r#   r$   r%   r   r   r   r   r   r   r>   r   r   staticmethodrG   r   r   r   r   r~   r   r   r   r   r   r   r   r   r   r   rZ   r   r   r   r   r   r   r   r  r  r	  r    rD   r&   r   r   rp   rp      sv       ]]  8M 'F#m7M3K7M%OD7MG$ G$ G$ G$R      -: : : : \:    " " "9 9 9
-< -< -<^? ? ?4   (( ( ( (   .E E E' ' '    "
 
 
" " "
, 
, 
,( ( (B* B* B*H& & &." " " 7G Y/ Y/ Y/ Y/|4 4 4 2  2  2DR R RG G GG G G G Gr   rp   )+r%   r   r   r   structr   r   collections.abcr   ImportErrorcollectionsr   r   ior	   r   osr
   rG   r   r   r   r   r   r   r>   r   r   r   r   r   r(   r+   r-   r/   LookupErrorr1   objectr4   rL   rc   ri   rp   r&   r   r   <module>r     sC    - , , , , , , ,        $''''''' $ $ $########$                 i   o"$  i  F  U  U V  D  ;  <  <
    I   H H H H H* H H HD D D D D- D D DY Y Y Y Y, Y Y Y( ( ( ( (* ( ( (    {   2$ 2$ 2$ 2$ 2$F 2$ 2$ 2$h
" 
" 
" 
" 
"W 
" 
" 
"
" 
" 
" 
" 
"' 
" 
" 
"Z Z Z Z Zv Z Z Z`	G `	G `	G `	G `	G `	G `	G `	G `	G `	Gs    ))