Download and optionally load data into the application. :param uris: Download URL(s). :param fileNames: File name(s) that will be downloaded (and loaded). :param nodeNames: Node name(s) in the scene. :param checksums: Checksum(s) formatted as `` : `` to v
(self, uris=None, fileNames=None, nodeNames=None, checksums=None, loadFiles=None,
customDownloader=None, loadFileTypes=None, loadFileProperties={}, forceDownload=False)
| 999 | return None |
| 1000 | |
| 1001 | def downloadFromURL(self, uris=None, fileNames=None, nodeNames=None, checksums=None, loadFiles=None, |
| 1002 | customDownloader=None, loadFileTypes=None, loadFileProperties={}, forceDownload=False): |
| 1003 | """Download and optionally load data into the application. |
| 1004 | |
| 1005 | :param uris: Download URL(s). |
| 1006 | :param fileNames: File name(s) that will be downloaded (and loaded). |
| 1007 | :param nodeNames: Node name(s) in the scene. |
| 1008 | :param checksums: Checksum(s) formatted as ``<algo>:<digest>`` to verify the downloaded file(s). For example, ``SHA256:cc211f0dfd9a05ca3841ce1141b292898b2dd2d3f08286affadf823a7e58df93``. |
| 1009 | :param loadFiles: Boolean indicating if file(s) should be loaded. By default, the function decides. |
| 1010 | :param customDownloader: Custom function for downloading. |
| 1011 | :param loadFileTypes: file format name(s) (if not specified then the default file reader will be used). |
| 1012 | :param loadFileProperties: custom properties passed to the IO plugin. |
| 1013 | |
| 1014 | If the given ``fileNames`` are not found in the application cache directory, they |
| 1015 | are downloaded using the associated URIs. |
| 1016 | See ``slicer.mrmlScene.GetCacheManager().GetRemoteCacheDirectory()`` |
| 1017 | |
| 1018 | If not explicitly provided or if set to ``None``, the ``loadFileTypes`` are |
| 1019 | guessed based on the corresponding filename extensions and file content. |
| 1020 | |
| 1021 | Special behavior for scene and archive files: |
| 1022 | - If a ``fileName`` has the ``.mrb`` or ``.mrml`` extension, it will **not** be loaded |
| 1023 | by default. To ensure the file is loaded, ``loadFiles`` must be set. |
| 1024 | - If a ``fileName`` has the ``.zip`` extension and ``loadFiles`` is set to ``True`` (or left at default value) |
| 1025 | then the archive is extracted and the folder that contains the files is returned. |
| 1026 | If ``loadFiles`` is set to ``False`` then the archive is not extracted and the filepath of the downloaded |
| 1027 | zip file is returned. |
| 1028 | |
| 1029 | The ``loadFileProperties`` are common for all files. If different properties |
| 1030 | need to be associated with files of different types, downloadFromURL must |
| 1031 | be called for each. |
| 1032 | |
| 1033 | If ``forceDownload`` is True then existing files are downloaded again (if no hash is provided). |
| 1034 | """ |
| 1035 | source = SampleDataSource( |
| 1036 | uris=uris, fileNames=fileNames, nodeNames=nodeNames, loadFiles=loadFiles, |
| 1037 | loadFileTypes=loadFileTypes, loadFileProperties=loadFileProperties, checksums=checksums, |
| 1038 | customDownloader=customDownloader) |
| 1039 | return self.downloadFromSource(source, forceDownload=forceDownload) |
| 1040 | |
| 1041 | def downloadSample(self, sampleName): |
| 1042 | """For a given sample name this will search the available sources |