Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

m.download.tnm: add -u option to list URLs #947

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/misc/m.download.tnm/m.download.tnm.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,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
Expand Down Expand Up @@ -230,6 +234,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"]

Expand Down Expand Up @@ -306,7 +311,7 @@ def main():
for code in sel_codes:
offset = 0
total = None
filenames = []
files = []
while not total or offset < total:
if total:
grass.message(
Expand Down Expand Up @@ -346,13 +351,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__":
Expand Down
Loading