Commit c382db56 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

ENH: Plugin/manifest model supports version/terms of use fields

parent 8a921842
......@@ -16,31 +16,36 @@ list of FSL plugin definitions, e.g.::
"url" : "http://.../UnixIntro.zip",
"checksum" : "f8222...",
"description" : "Data for the unix introduction",
"version" : "1.2.3",
"destination" : "~/"
},
{
"name" : "Preparatory material",
"category" : "fsl_course_data",
"url" : "http://...preCourse.zip",
"checksum" : "e659f",
"description" : "Data for the preparatory practicals",
"destination" : "~/"
"name" : "ABCD123 Mouse atlas",
"category" : "fsl_atlases",
"url" : "http://localhost:8000/abcd123_mouse_atlas.tar.gz",
"checksum" : "658701ff9a49b06f0d0ee38bce36a1c370fdfd0751ab17c2fd7b7b561d3b92e0",
"description" : "ABCD123 FSL mouse atlas derived from hand segmentations of 3813 small chocolate mice.",
"terms_of_use" : "https://chocolate-mouse.com/terms-of-use",
"destination" : "$FSLDIR/data/atlases/"
}
]
Each plugin definition must contain the ``url`` field; all other fieids are
optional but recommended:
- ``name``: A unique name for the plugin. Defaults to the filename
component of the ``url``.
- ``url``: URL of the plugin archive file.
- ``category``: The plugin category, used to organise plugins.
- ``checksum``: A SHA256 checksum of the plugin archive file, used to
verify that it has been successfully downloaded.
- ``description``: An extended description of the plugin
- ``destination``: Default installation directory. May contain environment
variables and ``~``.
"""
- ``name``: A unique name for the plugin. Defaults to the filename
component of the ``url``.
- ``url``: URL of the plugin archive file.
- ``category``: The plugin category, used to organise plugins.
- ``checksum``: A SHA256 checksum of the plugin archive file, used to
verify that it has been successfully downloaded.
- ``description``: An extended description of the plugin
- ``version``: A version identifier for the plugin (used solely for
descriptive purposes)
- ``tersm_of_use``: Terms of use for the plugin (displayed to the user)
- ``destination``: Default installation directory. May contain environment
variables and ``~``.
""" # noqa: E501
import os.path as op
......@@ -93,6 +98,15 @@ class Plugin:
"""SHA256 checksum of the plugin archive file, used to verify downloads.
"""
version : Optional[str] = None
"""Version identifier for the plugin - displayed to the user, but not
used for any other purpose.
"""
termsOfUse : Optional[str] = None
"""Terms of use for the plugin - displayed to the user during installation.
"""
destination : Union[None, str, pathlib.Path] = None
"""Installation/destination directory - where the plugin archive file
will be extracted. May have a default value in the manifest, but may
......@@ -135,6 +149,8 @@ class Manifest(dict):
description : Optional[str] = None,
category : Optional[str] = None,
checksum : Optional[str] = None,
version : Optional[str] = None,
termsOfUse : Optional[str] = None,
destination : Optional[str] = None) -> str:
"""Add a new :class:`Plugin` to the manifest.
......@@ -144,6 +160,8 @@ class Manifest(dict):
:arg description: Extended description of plugin
:arg category: Plugin category
:arg checksum: SHA256 checksum of archive file.
:arg version: Version identifier for the plugin.
:arg termsOfUse: Terms of use for the plugin.
:arg destination: Default installation directory.
:returns: The registered plugin name (equivalent to ``name``,
if provided).
......@@ -185,6 +203,8 @@ class Manifest(dict):
category=category,
description=description,
checksum=checksum,
version=version,
termsOfUse=termsOfUse,
destination=destination,
origDestination=origDestination,
archiveFile=archiveFile,
......@@ -249,6 +269,8 @@ def downloadManifest(url : Union[str, pathlib.Path]) -> Manifest:
description=plugin.get('description'),
category=plugin.get('category'),
checksum=plugin.get('checksum'),
version=plugin.get('version'),
termsOfUse=plugin.get('terms_of_use'),
destination=plugin.get('destination'))
except KeyError as e:
raise ManifestInvalid(f'The manifest file {url} '
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment