Extension for Foliant documentation tool to download external files during project build.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file foliantcontrib.downloadfile-1.0.1.tar.gz.
File metadata
- Download URL: foliantcontrib.downloadfile-1.0.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3ea2234be08fa395c8b43f603fd15883d39be74a11121318a052ce882ea582a
|
|
| MD5 |
ad0fcf6e99add8aa453d81d412320cdc
|
|
| BLAKE2b-256 |
b3d63f9e14e2193f7040cdb0b36ff2ebeda20b031dff91a560e1de7132f0f744
|
File details
Details for the file foliantcontrib.downloadfile-1.0.1-py3-none-any.whl.
File metadata
- Download URL: foliantcontrib.downloadfile-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5a03e8211f5da18a83d2cc9d34ffd34a28ffd2916f9517d290dc10e3bc32330
|
|
| MD5 |
aee8b6332fd4b4228414dab8eef54add
|
|
| BLAKE2b-256 |
f7e22331fca9705d1203160a5f2382db9adc58430afcb9664e6719c9aa73a9fe
|