prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  pyhf contrib download fails gracelessly with invalid URL
  # Description
  
  calling `pyhf contrib download` (just to see what it does) fails pretty violently. hould we make itt a bit nicer @matthewfeickert 
  ?
  
  ```
  pyhf contrib download
  Traceback (most recent call last):
    File "/Users/lukasheinrich/Code/pyhfdev/dev/pyhfdevenv/bin/pyhf", line 33, in <module>
      sys.exit(load_entry_point('pyhf', 'console_scripts', 'pyhf')())
    File "/Users/lukasheinrich/Code/pyhfdev/dev/pyhfdevenv/lib/python3.7/site-packages/click/core.py", line 829, in __call__
      return self.main(*args, **kwargs)
    File "/Users/lukasheinrich/Code/pyhfdev/dev/pyhfdevenv/lib/python3.7/site-packages/click/core.py", line 782, in main
      rv = self.invoke(ctx)
    File "/Users/lukasheinrich/Code/pyhfdev/dev/pyhfdevenv/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
      return _process_result(sub_ctx.command.invoke(sub_ctx))
    File "/Users/lukasheinrich/Code/pyhfdev/dev/pyhfdevenv/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
      return _process_result(sub_ctx.command.invoke(sub_ctx))
    File "/Users/lukasheinrich/Code/pyhfdev/dev/pyhfdevenv/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
      return ctx.invoke(self.callback, **ctx.params)
    File "/Users/lukasheinrich/Code/pyhfdev/dev/pyhfdevenv/lib/python3.7/site-packages/click/core.py", line 610, in invoke
      return callback(*args, **kwargs)
    File "/Users/lukasheinrich/Code/pyhfdev/dev/pyhfsrc/src/pyhf/cli/contrib.py", line 60, in download
      utils.download(archive_url, output_directory, force, compress)
    File "/Users/lukasheinrich/Code/pyhfdev/dev/pyhfsrc/src/pyhf/contrib/utils.py", line 47, in download
      + "To download an archive from this host use the --force option."
  pyhf.exceptions.InvalidArchiveHost:  is not an approved archive host: www.hepdata.net, doi.org
  To download an archive from this host use the --force option.
  ```
  
  
  </issue>
  <code>
  [start of src/pyhf/cli/contrib.py]
  1 """CLI for functionality that will get migrated out eventually."""
  2 import logging
  3 import click
  4 from pathlib import Path
  5 
  6 from ..contrib import utils
  7 
  8 logging.basicConfig()
  9 log = logging.getLogger(__name__)
  10 
  11 
  12 @click.group(name="contrib")
  13 def cli():
  14     """
  15     Contrib experimental operations.
  16 
  17     .. note::
  18 
  19         Requires installation of the ``contrib`` extra.
  20 
  21         .. code-block:: shell
  22 
  23             $ python -m pip install pyhf[contrib]
  24     """
  25 
  26 
  27 @cli.command()
  28 @click.argument("archive-url", default="-")
  29 @click.argument("output-directory", default="-")
  30 @click.option("-v", "--verbose", is_flag=True, help="Enables verbose mode")
  31 @click.option(
  32     "-f", "--force", is_flag=True, help="Force download from non-approved host"
  33 )
  34 @click.option(
  35     "-c",
  36     "--compress",
  37     is_flag=True,
  38     help="Keep the archive in a compressed tar.gz form",
  39 )
  40 def download(archive_url, output_directory, verbose, force, compress):
  41     """
  42     Download the patchset archive from the remote URL and extract it in a
  43     directory at the path given.
  44 
  45     Example:
  46 
  47     .. code-block:: shell
  48 
  49         $ pyhf contrib download --verbose https://www.hepdata.net/record/resource/1408476?view=true 1Lbb-likelihoods
  50 
  51         \b
  52         1Lbb-likelihoods/patchset.json
  53         1Lbb-likelihoods/README.md
  54         1Lbb-likelihoods/BkgOnly.json
  55 
  56     Raises:
  57         :class:`~pyhf.exceptions.InvalidArchiveHost`: if the provided archive host name is not known to be valid
  58     """
  59     try:
  60         utils.download(archive_url, output_directory, force, compress)
  61 
  62         if verbose:
  63             file_list = [str(file) for file in list(Path(output_directory).glob("*"))]
  64             print("\n".join(file_list))
  65     except AttributeError as excep:
  66         exception_info = (
  67             str(excep)
  68             + "\nInstallation of the contrib extra is required to use the contrib CLI API"
  69             + "\nPlease install with: python -m pip install pyhf[contrib]\n"
  70         )
  71         log.error(exception_info)
  72
  [end of src/pyhf/cli/contrib.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/src/pyhf/cli/contrib.py b/src/pyhf/cli/contrib.py
  --- a/src/pyhf/cli/contrib.py
  +++ b/src/pyhf/cli/contrib.py
  @@ -25,8 +25,8 @@
   
   
   @cli.command()
  -@click.argument("archive-url", default="-")
  -@click.argument("output-directory", default="-")
  +@click.argument("archive-url")
  +@click.argument("output-directory")
   @click.option("-v", "--verbose", is_flag=True, help="Enables verbose mode")
   @click.option(
       "-f", "--force", is_flag=True, help="Force download from non-approved host"
  
verification_info: {"golden_diff": "diff --git a/src/pyhf/cli/contrib.py b/src/pyhf/cli/contrib.py\n--- a/src/pyhf/cli/contrib.py\n+++ b/src/pyhf/cli/contrib.py\n@@ -25,8 +25,8 @@\n \n \n @cli.command()\n-@click.argument(\"archive-url\", default=\"-\")\n-@click.argument(\"output-directory\", default=\"-\")\n+@click.argument(\"archive-url\")\n+@click.argument(\"output-directory\")\n @click.option(\"-v\", \"--verbose\", is_flag=True, help=\"Enables verbose mode\")\n @click.option(\n     \"-f\", \"--force\", is_flag=True, help=\"Force download from non-approved host\"\n", "issue": "pyhf contrib download fails gracelessly with invalid URL\n# Description\r\n\r\ncalling `pyhf contrib download` (just to see what it does) fails pretty violently. hould we make itt a bit nicer @matthewfeickert \r\n?\r\n\r\n```\r\npyhf contrib download\r\nTraceback (most recent call last):\r\n  File \"/Users/lukasheinrich/Code/pyhfdev/dev/pyhfdevenv/bin/pyhf\", line 33, in <module>\r\n    sys.exit(load_entry_point('pyhf', 'console_scripts', 'pyhf')())\r\n  File \"/Users/lukasheinrich/Code/pyhfdev/dev/pyhfdevenv/lib/python3.7/site-packages/click/core.py\", line 829, in __call__\r\n    return self.main(*args, **kwargs)\r\n  File \"/Users/lukasheinrich/Code/pyhfdev/dev/pyhfdevenv/lib/python3.7/site-packages/click/core.py\", line 782, in main\r\n    rv = self.invoke(ctx)\r\n  File \"/Users/lukasheinrich/Code/pyhfdev/dev/pyhfdevenv/lib/python3.7/site-packages/click/core.py\", line 1259, in invoke\r\n    return _process_result(sub_ctx.command.invoke(sub_ctx))\r\n  File \"/Users/lukasheinrich/Code/pyhfdev/dev/pyhfdevenv/lib/python3.7/site-packages/click/core.py\", line 1259, in invoke\r\n    return _process_result(sub_ctx.command.invoke(sub_ctx))\r\n  File \"/Users/lukasheinrich/Code/pyhfdev/dev/pyhfdevenv/lib/python3.7/site-packages/click/core.py\", line 1066, in invoke\r\n    return ctx.invoke(self.callback, **ctx.params)\r\n  File \"/Users/lukasheinrich/Code/pyhfdev/dev/pyhfdevenv/lib/python3.7/site-packages/click/core.py\", line 610, in invoke\r\n    return callback(*args, **kwargs)\r\n  File \"/Users/lukasheinrich/Code/pyhfdev/dev/pyhfsrc/src/pyhf/cli/contrib.py\", line 60, in download\r\n    utils.download(archive_url, output_directory, force, compress)\r\n  File \"/Users/lukasheinrich/Code/pyhfdev/dev/pyhfsrc/src/pyhf/contrib/utils.py\", line 47, in download\r\n    + \"To download an archive from this host use the --force option.\"\r\npyhf.exceptions.InvalidArchiveHost:  is not an approved archive host: www.hepdata.net, doi.org\r\nTo download an archive from this host use the --force option.\r\n```\r\n\n", "before_files": [{"content": "\"\"\"CLI for functionality that will get migrated out eventually.\"\"\"\nimport logging\nimport click\nfrom pathlib import Path\n\nfrom ..contrib import utils\n\nlogging.basicConfig()\nlog = logging.getLogger(__name__)\n\n\n@click.group(name=\"contrib\")\ndef cli():\n    \"\"\"\n    Contrib experimental operations.\n\n    .. note::\n\n        Requires installation of the ``contrib`` extra.\n\n        .. code-block:: shell\n\n            $ python -m pip install pyhf[contrib]\n    \"\"\"\n\n\n@cli.command()\n@click.argument(\"archive-url\", default=\"-\")\n@click.argument(\"output-directory\", default=\"-\")\n@click.option(\"-v\", \"--verbose\", is_flag=True, help=\"Enables verbose mode\")\n@click.option(\n    \"-f\", \"--force\", is_flag=True, help=\"Force download from non-approved host\"\n)\n@click.option(\n    \"-c\",\n    \"--compress\",\n    is_flag=True,\n    help=\"Keep the archive in a compressed tar.gz form\",\n)\ndef download(archive_url, output_directory, verbose, force, compress):\n    \"\"\"\n    Download the patchset archive from the remote URL and extract it in a\n    directory at the path given.\n\n    Example:\n\n    .. code-block:: shell\n\n        $ pyhf contrib download --verbose https://www.hepdata.net/record/resource/1408476?view=true 1Lbb-likelihoods\n\n        \\b\n        1Lbb-likelihoods/patchset.json\n        1Lbb-likelihoods/README.md\n        1Lbb-likelihoods/BkgOnly.json\n\n    Raises:\n        :class:`~pyhf.exceptions.InvalidArchiveHost`: if the provided archive host name is not known to be valid\n    \"\"\"\n    try:\n        utils.download(archive_url, output_directory, force, compress)\n\n        if verbose:\n            file_list = [str(file) for file in list(Path(output_directory).glob(\"*\"))]\n            print(\"\\n\".join(file_list))\n    except AttributeError as excep:\n        exception_info = (\n            str(excep)\n            + \"\\nInstallation of the contrib extra is required to use the contrib CLI API\"\n            + \"\\nPlease install with: python -m pip install pyhf[contrib]\\n\"\n        )\n        log.error(exception_info)\n", "path": "src/pyhf/cli/contrib.py"}]}