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