File: //home/arjun/projects/env/lib/python3.10/site-packages/uszipcode/__pycache__/db.cpython-38.pyc
U
Y�aB � @ sz d Z ddlZddlmZ ddlmZ ddlmZ ddlZ dZ
dZee�� d�Z
ee
d �Zee
d
�Zeeeed�dd
�ZdS )av
The dataset for ``uszipcode`` is from multiple source, and integrated by Sanhe Hu.
- 2012-01-22 federal governmanet zipcode data from
http://federalgovernmentzipcodes.us/
- 2010 zcta2010 population, wage, houseunit, land, water area data from
from http://proximityone.com/cen2010_zcta_dp.htm
- 2015-10-01 geometry google map geocoding data from http://maps.google.com
� N)�Path)�repr_data_size)�atomic_writezZhttps://github.com/MacHu-GWU/uszipcode-project/releases/download/1.0.1.db/simple_db.sqlitezahttps://github.com/MacHu-GWU/uszipcode-project/releases/download/1.0.1.db/comprehensive_db.sqlitez
.uszipcodezsimple_db.sqlitezcomprehensive_db.sqlite)�db_file_path�download_url�
chunk_size�
progress_sizec C s� t | �jjddd� td| � d|� d�� tj|dd�}d}|}t| ddd ��R}|�|�D ]@}|sf q�|�|� ||7 }||krZtd
� t
|��� ||7 }qZW 5 Q R X td� d S )NT)�parents�exist_okz Download z from z ...)�streamr �wb)�mode� overwritez {} downloaded ...z Complete!)r �parent�mkdir�print�requests�getr Ziter_content�write�formatr ) r r r r �responseZdownloaded_sizeZnext_log_threshold�f�chunk� r �A/Users/sanhehu/Documents/GitHub/uszipcode-project/uszipcode/db.py�download_db_file s
r )�__doc__r �pathlib_mater Zpathlib_mate.helperr �atomicwritesr Zsqlalchemy_mateZsam�SIMPLE_DB_FILE_DOWNLOAD_URL�"COMPREHENSIVE_DB_FILE_DOWNLOAD_URL�homeZUSZIPCODE_HOME�DEFAULT_SIMPLE_DB_FILE_PATH�"DEFAULT_COMPREHENSIVE_DB_FILE_PATH�str�intr r r r r �<module> s
�