diff --git a/src/grass_gis_helpers/cleanup.py b/src/grass_gis_helpers/cleanup.py index 9d9a3cd..b3f5f2a 100644 --- a/src/grass_gis_helpers/cleanup.py +++ b/src/grass_gis_helpers/cleanup.py @@ -51,7 +51,9 @@ def general_cleanup( for rmg_wr in rm_groups_w_rasters: if grass.find_file(name=rmg_wr, element="group")["file"]: group_rasters = grass.parse_command( - "i.group", flags="lg", group=rmg_wr, + "i.group", + flags="lg", + group=rmg_wr, ) rm_rasters.extend(group_rasters) grass.run_command("g.remove", type="group", name=rmg, **kwargs) @@ -72,7 +74,10 @@ def general_cleanup( if find_reg.get("file"): grass.run_command("g.region", region=orig_region) grass.run_command( - "g.remove", type="region", name=orig_region, **kwargs, + "g.remove", + type="region", + name=orig_region, + **kwargs, ) for rmreg in rm_regions: find_reg = grass.find_file(name=rmreg, element="windows") diff --git a/src/grass_gis_helpers/data_import.py b/src/grass_gis_helpers/data_import.py index 18058ef..dde29c4 100644 --- a/src/grass_gis_helpers/data_import.py +++ b/src/grass_gis_helpers/data_import.py @@ -100,7 +100,8 @@ def get_list_of_tindex_locations(tindex, aoi=None): tiles = [ val[0] for val in grass.vector_db_select( - tindex_clipped, columns="location", + tindex_clipped, + columns="location", )["values"].values() ] finally: @@ -284,7 +285,10 @@ def get_xyz_file_infos(xyz_file, separator="space"): def import_single_local_xyz_file( - xyz_file, output, use_cur_reg=False, separator="space", + xyz_file, + output, + use_cur_reg=False, + separator="space", ): """Import single XYZ file. @@ -300,7 +304,8 @@ def import_single_local_xyz_file( """ res, xyz_reg, shift_needed = get_xyz_file_infos( - xyz_file, separator=separator, + xyz_file, + separator=separator, ) # check if aoi overlaps if use_cur_reg: @@ -440,7 +445,8 @@ def import_local_vector_data(aoi_map, local_data_dir, rm_vectors, output): recursive=True, ) shp_files = glob.glob( - os.path.join(local_data_dir, "**", "*.shp"), recursive=True, + os.path.join(local_data_dir, "**", "*.shp"), + recursive=True, ) files.extend(shp_files) diff --git a/src/grass_gis_helpers/general.py b/src/grass_gis_helpers/general.py index 15566b3..c141251 100644 --- a/src/grass_gis_helpers/general.py +++ b/src/grass_gis_helpers/general.py @@ -62,7 +62,9 @@ def log_memory(grassenv=None): if not grassenv: grassenv = grass.gisenv() cmd = grass.Popen( - f"df -h {grassenv['GISDBASE']}", shell=True, stdout=subprocess.PIPE, + f"df -h {grassenv['GISDBASE']}", + shell=True, + stdout=subprocess.PIPE, ) grass.message( _( diff --git a/src/grass_gis_helpers/location.py b/src/grass_gis_helpers/location.py index 008a112..7f44c61 100644 --- a/src/grass_gis_helpers/location.py +++ b/src/grass_gis_helpers/location.py @@ -26,7 +26,9 @@ def get_location_size(): """Log size of current location.""" current_gisdbase = grass.gisenv()["GISDBASE"] cmd = grass.Popen( - f"df -h {current_gisdbase}", shell=True, stdout=subprocess.PIPE, + f"df -h {current_gisdbase}", + shell=True, + stdout=subprocess.PIPE, ) grass.message( _( @@ -67,7 +69,11 @@ def create_tmp_location(epsg=4326): # create temp location from input without import grass.verbose(_(f"Creating temporary location with EPSG:{epsg}...")) grass.run_command( - "g.proj", flags="c", location=tmp_loc, quiet=True, **epsg_arg, + "g.proj", + flags="c", + location=tmp_loc, + quiet=True, + **epsg_arg, ) # switch to temp location diff --git a/src/grass_gis_helpers/open_geodata_germany/download_data.py b/src/grass_gis_helpers/open_geodata_germany/download_data.py index 3f198b0..91daaa4 100644 --- a/src/grass_gis_helpers/open_geodata_germany/download_data.py +++ b/src/grass_gis_helpers/open_geodata_germany/download_data.py @@ -159,7 +159,9 @@ def fix_corrupted_data(file): # remove corrupted data from TXT DOM files if not os.path.exists(f"{file}.bak"): with fileinput.FileInput( - file, inplace=True, backup=".bak", + file, + inplace=True, + backup=".bak", ) as file_object: for line in file_object: # two times replace of white spaces, since some lines contain diff --git a/src/grass_gis_helpers/open_geodata_germany/federal_state.py b/src/grass_gis_helpers/open_geodata_germany/federal_state.py index 55c37db..4ac1861 100644 --- a/src/grass_gis_helpers/open_geodata_germany/federal_state.py +++ b/src/grass_gis_helpers/open_geodata_germany/federal_state.py @@ -102,10 +102,8 @@ def import_administrative_boundaries(output, aoi=None, level="KRS"): response = requests.get(url) if response.status_code != 200: grass.fatal( - - "The data import of the administrative boundaries are " - "currently not available.", - + "The data import of the administrative boundaries are " + "currently not available.", ) # download and import administrative boundaries @@ -145,7 +143,10 @@ def get_federal_states(federal_state, federal_state_file): fs_list_str = fs_file.read().strip() if fs_list_str == "": grass.fatal( - _("Federal state in is empty string!"), + _( + "Federal state in is empty " + "string!", + ), ) elif federal_state: fs_list_str = federal_state.strip() diff --git a/src/grass_gis_helpers/parallel.py b/src/grass_gis_helpers/parallel.py index 663b938..b9725b2 100644 --- a/src/grass_gis_helpers/parallel.py +++ b/src/grass_gis_helpers/parallel.py @@ -23,7 +23,12 @@ def run_module_parallel( - module, module_kwargs, tile_list, nprocs, uid, parallel=True, + module, + module_kwargs, + tile_list, + nprocs, + uid, + parallel=True, ): """Running a module in parallel on a grid.""" # save current mapset diff --git a/src/grass_gis_helpers/tests.py b/src/grass_gis_helpers/tests.py index 914e519..5ab001a 100644 --- a/src/grass_gis_helpers/tests.py +++ b/src/grass_gis_helpers/tests.py @@ -44,7 +44,11 @@ def get_number_of_grass_elements(): def check_number_of_grass_elements( - ref_num_rast, ref_num_vect, ref_num_gr, ref_num_reg, ref_num_mapsets, + ref_num_rast, + ref_num_vect, + ref_num_gr, + ref_num_reg, + ref_num_mapsets, ): """Check the number of grass elements. diff --git a/src/grass_gis_helpers/tiling.py b/src/grass_gis_helpers/tiling.py index 81566dd..021fdcd 100644 --- a/src/grass_gis_helpers/tiling.py +++ b/src/grass_gis_helpers/tiling.py @@ -50,7 +50,10 @@ def create_grid(tile_size, grid_prefix, sid, area=None): if dist_ns <= float(tile_size) and dist_ew <= float(tile_size): grass.run_command("v.in.region", output=grid, quiet=True) grass.run_command( - "v.db.addtable", map=grid, columns="cat int", quiet=True, + "v.db.addtable", + map=grid, + columns="cat int", + quiet=True, ) else: # set region with tile_size @@ -58,7 +61,10 @@ def create_grid(tile_size, grid_prefix, sid, area=None): # create grid grass.run_command( - "v.mkgrid", map=grid, box=f"{tile_size},{tile_size}", quiet=True, + "v.mkgrid", + map=grid, + box=f"{tile_size},{tile_size}", + quiet=True, ) # reset region reset_region(orig_region) @@ -86,7 +92,11 @@ def create_grid(tile_size, grid_prefix, sid, area=None): # create list of tiles tiles_num_list = list( grass.parse_command( - "v.db.select", map=grid_name, columns="cat", flags="c", quiet=True, + "v.db.select", + map=grid_name, + columns="cat", + flags="c", + quiet=True, ).keys(), ) diff --git a/src/grass_gis_helpers/validation.py b/src/grass_gis_helpers/validation.py index c0ebfc6..9f8614c 100644 --- a/src/grass_gis_helpers/validation.py +++ b/src/grass_gis_helpers/validation.py @@ -25,7 +25,9 @@ def get_gdalinfo_returncodes(input): """Return return codes from reading input file with gdalinfo.""" gdalinfo_cmd = ["gdalinfo", "-mm", input] p_gdalinfo = subprocess.Popen( - gdalinfo_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, + gdalinfo_cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, ) gdalinfo_err = p_gdalinfo.communicate()[1].decode("utf-8") gdalinfo_returncode = p_gdalinfo.returncode @@ -48,7 +50,5 @@ def check_valid_rasterdata(input, strict=True): ), ) # less strict check: fails only if bands can't be read - elif gdalinfo_returncode != 0 or ( - "TIFFReadEncodedStrip" in gdalinfo_err - ): + elif gdalinfo_returncode != 0 or ("TIFFReadEncodedStrip" in gdalinfo_err): grass.fatal(_(f"<{input}> is a broken file"))