Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__pycache__/
/dist/
/*.egg*
66 changes: 29 additions & 37 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
repos:
- repo: https://github.com/bemeurer/beautysh
rev: 'v6.2.1'
hooks:
- id: beautysh
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: '3.0.0'
hooks:
- id: shellcheck
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
- id: check-yaml
- id: check-xml
- id: check-symlinks
- id: check-vcs-permalinks
- id: trailing-whitespace
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
- repo: https://github.com/pycqa/flake8
rev: '6.1.0' # pick a git hash / tag to point to
hooks:
- id: flake8
args: ["--ignore=E501,W503,E722"]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.10.1
hooks:
- id: black
language_version: python3.11
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- repo: https://github.com/lovesegfault/beautysh
rev: v6.2.1
hooks: [{id: beautysh}]
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: '3.0.0'
hooks: [{id: shellcheck}]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
- id: check-yaml
- id: check-xml
- id: check-symlinks
- id: check-vcs-permalinks
- id: trailing-whitespace
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
- repo: https://github.com/pycqa/flake8
rev: '7.0.0' # pick a git hash / tag to point to
hooks:
- id: flake8
args: ["--ignore=E203,E501,W503,E722"]
- repo: https://github.com/psf/black
rev: '24.3.0'
hooks: [{id: black}]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ Special parameters:
- ``-m`` : generate md5sums.txt for verification. Beware, if `md5sums.txt` is
present in the dataset, it will overwrite this generated file. Verification example:
`md5sum -c md5sums.txt`
- ``-g GLOB`` : A [glob](https://docs.python.org/3/library/fnmatch.html) expression to
select a subset of record files.
- ``-w FILE`` : instead of downloading the record files, it will
generate a FILE which contains direct links to the Zenodo site. These links
could be downloaded with any download manager, e.g. with wget:
Expand All @@ -77,7 +79,7 @@ Special parameters:
- ``-n`` : do not continue. The default behaviour is to download only the files
which are not yet download or where the checksum does not match with the file.
This flag disables this feature, and it will force download existing files,
and assigining a new name to the files (e.g. file(1).ext )
and assigning a new name to the files (e.g. file(1).ext )


Remark for batch processing: the program always exits with non-zero exit code, if any error has happened,
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ matrix:

platform:
-x64

install:
- "SET PATH=C:\\Python38-x64;%PATH%"
- "python -m pip install -r requirements.txt"
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[metadata]
description-file = README.md

2 changes: 1 addition & 1 deletion tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

CMD="python3 -m coverage run -a --source zenodo_get -m zenodo_get"
$CMD
$CMD
$CMD -h
$CMD --cite

Expand Down
1 change: 0 additions & 1 deletion tests/win-test.bat
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ python -m zenodo_get -d 10.5281/zenodo.1215979 -w urls.txt -n
python -m zenodo_get -r 1215979 -w -
python -m zenodo_get 1215979 -R 3 -p 2 -n
python -m zenodo_get 1215979

34 changes: 26 additions & 8 deletions zenodo_get/zget.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#!/usr/bin/env python3
import zenodo_get as zget
import requests
import hashlib
import sys
import os
from optparse import OptionParser
import wget
import time
import requests
import signal
from pathlib import Path
import sys
import time
import wget
import zenodo_get as zget
from contextlib import contextmanager
from fnmatch import fnmatch
from optparse import OptionParser
from pathlib import Path
from urllib.parse import unquote


Expand Down Expand Up @@ -221,6 +222,16 @@ def zenodo_get(argv=None):
help="Optional access token for the requests query.",
)

parser.add_option(
"-g",
"--glob",
action="store",
type=str,
dest="glob",
default="*",
help="Optional glob expression for files.",
)

(options, args) = parser.parse_args(argv)

if options.cite:
Expand Down Expand Up @@ -306,7 +317,14 @@ def zenodo_get(argv=None):

if r.ok:
js = r.json()
files = js["files"]
files = [
f
for f in js["files"]
if fnmatch(f.get("filename") or f["key"], options.glob)
]
if not files:
eprint("Files {} not found in metadata".format(options.glob))

total_size = sum((f.get("filesize") or f["size"]) for f in files)

if options.md5 is not None:
Expand Down
Loading