Ë
    õ¾jˆ  ã                   ó.  — d Z ddlZddlZddlZej                  j                  ej                  j                  e«      d«      Zej                  j                  ej                  j                  e«      d«      Z	g d¢Z
d„ Zd„ Zd„ Zd	„ Zed
k(  r e«        yy)zÃ
Bigg Adventure EQEmu Server - Server-side Manifest Generator
Scans the 'patch_files' directory, calculates SHA-256 hashes & file sizes,
and outputs 'patch_manifest.json' for the Client Patcher.
é    NÚpatch_fileszpatch_manifest.json)z
bazaar.eqgz
Bazaar.eqgz+uifiles/default/EQUI_SpellDisplayWindow.xmlc                 ó  — t        j                  «       }t        | d«      5 }|j                  d«      x}r%|j	                  |«       |j                  d«      x}rŒ%d d d «       |j                  «       S # 1 sw Y   |j                  «       S xY w)NÚrbi   )ÚhashlibÚsha256ÚopenÚreadÚupdateÚ	hexdigest)Úfilepathr   ÚfÚchunks       úgenerate_manifest.pyÚ
get_sha256r      s€   € Ü�^‰^Ó€FÜ	ˆh˜Ó	ð ! Ø—v‘v˜e“}Ð$ˆeÐ$Ø�M‰M˜%Ô ð —v‘v˜e“}Ð$ˆeÑ$÷!ð ×ÑÓÐ÷!ð ×ÑÓÐús   ¡8A2Á2B
c                  ój  — t         j                  j                  t         j                  j                  t         j                  j	                  t
        «      «      d«      } 	 t        | d¬«      5 }|j                  «       j                  «       }ddd«       r|S 	 y# 1 sw Y   ŒxY w# t        $ r Y yw xY w)zkPatcher news / patch notes: news.txt next to this script (shown in the patcher log), else the welcome line.znews.txtúutf-8©ÚencodingNzJWelcome to Bigg's Adventure, a private emulated realm. By invitation only.)
ÚosÚpathÚjoinÚdirnameÚabspathÚ__file__r   r	   ÚstripÚOSError)r   r   Útexts      r   Ú	read_newsr      s‘   € ä�7‰7�<‰<œŸ™Ÿ™¬¯©¯©¼Ó(AÓBÀJÓO€DðÜ�$ Ô)ð 	$¨QØ—6‘6“8—>‘>Ó#ˆD÷	$áØˆKð ð X÷	$ð 	$ûô ò ØØWðús*   Á B& Á-BÂB& ÂB#ÂB& Â&	B2Â1B2c                  ó  — t         j                  j                  t         j                  j                  t         j                  j	                  t
        «      «      d«      } 	 t        | d¬«      5 }|j                  «       j                  «       }ddd«       sy|ddœ}t         j                  j                  t         j                  j                  t         j                  j	                  t
        «      «      dd«      }t         j                  j                  |«      r<|j                  d	t        |«      t         j                  j                  |«      ¬
«       |S t        d|› d�«       |S # 1 sw Y   ŒÜxY w# t        $ r Y yw xY w)a:  Current Windows patcher (patcher_version.txt next to this script, e.g. 3.3): patcher 3.2+ shows a
    "new patcher available" dialog with the website Downloads page when its own version is older, and 3.3+
    replaces itself with patcher_exe/BiggsAdventurePatcher.exe, whose version MUST equal patcher_version.txt.zpatcher_version.txtr   r   Nz
/downloads)ÚversionÚurlÚpatcher_exezBiggsAdventurePatcher.exez(/patch/patcher/BiggsAdventurePatcher.exe)Úexe_urlr   Úsizez	WARNING: z' missing: patchers will not self-update)r   r   r   r   r   r   r   r	   r   r   Úisfiler
   r   ÚgetsizeÚprint)r   r   r    ÚinfoÚexes        r   Úread_patcher_infor*   (   s  € ô �7‰7�<‰<œŸ™Ÿ™¬¯©¯©¼Ó(AÓBÐDYÓZ€DðÜ�$ Ô)ð 	'¨QØ—f‘f“h—n‘nÓ&ˆG÷	'ñ ØØ |Ñ4€Dô �'‰'�,‰,”r—w‘w—‘¤r§w¡w§¡´xÓ'@ÓAÀ=ÐRmÓ
n€CÜ	‡w�w‡~�~�cÔØ�‰ÐFÌzÐZ]ËÜŸ™Ÿ™¨Ó-ð 	ô 	/ð €Kô 	�	˜#˜ÐEÐFÔGØ€K÷	'ð 	'ûäò Ùðús*   Á E3 Á-E'ÂE3 Å'E0Å,E3 Å3	E?Å>E?c                  ó†  — t         j                  j                  t        «      s-t        j                  t        d¬«       t        dt        › �«       dddt        «       g t        dœ} t        «       }|r|| d<   t        d	«       t        j                  t        «      D ]»  \  }}}|D ]°  }t         j                  j                  ||«      }t         j                  j                  |t        «      j                  d
d«      }t        |«      }t         j                  j                  |«      }	| d   j                  |||	dœ«       t        d|› d|	› d|d d › d�«       Œ² Œ½ t!        t"        d«      5 }
t%        j&                  | |
d¬«       d d d «       t        dt"        › �«       t        dt)        | d   «      › �«       y # 1 sw Y   Œ6xY w)NT)Úexist_okzCreated directory: z1.0.0zBigg Adventurez!Host=play.biggsadventure.com:5999)r    Úserver_nameÚeqhostÚnewsÚfilesÚretireÚpatcherzScanning patch files...ú\ú/r0   )r   r   r$   z  + Added: z (z bytes, hash: é   z...)Úwé   )Úindentz%
Manifest successfully generated at: zTotal files: )r   r   ÚexistsÚPATCH_FILES_DIRÚmakedirsr'   r   ÚRETIREr*   Úwalkr   ÚrelpathÚreplacer   r&   Úappendr   ÚMANIFEST_PATHÚjsonÚdumpÚlen)Úmanifestr2   ÚrootÚ_r0   ÚfileÚ	full_pathÚrel_pathÚsha256_hashÚ
size_bytesr   s              r   Úgenerate_manifestrM   ?   sœ  € Ü�7‰7�>‰>œ/Ô*Ü
�‰”O¨dÕ3ÜÐ#¤OÐ#4Ð5Ô6ð Ø'ð 6Ü“ØÜñ	€Hô  Ó!€GÙØ%ˆ�Ñä	Ð
#Ô$ÜŸ'™'¤/Ó2ò ]‰ˆˆa�Øò 	]ˆDÜŸ™Ÿ™ T¨4Ó0ˆIÜ—w‘w—‘ y´/ÓB×JÑJÈ4ÐQTÓUˆHÜ$ YÓ/ˆKÜŸ™Ÿ™¨Ó3ˆJà�WÑ×$Ñ$Ø Ø%Ø"ñ&ô ô
 �K ˜z¨¨J¨<°~ÀkÐRTÐSTÀoÐEVÐVZÐ[Õ\ñ	]ð]ô 
Œm˜SÓ	!ð ) QÜ�	‰	�(˜A aÕ(÷)ô 
Ð2´=°/Ð
BÔCÜ	ˆMœ#˜h wÑ/Ó0Ð1Ð
2Õ3÷	)ð )ús   Å)F7Æ7G Ú__main__)Ú__doc__r   rB   r   r   r   r   r   r:   rA   r<   r   r   r*   rM   Ú__name__© ó    r   ú<module>rS      sŠ   ðñó 
Û Û à—'‘'—,‘,˜rŸw™wŸ™¨xÓ8¸-ÓH€Ø—‘—‘˜RŸW™WŸ_™_¨XÓ6Ð8MÓN€ò
9€òò
Xòò.&4ðP ˆzÒÙÕð rR   