diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..3d076f8be233091e5de4724411b7de85f348e701 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.pyc +*.log +*.pkl +*.egg-info +Pipfile +Pipfile.lock +.idea + +__pycache__ +.cache + +build +dist +env diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..b32a166506354b75b643f234c1416739a855e416 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,26 @@ +image: python:3-buster + +# Make pip cache the installed dependencies +variables: + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" +cache: + paths: + - .cache/pip + - venv/ + +before_script: + - python3 -V + - pip3 install virtualenv + - virtualenv venv + - source venv/bin/activate + - pip3 install . + - pip3 install .[tests] + +linters: + script: + - pip3 install .[linters] + - make check + +tests: + script: + - pytest tests diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..ae75ac8984eb252f151908b8b2336fe28688781f --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +SOURCES=gdeimporter tests setup.py +LENGTH=96 + +check: $(SOURCES) + flake8 --max-line-length=$(LENGTH) --ignore=E203,W503 $^ + black --check --line-length $(LENGTH) $^ + pylint -E $^ + +format: $(SOURCES) + black --line-length $(LENGTH) $^ diff --git a/gdeimporter/__init__.py b/gdeimporter/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..6502050df1da0442f7d284c1838e03bb5a9cee9b --- /dev/null +++ b/gdeimporter/__init__.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2021: +# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. diff --git a/gdeimporter/gdeimporter.py b/gdeimporter/gdeimporter.py new file mode 100644 index 0000000000000000000000000000000000000000..316ee99efd6eff74faa80333df0ed3470c98cb1c --- /dev/null +++ b/gdeimporter/gdeimporter.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2021: +# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. + +import logging +import sys + +# Add a logger printing error, warning, info and debug messages to the screen +logger = logging.getLogger() +logger.setLevel(logging.DEBUG) +logger.addHandler(logging.StreamHandler(sys.stdout)) + + +def main(): + + # Example logging output + logger.info("gde-importer has started") + + # Leave the program + sys.exit() + + +if __name__ == "__main__": + main() diff --git a/setup.py b/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..021b60749a5a3d6f049b80958af13d9bcb312341 --- /dev/null +++ b/setup.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2020-2021: +# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. + +from setuptools import setup, find_packages + +tests_require = ["pytest"] +linters_require = ["black>=20.8b1", "pylint", "flake8"] + +setup( + name="gde-importer", + version="0.0.1", + description="Importer of aggregated exposure models for GDE", + keywords="Global Dynamic Exposure, GDE, buildings, exposure model", + author="Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ", + license="AGPLv3+", + install_requires=["numpy"], + extras_require={ + "tests": tests_require, + "linters": linters_require, + }, + packages=find_packages(), + entry_points={"console_scripts": ["gdeimporter = gdeimporter.gdeimporter:main"]}, + python_requires=">=3.7", +) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..6502050df1da0442f7d284c1838e03bb5a9cee9b --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2021: +# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. diff --git a/tests/test_gdeimporter.py b/tests/test_gdeimporter.py new file mode 100644 index 0000000000000000000000000000000000000000..bb61ff6ee66948d8d7f66a986cbc34c99b5ecb00 --- /dev/null +++ b/tests/test_gdeimporter.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2021: +# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. + +import logging + +logger = logging.getLogger() + + +def test_main(): + pass