Skip to main content

DownloadFile Extension

DownloadFile is a configuration extension for Foliant which downloads external files to use in your project.

It also resolves !download YAML tag in the project config and inside XML-tags parameters.

Installation

$ pip install foliantcontrib.downloadfile

Usage

To configure DownloadFile add the following section to your foliant.yml file:

downloadfile:
    fail_fast: true
    ignore_ssl_errors: false
    queue:
        - url: https://example.com/image.png  # required
          save_to: images/img1.png
          login: john
          password: qwerty123
        - ...

fail_fast : When true, build will be stopped if any file can't be downloaded. If false ­— unavailable files will be just skipped. Doesn't affect !download tag, this one will always break the build on errors. Default: true.

ignore_ssl_errors : Switch to true to skip SSL certificate check. Default: false.

queue : list of files to download. Each file is represented by a dictionary with the following fields:

url : (requried) URL to the file which should be downloaded.

save_to : path where the downloaded file should be saved, relative to the project root. If not supplied, file will be saved in the project root with the name from url.

login : login for basic authentication.

password : password for basic authentication.

Warning: don't store plain text passwords in foliant.yml. Use environment variables.

!download YAML tag

Another way to use DownloadFile is by specifying !download YAML tag. This is the quickest and the simplest way, but it comes with a few disadvantages.

Insert the !download tag, followed by file URL, in any place in foliant.yml or tag parameters, where file path is expected:

preprocessors:
    - swaggerdoc:
        spec_path: !download https://example.com/swagger.json
        mode: widdershins
Generated template:

<template engine="jinja2" ext_context="!download https://example.com/mycontext.yml">
...
</template>

The downloaded file will be saved in the .downloadfilecache directory under a hashed name, and the !download tag will be replaced by absolute path to this file.

The cons of this method are that you can't change the saved file path nor other parameters. Also if you reference the same file twice with !download tag, it will be downloaded two times.

Metadata

Release files for foliantcontrib.downloadfile 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for foliantcontrib.downloadfile 1.0.1
File Size Uploaded
foliantcontrib.downloadfile-1.0.1.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for foliantcontrib.downloadfile 1.0.1
File Interpreter ABI Platform
foliantcontrib.downloadfile-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.7 kB

Release files / foliantcontrib.downloadfile-1.0.1.tar.gz

Download URL foliantcontrib.downloadfile-1.0.1.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d3ea2234be08fa395c8b43f603fd15883d39be74a11121318a052ce882ea582a
BLAKE2b-256 checksum
How to use checksums
b3d63f9e14e2193f7040cdb0b36ff2ebeda20b031dff91a560e1de7132f0f744
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5

Release files / foliantcontrib.downloadfile-1.0.1-py3-none-any.whl

Download URL foliantcontrib.downloadfile-1.0.1-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d5a03e8211f5da18a83d2cc9d34ffd34a28ffd2916f9517d290dc10e3bc32330
BLAKE2b-256 checksum
How to use checksums
f7e22331fca9705d1203160a5f2382db9adc58430afcb9664e6719c9aa73a9fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page