Loading openflexure_microscope/common/labthings/plugins.py +6 −2 Original line number Diff line number Diff line Loading @@ -6,7 +6,11 @@ from importlib import util import sys from openflexure_microscope.config import USER_CONFIG_DIR from openflexure_microscope.utilities import camel_to_snake, camel_to_spine from openflexure_microscope.utilities import ( camel_to_snake, camel_to_spine, snake_to_spine, ) class BasePlugin: Loading Loading @@ -96,7 +100,7 @@ class BasePlugin: @property def _name_uri_safe(self): return camel_to_spine(self._name_python_safe) return snake_to_spine(self._name_python_safe) def find_plugins(plugin_path, module_name="plugins"): Loading openflexure_microscope/utilities.py +7 −1 Original line number Diff line number Diff line Loading @@ -12,12 +12,14 @@ def deserialise_array_b64(b64_string, dtype, shape): flat_arr = np.fromstring(base64.b64decode(b64_string), dtype) return flat_arr.reshape(shape) def serialise_array_b64(npy_arr): b64_string = base64.b64encode(npy_arr).decode('ascii') b64_string = base64.b64encode(npy_arr).decode("ascii") dtype = str(npy_arr.dtype) shape = npy_arr.shape return b64_string, dtype, shape def get_by_path(root, items): """Access a nested object in root by item sequence.""" return reduce(operator.getitem, items, root) Loading Loading @@ -69,6 +71,10 @@ def camel_to_spine(name): return re.sub("([a-z0-9])([A-Z])", r"\1-\2", s1).lower() def snake_to_spine(name): return name.replace("_", "-") @contextmanager def set_properties(obj, **kwargs): """A context manager to set, then reset, certain properties of an object. Loading Loading
openflexure_microscope/common/labthings/plugins.py +6 −2 Original line number Diff line number Diff line Loading @@ -6,7 +6,11 @@ from importlib import util import sys from openflexure_microscope.config import USER_CONFIG_DIR from openflexure_microscope.utilities import camel_to_snake, camel_to_spine from openflexure_microscope.utilities import ( camel_to_snake, camel_to_spine, snake_to_spine, ) class BasePlugin: Loading Loading @@ -96,7 +100,7 @@ class BasePlugin: @property def _name_uri_safe(self): return camel_to_spine(self._name_python_safe) return snake_to_spine(self._name_python_safe) def find_plugins(plugin_path, module_name="plugins"): Loading
openflexure_microscope/utilities.py +7 −1 Original line number Diff line number Diff line Loading @@ -12,12 +12,14 @@ def deserialise_array_b64(b64_string, dtype, shape): flat_arr = np.fromstring(base64.b64decode(b64_string), dtype) return flat_arr.reshape(shape) def serialise_array_b64(npy_arr): b64_string = base64.b64encode(npy_arr).decode('ascii') b64_string = base64.b64encode(npy_arr).decode("ascii") dtype = str(npy_arr.dtype) shape = npy_arr.shape return b64_string, dtype, shape def get_by_path(root, items): """Access a nested object in root by item sequence.""" return reduce(operator.getitem, items, root) Loading Loading @@ -69,6 +71,10 @@ def camel_to_spine(name): return re.sub("([a-z0-9])([A-Z])", r"\1-\2", s1).lower() def snake_to_spine(name): return name.replace("_", "-") @contextmanager def set_properties(obj, **kwargs): """A context manager to set, then reset, certain properties of an object. Loading