download_file#

pytwin.download_file(file_name, directory, force_download=False, destination=None)#

Download a file that is used for a PyTwin example.

The files are downloaded from the PyTwin example files repository whose URL is given by the pytwin.examples.downloads.EXAMPLES_REPO constant. All example files are downloaded to a persistent cache to avoid downloading the same file twice.

Parameters:
file_namestr

Name of the example file.

directorystr

Path to the directory in the example files repository where the example file is stored.

force_downloadbool, optional

Whether to force deletion of an example file so that it can be downloaded again. The default is False.

destinationstr, optional

Path to download the example file to. The default is None, in which case the example file is downloaded to the user’s temporary folder.

Returns:
str

Path to the downloaded example file.

Examples

>>> from pytwin import download_file
>>> path = download_file("CoupledClutches_23R1_other.twin", "twin_files", force_download=True)