cdsetool 0.2.3__tar.gz → 0.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cdsetool
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: Tools & CLI for interacting with CDSE product APIs
5
5
  Author-email: Jacob Vejby <javej@sdfi.dk>
6
6
  Project-URL: Homepage, https://github.com/SDFIdk/CDSETool
@@ -15,9 +15,9 @@ Requires-Dist: rich<13.8,>=13.6
15
15
  Requires-Dist: requests<2.32.0,>=2.28.1
16
16
  Requires-Dist: pyjwt[crypto]~=2.8.0
17
17
  Provides-Extra: test
18
- Requires-Dist: black==23.11.0; extra == "test"
19
- Requires-Dist: pylint==3.0.2; extra == "test"
20
- Requires-Dist: pytest==7.4.3; extra == "test"
18
+ Requires-Dist: black==24.1.1; extra == "test"
19
+ Requires-Dist: pylint==3.0.3; extra == "test"
20
+ Requires-Dist: pytest==8.0.0; extra == "test"
21
21
  Requires-Dist: pytest-cov==4.1.0; extra == "test"
22
22
  Requires-Dist: requests-mock==1.11.0; extra == "test"
23
23
  Requires-Dist: pytest-mock==3.12.0; extra == "test"
@@ -97,7 +97,7 @@ cdsetool download Sentinel2 PATH/TO/DIR --concurrency 4 --search-term startDate=
97
97
  Install `cdsetool` using pip:
98
98
 
99
99
  ```bash
100
- pip install cdsetool==0.2.3
100
+ pip install cdsetool==0.2.4
101
101
  ```
102
102
 
103
103
  ## Usage
@@ -71,7 +71,7 @@ cdsetool download Sentinel2 PATH/TO/DIR --concurrency 4 --search-term startDate=
71
71
  Install `cdsetool` using pip:
72
72
 
73
73
  ```bash
74
- pip install cdsetool==0.2.3
74
+ pip install cdsetool==0.2.4
75
75
  ```
76
76
 
77
77
  ## Usage
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cdsetool"
7
- version = "0.2.3"
7
+ version = "0.2.4"
8
8
  authors = [
9
9
  { name="Jacob Vejby", email="javej@sdfi.dk" },
10
10
  ]
@@ -23,9 +23,9 @@ dependencies = [
23
23
  ]
24
24
  [project.optional-dependencies]
25
25
  test = [
26
- "black==23.11.0",
27
- "pylint==3.0.2",
28
- "pytest==7.4.3",
26
+ "black==24.1.1",
27
+ "pylint==3.0.3",
28
+ "pytest==8.0.0",
29
29
  "pytest-cov==4.1.0",
30
30
  "requests-mock==1.11.0",
31
31
  "pytest-mock==3.12.0",
@@ -1,6 +1,7 @@
1
1
  """
2
2
  This module provides functions for processing data concurrently
3
3
  """
4
+
4
5
  from concurrent.futures import wait, FIRST_COMPLETED
5
6
  from concurrent.futures import ThreadPoolExecutor
6
7
 
@@ -1,6 +1,7 @@
1
1
  """
2
2
  Command line interface
3
3
  """
4
+
4
5
  import os
5
6
  import sys
6
7
  import json as JSON
@@ -76,6 +77,9 @@ def download(
76
77
  concurrency: Annotated[
77
78
  int, typer.Option(help="Number of concurrent connections")
78
79
  ] = 1,
80
+ overwrite_existing: Annotated[
81
+ bool, typer.Option(help="Overwrite already downloaded files")
82
+ ] = False,
79
83
  search_term: Annotated[
80
84
  Optional[List[str]],
81
85
  typer.Option(
@@ -97,7 +101,13 @@ def download(
97
101
 
98
102
  list(
99
103
  download_features(
100
- features, path, {"monitor": StatusMonitor(), "concurrency": concurrency}
104
+ features,
105
+ path,
106
+ {
107
+ "monitor": StatusMonitor(),
108
+ "concurrency": concurrency,
109
+ "overwrite_existing": overwrite_existing,
110
+ },
101
111
  )
102
112
  )
103
113
 
@@ -2,6 +2,7 @@
2
2
  This module provides a class for handling credentials for
3
3
  the Copernicus Identity and Access Management (IAM) system.
4
4
  """
5
+
5
6
  from datetime import datetime, timedelta
6
7
  import netrc
7
8
  import threading
@@ -4,6 +4,7 @@ Download features from a Copernicus Data Space Ecosystem OpenSearch API result
4
4
  Provides a function to download a single feature, and a function to download
5
5
  all features in a result set.
6
6
  """
7
+
7
8
  import os
8
9
  import random
9
10
  import tempfile
@@ -27,8 +28,12 @@ def download_feature(feature, path, options=None):
27
28
  if not url or not filename:
28
29
  return feature.get("id")
29
30
 
30
- # if os.path.exists(file):
31
- # return feature.get("id")
31
+ overwrite = options.get("overwrite_existing", False)
32
+
33
+ result_path = os.path.join(path, filename.replace(".SAFE", ".zip"))
34
+
35
+ if not overwrite and os.path.exists(result_path):
36
+ return feature.get("id")
32
37
 
33
38
  with _get_monitor(options).status() as status:
34
39
  status.set_filename(filename)
@@ -51,7 +56,7 @@ def download_feature(feature, path, options=None):
51
56
  status.add_progress(len(chunk))
52
57
 
53
58
  os.close(fd)
54
- shutil.move(tmp, os.path.join(path, filename.replace(".SAFE", ".zip")))
59
+ shutil.move(tmp, result_path)
55
60
 
56
61
  return feature.get("id")
57
62
 
@@ -7,6 +7,7 @@ progress of file downloads.
7
7
  For non-interactive programs the NoopMonitor class can be used to disable
8
8
  status monitoring.
9
9
  """
10
+
10
11
  import time
11
12
  import threading
12
13
  import sys
@@ -3,6 +3,7 @@ Query the Copernicus Data Space Ecosystem OpenSearch API
3
3
 
4
4
  https://documentation.dataspace.copernicus.eu/APIs/OpenSearch.html
5
5
  """
6
+
6
7
  from xml.etree import ElementTree
7
8
  from datetime import datetime, date
8
9
  import re
@@ -114,6 +115,8 @@ def geojson_to_wkt(geojson):
114
115
 
115
116
  if geojson.get("type") == "Feature":
116
117
  geojson = geojson["geometry"]
118
+ elif geojson.get("type") == "FeatureCollection" and len(geojson["features"]) == 1:
119
+ geojson = geojson["features"][0]["geometry"]
117
120
 
118
121
  coordinates = str(
119
122
  tuple(item for sublist in geojson["coordinates"][0] for item in sublist)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cdsetool
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: Tools & CLI for interacting with CDSE product APIs
5
5
  Author-email: Jacob Vejby <javej@sdfi.dk>
6
6
  Project-URL: Homepage, https://github.com/SDFIdk/CDSETool
@@ -15,9 +15,9 @@ Requires-Dist: rich<13.8,>=13.6
15
15
  Requires-Dist: requests<2.32.0,>=2.28.1
16
16
  Requires-Dist: pyjwt[crypto]~=2.8.0
17
17
  Provides-Extra: test
18
- Requires-Dist: black==23.11.0; extra == "test"
19
- Requires-Dist: pylint==3.0.2; extra == "test"
20
- Requires-Dist: pytest==7.4.3; extra == "test"
18
+ Requires-Dist: black==24.1.1; extra == "test"
19
+ Requires-Dist: pylint==3.0.3; extra == "test"
20
+ Requires-Dist: pytest==8.0.0; extra == "test"
21
21
  Requires-Dist: pytest-cov==4.1.0; extra == "test"
22
22
  Requires-Dist: requests-mock==1.11.0; extra == "test"
23
23
  Requires-Dist: pytest-mock==3.12.0; extra == "test"
@@ -97,7 +97,7 @@ cdsetool download Sentinel2 PATH/TO/DIR --concurrency 4 --search-term startDate=
97
97
  Install `cdsetool` using pip:
98
98
 
99
99
  ```bash
100
- pip install cdsetool==0.2.3
100
+ pip install cdsetool==0.2.4
101
101
  ```
102
102
 
103
103
  ## Usage
@@ -7,9 +7,9 @@ pyjwt[crypto]~=2.8.0
7
7
  geopandas==0.13.2
8
8
 
9
9
  [test]
10
- black==23.11.0
11
- pylint==3.0.2
12
- pytest==7.4.3
10
+ black==24.1.1
11
+ pylint==3.0.3
12
+ pytest==8.0.0
13
13
  pytest-cov==4.1.0
14
14
  requests-mock==1.11.0
15
15
  pytest-mock==3.12.0
File without changes
File without changes