From 19aeae29a22f3c8f4e673ed17cd8d1d882f3f9a9 Mon Sep 17 00:00:00 2001 From: Huidae Cho Date: Tue, 26 Sep 2023 20:34:49 -0600 Subject: [PATCH 1/2] Add -u option to list URLs --- src/misc/m.download.tnm/m.download.tnm.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/misc/m.download.tnm/m.download.tnm.py b/src/misc/m.download.tnm/m.download.tnm.py index 12f637694f..0f8eef062f 100755 --- a/src/misc/m.download.tnm/m.download.tnm.py +++ b/src/misc/m.download.tnm/m.download.tnm.py @@ -56,6 +56,7 @@ # % description: End date for search in YYYY-MM-DD # %end # %option G_OPT_F_SEP +# % answer: newline # %end # %flag # % key: d @@ -66,6 +67,10 @@ # % label: List supported states and exit # %end # %flag +# % key: u +# % label: List URLs only without downloading +# %end +# %flag # % key: f # % label: List filenames only without downloading # %end @@ -230,6 +235,7 @@ def main(): fs = separator(options["separator"]) list_datasets = flags["d"] list_states = flags["s"] + list_urls = flags["u"] list_filenames = flags["f"] compare_file_size = flags["S"] @@ -306,7 +312,7 @@ def main(): for code in sel_codes: offset = 0 total = None - filenames = [] + files = [] while not total or offset < total: if total: grass.message( @@ -346,13 +352,15 @@ def main(): items = ret["items"] for item in items: - if list_filenames: - filenames.append(item["downloadURL"].split("/")[-1]) + if list_urls: + files.append(item["downloadURL"]) + elif list_filenames: + files.append(item["downloadURL"].split("/")[-1]) else: download_file(item, code, compare_file_size) offset += len(items) - if filenames: - print(fs.join(filenames)) + if files: + print(fs.join(files)) if __name__ == "__main__": From 143d69b8cb273121b95843d2cd88f8c9d91f6fb9 Mon Sep 17 00:00:00 2001 From: Huidae Cho Date: Tue, 26 Sep 2023 20:39:03 -0600 Subject: [PATCH 2/2] Remove newline default --- src/misc/m.download.tnm/m.download.tnm.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/misc/m.download.tnm/m.download.tnm.py b/src/misc/m.download.tnm/m.download.tnm.py index 0f8eef062f..ff759f3c76 100755 --- a/src/misc/m.download.tnm/m.download.tnm.py +++ b/src/misc/m.download.tnm/m.download.tnm.py @@ -56,7 +56,6 @@ # % description: End date for search in YYYY-MM-DD # %end # %option G_OPT_F_SEP -# % answer: newline # %end # %flag # % key: d