From 8f634b3a7ea151cf2e8ad6b2680ded06a1df3b57 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 16:38:17 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/commitizen-tools/commitizen: 3.10.0 → 3.10.1](https://github.com/commitizen-tools/commitizen/compare/3.10.0...3.10.1) - [github.com/astral-sh/ruff-pre-commit: v0.0.291 → v0.0.292](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.291...v0.0.292) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index efb95aa3..a4a57e9d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: # Versioning: Commit messages & changelog - repo: https://github.com/commitizen-tools/commitizen - rev: 3.10.0 + rev: 3.10.1 hooks: - id: commitizen stages: [commit-msg] @@ -15,7 +15,7 @@ repos: # Lint / autoformat: Python code - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: "v0.0.291" + rev: "v0.0.292" hooks: - id: ruff args: [--exit-non-zero-on-fix] From 32564400364d40c0c5389a1bcb38375fd691579b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 16:39:05 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- osm_fieldwork/basemapper.py | 1 + osm_fieldwork/make_data_extract.py | 2 +- tests/test_basemap.py | 29 +++++++++++++---------------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/osm_fieldwork/basemapper.py b/osm_fieldwork/basemapper.py index 0cd37f20..79063a40 100755 --- a/osm_fieldwork/basemapper.py +++ b/osm_fieldwork/basemapper.py @@ -501,6 +501,7 @@ def create_basemap_file( raise ValueError(msg) log.info(f"Wrote {outfile}") + def main(): """This main function lets this class be run standalone by a bash script.""" parser = argparse.ArgumentParser(description="Create an tile basemap for ODK Collect") diff --git a/osm_fieldwork/make_data_extract.py b/osm_fieldwork/make_data_extract.py index 351984a6..d4618bf1 100755 --- a/osm_fieldwork/make_data_extract.py +++ b/osm_fieldwork/make_data_extract.py @@ -27,13 +27,13 @@ import geojson import yaml from geojson import FeatureCollection, dump +from osm_rawdata.config import QueryConfig from osm_rawdata.postgres import PostgresClient from shapely.geometry import shape from osm_fieldwork.data_models import data_models_path from osm_fieldwork.filter_data import FilterData from osm_fieldwork.xlsforms import xlsforms_path -from osm_rawdata.config import QueryConfig # Instantiate logger log = logging.getLogger(__name__) diff --git a/tests/test_basemap.py b/tests/test_basemap.py index b6531eb5..6ffe72ed 100755 --- a/tests/test_basemap.py +++ b/tests/test_basemap.py @@ -18,41 +18,37 @@ # along with osm_fieldwork. If not, see . # -import argparse import logging import os import shutil -from osm_fieldwork.xlsforms import xlsforms_path from osm_fieldwork.basemapper import BaseMapper -import geojson -from shapely.geometry import shape -from geojson import Feature, FeatureCollection -from osm_fieldwork.sqlite import DataFile, MapTile +from osm_fieldwork.sqlite import DataFile log = logging.getLogger(__name__) -infile = f"testdata/Rollinsville.geojson" +infile = "testdata/Rollinsville.geojson" outfile = "rollinsville.mbtiles" base = "./tiles" -#boundary = open(infile, "r") -#poly = geojson.load(boundary) -#if "features" in poly: +# boundary = open(infile, "r") +# poly = geojson.load(boundary) +# if "features" in poly: # geometry = shape(poly["features"][0]["geometry"]) -#elif "geometry" in poly: +# elif "geometry" in poly: # geometry = shape(poly["geometry"]) -#else: +# else: # geometry = shape(poly) - + + def test_create(): """See if the file got loaded.""" hits = 0 - basemap = BaseMapper(infile, base, 'topo', False) + basemap = BaseMapper(infile, base, "topo", False) tiles = list() for level in [8, 9, 10, 11, 12]: basemap.getTiles(level) tiles += basemap.tiles - + if len(tiles) == 5: hits += 1 @@ -64,8 +60,9 @@ def test_create(): os.remove(outfile) shutil.rmtree(base) - + assert hits == 2 + if __name__ == "__main__": test_create()