Skip to content

Commit

Permalink
Format with black
Browse files Browse the repository at this point in the history
  • Loading branch information
plant99 committed Sep 29, 2020
1 parent 607eca3 commit c6305f8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
7 changes: 5 additions & 2 deletions felicette/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
from felicette.utils.sys_utils import exit_cli, remove_dir
from felicette.sat_processor import process_landsat_data


def trigger_download_and_processing(landsat_item, bands):
# download data
data_id = download_landsat_data(landsat_item, bands)
# process data
process_landsat_data(data_id, bands)


@click.command()
@click.option(
"-c",
Expand Down Expand Up @@ -88,7 +90,9 @@ def main(coordinates, location_name, pan_enhancement, no_preview, vegetation, ve
try:
trigger_download_and_processing(landsat_item, bands)
except RasterioIOError:
response = input("Local data for this location is corrupted, felicette will remove existing data to proceed, are you sure? [Y/n]")
response = input(
"Local data for this location is corrupted, felicette will remove existing data to proceed, are you sure? [Y/n]"
)
if response in ["y", "Y", ""]:
# remove file dir
file_paths = file_paths_wrt_id(landsat_item._data["id"])
Expand All @@ -99,6 +103,5 @@ def main(coordinates, location_name, pan_enhancement, no_preview, vegetation, ve
exit_cli(print, "")



if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion felicette/sat_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def handle_prompt_response(response):
if response in ["n", "N"]:
exit_cli(
rprint,
"Why not try a different location next time? I'd suggest [link=https://en.wikipedia.org/wiki/Svalbard]Svalbard[/link] :)"
"Why not try a different location next time? I'd suggest [link=https://en.wikipedia.org/wiki/Svalbard]Svalbard[/link] :)",
)
elif response in ["y", "Y", ""]:
return None
Expand Down
6 changes: 5 additions & 1 deletion felicette/utils/geo_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import requests
from felicette.utils.sys_utils import exit_cli


def find_first_landsat(items):
for index, item in enumerate(items):
if "LC" in item._data["id"]:
Expand All @@ -16,7 +17,10 @@ def geocoder_util(location_name):
)
r_json = r.json()
if len(r_json) == 0:
exit_cli(print, "Oops, couldn't geocode this location's name. Could you please try with coordinates(-c) option?")
exit_cli(
print,
"Oops, couldn't geocode this location's name. Could you please try with coordinates(-c) option?",
)

# return lat, lon
return (float(r_json[0]["lon"]), float(r_json[0]["lat"]))
Expand Down
3 changes: 2 additions & 1 deletion felicette/utils/sys_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def display_file(file_name):
elif sys.platform.startswith("darwin"):
os.system("open %s" % file_name)


def remove_dir(directory):
for filename in os.listdir(directory):
file_path = os.path.join(directory, filename)
Expand All @@ -27,5 +28,5 @@ def remove_dir(directory):
elif os.path.isdir(file_path):
shutil.rmtree(file_path)
except Exception as e:
print('Failed to delete %s. Reason: %s' % (file_path, e))
print("Failed to delete %s. Reason: %s" % (file_path, e))
exit_cli(print, "")

0 comments on commit c6305f8

Please sign in to comment.