Skip to content

Commit

Permalink
WIP Fix DB downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
somnathrakshit committed May 27, 2022
1 parent 4216054 commit a7a2514
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

# https://stackoverflow.com/a/16609054
class Download(install):
def run(self):
install.run(self)

def nltk_download(self):
import nltk
nltk.downloader.download('maxent_ne_chunker')
nltk.downloader.download('words')
Expand All @@ -16,6 +16,33 @@ def run(self):
# since 2020-09
nltk.downloader.download('averaged_perceptron_tagger')

def gunzip(self, source_filepath, dest_filepath, block_size=65536):
import gzip
with gzip.open(source_filepath, 'rb') as s_file, \
open(dest_filepath, 'wb') as d_file:
while True:
block = s_file.read(block_size)
if not block:
break
else:
d_file.write(block)

def db_download(self):
import urllib.request
import gzip
from pathlib import Path
import os

urllib.request.urlretrieve('https://github.com/somnathrakshit/geograpy3/wiki/data/locations.db.gz', 'locations.db.gz')
urllib.request.urlretrieve('https://github.com/somnathrakshit/geograpy3/wiki/data/regions.tgz', 'regions.tgz')
self.gunzip("locations.db.gz", f"{str(Path(Path.home(), '.geograpy3'))}")


def run(self):
install.run(self)
self.nltk_download()
self.db_download()

try:
long_description = ""
with open('README.md', encoding='utf-8') as f:
Expand Down

0 comments on commit a7a2514

Please sign in to comment.