diff --git a/MANIFEST.in b/MANIFEST.in index 4ca82463a88e84208d6e89571736f6aaea665c70..ed41cf79cb7c7b4ee53c0298eb7141dbe70c7ef0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,3 +2,4 @@ include COPYING include COPYING.LESSER include LICENSE-plWN.txt include LICENSE-PWN.txt +include plwn/config.ini \ No newline at end of file diff --git a/plwn/config.ini b/plwn/config.ini new file mode 100644 index 0000000000000000000000000000000000000000..04c4bf256a340605658c527de18d82e11b0db1e2 --- /dev/null +++ b/plwn/config.ini @@ -0,0 +1,2 @@ +[DOWNLOAD] +model = https://minio.clarin-pl.eu/public/models/plwn_api_dumps/plwn_dump_27-03-2018.sqlite \ No newline at end of file diff --git a/plwn/download.py b/plwn/download.py new file mode 100644 index 0000000000000000000000000000000000000000..9699eb5b58a6d7c5cc55c490f85ab1b410934506 --- /dev/null +++ b/plwn/download.py @@ -0,0 +1,31 @@ +"""Implementation of download method.""" +import configparser +import os + +import requests + +models = { + "model", +} + + +def download(name): + """After called it downloads a specified database model. + + Currently only one model available. + """ + if name in models: + cfg = configparser.ConfigParser() + config_path = os.path.join(os.path.dirname( + os.path.abspath(__file__)), "config.ini") + cfg.read(config_path) + url = cfg["DOWNLOAD"][name] + r = requests.get(url) + with open(name, "wb") as f: + f.write(r.content) + f.close() + else: + print("Cannot download: ", + name, + "\n Possible download options: ", + models) diff --git a/setup.py b/setup.py index 2277dc8fcca7ed664ade8713a67af130ba30a710..612fcef5559199432bd2c57f5250e80f4da034ef 100644 --- a/setup.py +++ b/setup.py @@ -17,10 +17,10 @@ setup_args = dict( author_email='michal.kalinski@pwr.edu.pl', packages=['plwn', 'plwn.readers', 'plwn.storages', 'plwn.utils'], - package_data={'plwn.default': ['*.db']}, + package_data={'plwn.default': ['*.db'],'plwn':['config.ini']}, test_suite='tests.setuptools_loader.setuptools_load_tests', - install_requires=['six>=1.10', 'enum34>=1.1.2;python_version<"3.4"'], + install_requires=['six>=1.10', 'enum34>=1.1.2;python_version<"3.4"','requests'], zip_safe=False, )