U
    ^'^                     @   sj   d dl mZmZ d dlZd dlmZ d dlmZmZm	Z	 d dl
mZ dZdZdd	d
Zedkrfed dS )    )rmtreecopytreeN)urlparse)urlretrievebuild_openerinstall_opener)
gettempdir)z;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.csszBhttps://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet-src.min.jszLhttps://cdn.jsdelivr.net/npm/leaflet.fullscreen@1.4.5/Control.FullScreen.csszOhttps://cdn.jsdelivr.net/npm/leaflet.fullscreen@1.4.5/Control.FullScreen.min.jsz<https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.min.jszUhttps://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.csszFhttps://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.jszRhttps://cdn.jsdelivr.net/gh/L0laapk3/Leaflet.OpacityControls@2/Control.Opacity.csszQhttps://cdn.jsdelivr.net/gh/L0laapk3/Leaflet.OpacityControls@2/Control.Opacity.jszJhttps://cdn.jsdelivr.net/npm/js-natural-sort@0.8.1/dist/naturalsort.min.jsz+https://factorio.com/static/img/favicon.ico   Tc              
   C   s  t jt jt jtd}| s|zDtt j|dd&}| tt	krZW 5 Q R  W dS W 5 Q R X W n t
k
rz   Y nX t jt d}zt| W n t
tfk
r   Y nX t j|dd t }dg|_t| tD ]4}td	|  t|t j|t jt|j qzt| W n t
tfk
r6   Y nX t|| tt j|dd
}|tt	 W 5 Q R X zt| W n t
tfk
r   Y nX dS )Nzweb/libVERSIONrFZFactorioMapsTmpLibT)exist_ok)z
User-agentz:Mozilla/5.0 U GUYS SUCK WHY ARE YOU BLOCKING Python-urllibzdownloading w)ospathjoindirnameabspath__file__openreadlinestrCURRENTVERSIONFileNotFoundErrorr   r   NotADirectoryErrormakedirsr   
addheadersr   urlListprintr   basenamer   r   write)ZForceZ
targetPathfZtempPathopenerurl r#   LD:\Dropbox\games\factorio\mods-live\L0laapk3_FactorioMaps_3.5.5\updateLib.pyupdate   s@    $
r%   __main__)T)shutilr   r   r   urllib.parser   urllib.requestr   r   r   tempfiler   r   r   r%   __name__r#   r#   r#   r$   <module>   s   
3