Commit 181f47b5 authored by Willi Rath's avatar Willi Rath

Add -X flag for wget

parent e2d9cd55
......@@ -209,11 +209,34 @@ class WgetRecursive(Renderer):
String containing a comma-separated list of patterns to be accepted.
(Example: Set to `"*.nc,*.nc.gz"` to only download `.nc` and `.nc.gz`
exclude_directories : str (optional)
String containing a comma-separated list of directories to be excluded.
(Example: Set to `"/some-path,/some-other-path"` to not download
anything from `<fqdn>/some-path/` and `<fqdn>/some-other-path/`.)
template = ("wget -nv -r -c -np -nH --cut-dirs={cut_dirs} "
"--accept \"{accept_files}\" -P \"{prefix}\" \"{url}\"\n")
template = ("wget -nv -r -c -np -nH --cut-dirs={cut_dirs}"
"{accept_files_string}{exclude_directories_string} "
"-P \"{prefix}\" \"{url}\"\n")
def __init__(self, yaml_dict=None, *args, **kwargs):
"""Construct `accept_files_string` and `exclude_directories_string`."""
if "accept_files" not in yaml_dict:
yaml_dct["accept_files_string"] = ""
yaml_dict["accept_files_string"] = (
" --accept \"{}\"".format(yaml_dict["accept_files"])
if "exclude_directories" not in yaml_dict:
yaml_dict["exclude_directories_string"] = ""
yaml_dict["exclude_directories_string"] = (
" -X \"{}\"".format(yaml_dict["exclude_directories"])
super(WgetRecursive, self).__init__(yaml_dict=yaml_dict, *args,
class WgetRecursiveCred(Renderer):
......@@ -16,7 +16,17 @@ def test_curl_single_file_rendering():
assert renderer.__str__ == target_string
def test_wget_recursive_rendering():
def test_wget_recursive_rendering_with_excluded_dirs():
yaml_dict = {"prefix": "pref", "cut_dirs": 77, "url": "http://url",
"accept_files": "*.*", "exclude_directories": "/asdf,/zxcv/a"}
target_string = ("wget -nv -r -c -np -nH --cut-dirs=77 "
"--accept \"*.*\" -X \"/asdf,/zxcv/a\" -P \"pref\" "
renderer = data_repo_renderer.WgetRecursive(yaml_dict=yaml_dict)
assert renderer.__str__ == target_string
def test_wget_recursive_rendering_without_excluded_dirs():
yaml_dict = {"prefix": "pref", "cut_dirs": 77, "url": "http://url",
"accept_files": "*.*"}
target_string = ("wget -nv -r -c -np -nH --cut-dirs=77 "
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment