Skip to content

Commit

Permalink
add exception for flake8, pylint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
juleshaas committed Jul 6, 2023
1 parent 75c8d53 commit 31ecf80
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ per-file-ignores =
./i.sentinel_2.autotraining/i.sentinel_2.autotraining.py: E501,F821
./i.sentinel_2.parallel.index/i.sentinel_2.parallel.index.py: E501,F821
./i.sentinel_2.sen2cor/i.sentinel_2.sen2cor.py: E501,F821
./i.sentinel_2.vrt.index/i.sentinel_2.vrt.index.py: E501,F821
20 changes: 11 additions & 9 deletions i.sentinel_2.vrt.index/i.sentinel_2.vrt.index.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,19 @@
# % description: Prefix in front of output maps
# %end

import grass.script as grass
import atexit
import multiprocessing as mp
import os
import sys
import multiprocessing as mp
import atexit

import grass.script as grass
from grass.pygrass.modules import Module, ParallelModuleQueue

rm_regions = []


def cleanup():
"""Cleanup function (can be extended)"""
nuldev = open(os.devnull, "w")
kwargs = {"flags": "f", "quiet": True, "stderr": nuldev}
for rmr in rm_regions:
Expand All @@ -96,6 +98,7 @@ def cleanup():


def main():
"""Main function of i.sentinel_2.vrt.index"""
global rm_regions
indices = options["indices"].split(",")
nprocs = int(options["nprocs"])
Expand All @@ -106,8 +109,8 @@ def main():
if not grass.find_program("i.sentinel.parallel.index", "--help"):
grass.fatal(
_(
"The 'i.sentinel_2.parallel.index' module was not found, install it first:"
+ "\n"
"The 'i.sentinel_2.parallel.index' module was not found, "
+ "install it first: \n"
+ "g.extension i.sentinel_2.parallel.index url=path/to/addon"
)
)
Expand All @@ -125,9 +128,9 @@ def main():
if nprocs > mp.cpu_count():
grass.warning(
_(
"Using %d parallel processes but only %d CPUs available. Using %d procs."
f"Using {nprocs} parallel processes but only {mp.cpu_count()} "
f"CPUs available. Using {mp.cpu_count() - 1} procs."
)
% (nprocs, mp.cpu_count(), mp.cpu_count() - 1)
)
nprocs = mp.cpu_count() - 1

Expand Down Expand Up @@ -156,8 +159,7 @@ def main():
)
elif len(current_bands_list) == 1:
grass.message(
_("Only one raster dataset found for band %s. Copying...")
% (band)
_(f"Only one raster dataset found for band {band}. Copying...")
)
rename_str = "%s,%s" % (current_bands_list[0], vrt_name)
grass.run_command("g.copy", raster=rename_str, overwrite=True)
Expand Down

0 comments on commit 31ecf80

Please sign in to comment.