Commit cfcee93b authored by Thomas Vincent's avatar Thomas Vincent
Browse files

docstring and code clean-up

parent d3107a5a
......@@ -49,8 +49,6 @@ _IMAGEFILE_LINE_PATTERN = ('^#C imageFile '
'nextNr\[(?P<nextNr>[^\]]*)\] '
'suffix\[(?P<suffix>[^\]]*)\]$')
# #######################################################################
# #######################################################################
......@@ -62,24 +60,23 @@ KmapMatchResults = namedtuple('KmapMatchResults',
'no_img_info', 'error',
'spec_h5'])
# #######################################################################
# #######################################################################
class KmapSpecParser(object):
(READY, RUNNING, DONE,
ERROR, CANCELED, UNKNOWN) = __STATUSES = range(6)
""" Available status codes """
"""Available status codes"""
status = property(lambda self: self.__status)
""" Current status code of this instance """
"""Current status code of this instance"""
statusMsg = property(lambda self: self.__status_msg)
""" Status message if any, or None """
"""Status message if any, or None"""
results = property(lambda self: self.__results)
""" Parse results. KmapParseResults instance. """
"""Parse results. KmapMatchResults instance."""
def __init__(self,
spec_fname,
......@@ -92,6 +89,7 @@ class KmapSpecParser(object):
"""
Parser for the Kmap SPEC files. This loads a spec file, converts
it to HDF5 and then tries to match scans and edf image files.
:param spec_fname: Path to the spec file.
:param spec_h5: Name of the HDF5 file that will be created and filled
with the contents of the SPEC file
......@@ -131,27 +129,25 @@ class KmapSpecParser(object):
self.__set_status(self.READY)
def __set_status(self, status, msg=None):
"""
Sets the status of this instance.
"""Sets the status of this instance.
:param status:
:param msg:
:return:
"""
assert status in self.__STATUSES
self.__status = status
self.__status_msg = msg
def parse(self, blocking=True):
"""
Starts the parsing.
"""Starts the parsing.
:param blocking: if False, the parsing will be done in a separate
thread and this method will return immediately.
:return:
"""
if self.__thread and self.__thread.is_alive():
raise RuntimeError('This KmapSpecParser instance is already '
'parsing.')
raise RuntimeError(
'This KmapSpecParser instance is already parsing.')
self.__results = None
......@@ -162,10 +158,7 @@ class KmapSpecParser(object):
thread.start()
def __run_parse(self):
"""
Runs the parsing.
:return:
"""
"""Runs the parsing."""
self.__set_status(self.RUNNING)
......@@ -185,8 +178,6 @@ class KmapSpecParser(object):
if self.__callback:
self.__callback()
return self.__results
def wait(self):
"""
Waits until parsing is done, or returns if it is not running.
......
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