Fixed docstrings

This commit is contained in:
Joel Collins 2019-01-24 16:24:14 +00:00
parent 80cc74bd3d
commit 465ed647d3
6 changed files with 58 additions and 58 deletions

View file

@ -3,4 +3,6 @@ __version__ = "0.1.0"
from .microscope import Microscope
from . import config
from . import utilities
from . import utilities
from . import task
from . import lock

View file

@ -13,7 +13,7 @@ class ListAPI(MicroscopeView):
"""
Get list of image captures.
.. :quickref: Capture collection; Get collection of captures
.. :quickref: Captures; Get collection of captures
:>header Accept: application/json
:query include_unavailable: return json representations of captures that have been completely deleted
@ -45,7 +45,7 @@ class ListAPI(MicroscopeView):
"""
Delete all captures (not yet implemented)
.. :quickref: Capture collection; Delete all captures
.. :quickref: Captures; Delete all captures
"""
for image in self.microscope.camera.images:
image.delete()
@ -58,7 +58,7 @@ class ListAPI(MicroscopeView):
"""
Create a new image capture.
.. :quickref: Capture collection; New capture
.. :quickref: Captures; New capture
**Example request**:
@ -257,25 +257,6 @@ class CaptureAPI(MicroscopeView):
class DownloadRedirectAPI(MicroscopeView):
def get(self, capture_id):
"""
Redirect to download the capture under it's currently set filename.
I.e., `/(capture_id)/download` will
redirect to `/(capture_id)/download/(filename)`.
.. :quickref: Capture; Redirect to download
"""
capture_obj = self.microscope.camera.image_from_id(capture_id)
if not capture_obj or not capture_obj.state['available']:
return abort(404) # 404 Not Found
thumbnail = get_bool(request.args.get('thumbnail'))
return redirect(url_for('.capture_download', capture_id=capture_id, filename=capture_obj.filename, thumbnail=thumbnail), code=307)
class DownloadAPI(MicroscopeView):
def get(self, capture_id, filename):
"""
Return image data for a capture.
@ -283,7 +264,11 @@ class DownloadAPI(MicroscopeView):
I.e., `/(capture_id)/download/foo.jpeg` will download the image as
`foo.jpeg`, regardless of the capture's initially set filename.
.. :quickref: Capture; Download capture file
Route automatically redirects to download the capture under it's currently set filename.
I.e., `/(capture_id)/download` will
redirect to `/(capture_id)/download/(filename)`.
.. :quickref: Capture; Download capture image
**Example request**:
@ -298,6 +283,7 @@ class DownloadAPI(MicroscopeView):
:>header Content-Type: image/jpeg
:status 200: capture data found
:status 404: no capture found with that id
"""
capture_obj = self.microscope.camera.image_from_id(capture_id)
@ -306,6 +292,19 @@ class DownloadAPI(MicroscopeView):
thumbnail = get_bool(request.args.get('thumbnail'))
return redirect(url_for('.capture_download', capture_id=capture_id, filename=capture_obj.filename, thumbnail=thumbnail), code=307)
class DownloadAPI(MicroscopeView):
def get(self, capture_id, filename):
capture_obj = self.microscope.camera.image_from_id(capture_id)
if not capture_obj or not capture_obj.state['available']:
return abort(404) # 404 Not Found
thumbnail = get_bool(request.args.get('thumbnail'))
# If no filename is specified, redirect to the capture's currently set filename
if not filename:
return redirect(url_for('capture_download', capture_id=capture_id, filename=capture_obj.filename, thumbnail=thumbnail), code=307)
@ -323,23 +322,6 @@ class DownloadAPI(MicroscopeView):
class MetadataRedirectAPI(MicroscopeView):
def get(self, capture_id):
"""
Redirect to download the capture metadata under it's currently set filename.
I.e., `/(capture_id)/download` will
redirect to `/(capture_id)/download/(filename)`.
.. :quickref: Capture; Redirect to metadata
"""
capture_obj = self.microscope.camera.image_from_id(capture_id)
if not capture_obj or not capture_obj.state['available']:
return abort(404) # 404 Not Found
return redirect(url_for('.metadata_download', capture_id=capture_id, filename=capture_obj.metadataname), code=307)
class MetadataAPI(MicroscopeView):
def get(self, capture_id, filename):
"""
Return metadatadata for a capture.
@ -347,6 +329,10 @@ class MetadataAPI(MicroscopeView):
I.e., `/(capture_id)/download/bar.yaml` will download the file as
`bar.yaml`, regardless of the capture's initially set filename.
Route automatically redirects to download the capture metadata under it's currently set filename.
I.e., `/(capture_id)/download` will
redirect to `/(capture_id)/download/(filename)`.
.. :quickref: Capture; Download capture metadata
**Example request**:
@ -362,9 +348,21 @@ class MetadataAPI(MicroscopeView):
:>header Content-Type: text/yaml
:status 200: capture data found
:status 404: no capture found with that id
"""
capture_obj = self.microscope.camera.image_from_id(capture_id)
if not capture_obj or not capture_obj.state['available']:
return abort(404) # 404 Not Found
return redirect(url_for('.metadata_download', capture_id=capture_id, filename=capture_obj.metadataname), code=307)
class MetadataAPI(MicroscopeView):
def get(self, capture_id, filename):
capture_obj = self.microscope.camera.image_from_id(capture_id)
if not capture_obj or not capture_obj.state['available']:
return abort(404) # 404 Not Found

View file

@ -4,10 +4,10 @@ from openflexure_microscope.exceptions import LockError
class StrictLock(object):
"""
Class that behaves like a Python RLock, but with stricter timeout conditions and custom exceptions.
"""
def __init__(self, timeout=1):
"""
Class that behaves like a Python RLock, but with stricter timeout conditions and custom exceptions.
"""
self._lock = RLock()
self.timeout = timeout
@ -29,11 +29,11 @@ class StrictLock(object):
class CompositeLock(object):
"""
Class that behaves like a :py:class:`openflexure_microscope.lock.StrictLock`,
but allows multiple locks to be acquired and released.
"""
def __init__(self, locks, timeout=1):
"""
Class that behaves like a :py:class:`openflexure_microscope.lock.StrictLock`,
but allows multiple locks to be acquired and released.
"""
self.locks = locks
self.timeout = timeout

View file

@ -38,7 +38,7 @@ class Microscope(object):
self._config = config
# Create a task orchestrator
self.task = TaskOrchestrator()
self.task = TaskOrchestrator() #: :py:class:`openflexure_microscope.task.TaskOrchestrator`: Threaded task orchestrator
# Create plugin mountpoint
self.plugin = PluginMount(self) #: :py:class:`openflexure_microscope.plugins.PluginMount`: Mounting point for all microscope plugins

View file

@ -13,7 +13,7 @@ class IdentifyAPI(MicroscopeViewPlugin):
"""
Default plugin to return a plaintext representation of the camera and stage objects.
.. :quickref: Default plugin; Show representation of camera and stage objects.
.. :quickref: Default plugin; Identify hardware
"""
data = self.microscope.plugin.default.identify() # Call a method from our plugin, using the full route
return Response(escape(data))

View file

@ -8,11 +8,11 @@ from openflexure_microscope.exceptions import TaskDeniedException
from openflexure_microscope.utilities import entry_by_id
class TaskOrchestrator:
"""
Class responsible for spawning threaded tasks, and storing their returns.
A microscope should contain exactly one instance of `TaskOrchestrator`.
"""
def __init__(self):
"""
Class responsible for spawning threaded tasks, and storing their returns.
A microscope should contain exactly one instance of `TaskOrchestrator`.
"""
self.tasks = [] #: list: List of `Task` objects
@property
@ -79,11 +79,11 @@ class TaskOrchestrator:
class Task:
"""
Class responsible for running a task function in a thread, and handling return or errors.
Tasks should be created by an instance of :py:class:`openflexure_microscope.task.TaskOrchestrator`.
"""
def __init__(self, function, *args, **kwargs):
"""
Class responsible for running a task function in a thread, and handling return or errors.
Tasks should be created by an instance of :py:class:`openflexure_microscope.task.TaskOrchestrator`.
"""
# The task long-running method
self.task = function #: function: Function to be called in the task thread.
self.args = args #: Positional arguments to be passed to the task function.