From 0b776a088f3aeed9549694691374774540b97468 Mon Sep 17 00:00:00 2001 From: Mike Metcalfe Date: Tue, 6 Aug 2024 17:45:26 +0200 Subject: [PATCH 1/2] Fixed import of format_keyword to new position in utils --- .flake8 | 2 ++ CHANGES.rst | 1 + .../instruments/agilent/chemstation/chemstation.py | 6 +++--- .../instruments/instruments/agilent/masshunter/aorc.py | 4 ++-- .../instruments/agilent/masshunter/qualitative.py | 6 +++--- .../instruments/agilent/masshunter/quantitative.py | 6 +++--- 6 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 .flake8 diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..e44b810 --- /dev/null +++ b/.flake8 @@ -0,0 +1,2 @@ +[flake8] +ignore = E501 diff --git a/CHANGES.rst b/CHANGES.rst index 91fe8d9..a1cafee 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,7 @@ Changelog 1.0.0 (unreleased) ------------------ +- #9 Fix import of format_keyword from new place in utils - #8 Fix nexion350x Instrument by not lowering keywords - #7 Fix Winlab Instrument by not lowering keywords - First version of `senaite.instruments` diff --git a/src/senaite/instruments/instruments/agilent/chemstation/chemstation.py b/src/senaite/instruments/instruments/agilent/chemstation/chemstation.py index b22afaa..95d8313 100644 --- a/src/senaite/instruments/instruments/agilent/chemstation/chemstation.py +++ b/src/senaite/instruments/instruments/agilent/chemstation/chemstation.py @@ -8,7 +8,7 @@ from senaite.core.exportimport.instruments import IInstrumentAutoImportInterface from senaite.core.exportimport.instruments import IInstrumentExportInterface from senaite.core.exportimport.instruments import IInstrumentImportInterface -from senaite.core.exportimport.instruments.instrument import format_keyword +from senaite.core.exportimport.instruments.utils import format_keyword from senaite.core.exportimport.instruments.resultsimport import AnalysisResultsImporter from bika.lims.utils import t from cStringIO import StringIO @@ -74,7 +74,7 @@ def Export(self, context, request): options['dilute_factor'], ""]) ARs_exported.append(p_uid) - tmprows.sort(lambda a, b: cmp(a[1], b[1])) + tmprows.sort(lambda a, b: cmp(a[1], b[1])) # noqa rows += tmprows ramdisk = StringIO() @@ -244,7 +244,7 @@ def Import(self, context, request): errors = importer.errors logs = importer.logs warns = importer.warns - except Exception as e: + except Exception: tbex = traceback.format_exc() errors.append(tbex) diff --git a/src/senaite/instruments/instruments/agilent/masshunter/aorc.py b/src/senaite/instruments/instruments/agilent/masshunter/aorc.py index dc4d73d..e8f4eed 100644 --- a/src/senaite/instruments/instruments/agilent/masshunter/aorc.py +++ b/src/senaite/instruments/instruments/agilent/masshunter/aorc.py @@ -6,7 +6,7 @@ from bika.lims import bikaMessageFactory as _ from senaite.core.exportimport.instruments import IInstrumentAutoImportInterface from senaite.core.exportimport.instruments import IInstrumentImportInterface -from senaite.core.exportimport.instruments.instrument import format_keyword +from senaite.core.exportimport.instruments.utils import format_keyword from senaite.core.exportimport.instruments.resultsimport import AnalysisResultsImporter from bika.lims.utils import t from DateTime import DateTime @@ -178,7 +178,7 @@ def Import(self, context, request): errors = importer.errors logs = importer.logs warns = importer.warns - except Exception as e: + except Exception: tbex = traceback.format_exc() errors.append(tbex) diff --git a/src/senaite/instruments/instruments/agilent/masshunter/qualitative.py b/src/senaite/instruments/instruments/agilent/masshunter/qualitative.py index 9512cd9..bf4a637 100644 --- a/src/senaite/instruments/instruments/agilent/masshunter/qualitative.py +++ b/src/senaite/instruments/instruments/agilent/masshunter/qualitative.py @@ -8,7 +8,7 @@ from senaite.core.exportimport.instruments import IInstrumentAutoImportInterface from senaite.core.exportimport.instruments import IInstrumentExportInterface from senaite.core.exportimport.instruments import IInstrumentImportInterface -from senaite.core.exportimport.instruments.instrument import format_keyword +from senaite.core.exportimport.instruments.utils import format_keyword from senaite.core.exportimport.instruments.resultsimport import AnalysisResultsImporter from senaite.core.exportimport.instruments.resultsimport import InstrumentCSVResultsFileParser from bika.lims.utils import t @@ -177,7 +177,7 @@ def Import(self, context, request): errors = importer.errors logs = importer.logs warns = importer.warns - except Exception as e: + except Exception: tbex = traceback.format_exc() errors.append(tbex) @@ -245,7 +245,7 @@ def Export(self, context, request): 'analysis_uid': getAdapter(item['analysis_uid'], ISuperModel), 'sample': getAdapter(item['container_uid'], ISuperModel) }) - rows.sort(lambda a, b: cmp(a['cup'], b['cup'])) + rows.sort(lambda a, b: cmp(a['cup'], b['cup'])) # noqa cnt = 0 for row in rows: diff --git a/src/senaite/instruments/instruments/agilent/masshunter/quantitative.py b/src/senaite/instruments/instruments/agilent/masshunter/quantitative.py index c4bb7a2..58bb44d 100644 --- a/src/senaite/instruments/instruments/agilent/masshunter/quantitative.py +++ b/src/senaite/instruments/instruments/agilent/masshunter/quantitative.py @@ -8,7 +8,7 @@ from senaite.core.exportimport.instruments import IInstrumentAutoImportInterface from senaite.core.exportimport.instruments import IInstrumentExportInterface from senaite.core.exportimport.instruments import IInstrumentImportInterface -from senaite.core.exportimport.instruments.instrument import format_keyword +from senaite.core.exportimport.instruments.utils import format_keyword from senaite.core.exportimport.instruments.resultsimport import AnalysisResultsImporter from senaite.core.exportimport.instruments.resultsimport import InstrumentCSVResultsFileParser from bika.lims.utils import t @@ -198,7 +198,7 @@ def Import(self, context, request): errors = importer.errors logs = importer.logs warns = importer.warns - except Exception as e: + except Exception: tbex = traceback.format_exc() errors.append(tbex) @@ -267,7 +267,7 @@ def Export(self, context, request): 'analysis_uid': getAdapter(item['analysis_uid'], ISuperModel), 'sample': getAdapter(item['container_uid'], ISuperModel) }) - rows.sort(lambda a, b: cmp(a['cup'], b['cup'])) + rows.sort(lambda a, b: cmp(a['cup'], b['cup'])) # noqa cnt = 0 for row in rows: From aff3088b65561ff9e8d29bb08bdfad5e2d2bd042 Mon Sep 17 00:00:00 2001 From: Mike Metcalfe Date: Mon, 12 Aug 2024 16:32:31 +0200 Subject: [PATCH 2/2] added default instrument.pt --- src/senaite/instruments/configure.zcml | 2 ++ .../instruments/instruments/data_import.py | 13 +++++++++ .../instruments/instruments/instrument.pt | 29 +++++++++++++++++++ .../instruments/instruments/overrides.zcml | 10 +++++++ src/senaite/instruments/interfaces.py | 8 +++++ src/senaite/instruments/overrides.zcml | 7 +++++ .../profiles/default/browserlayer.xml | 8 +++++ 7 files changed, 77 insertions(+) create mode 100644 src/senaite/instruments/instruments/data_import.py create mode 100644 src/senaite/instruments/instruments/instrument.pt create mode 100644 src/senaite/instruments/instruments/overrides.zcml create mode 100644 src/senaite/instruments/interfaces.py create mode 100644 src/senaite/instruments/overrides.zcml create mode 100644 src/senaite/instruments/profiles/default/browserlayer.xml diff --git a/src/senaite/instruments/configure.zcml b/src/senaite/instruments/configure.zcml index 8553e8d..3a845ef 100644 --- a/src/senaite/instruments/configure.zcml +++ b/src/senaite/instruments/configure.zcml @@ -2,6 +2,7 @@ xmlns="http://namespaces.zope.org/zope" xmlns:five="http://namespaces.zope.org/five" xmlns:genericsetup="http://namespaces.zope.org/genericsetup" + xmlns:browser="http://namespaces.zope.org/browser" i18n_domain="senaite.instruments"> @@ -16,4 +17,5 @@ + diff --git a/src/senaite/instruments/instruments/data_import.py b/src/senaite/instruments/instruments/data_import.py new file mode 100644 index 0000000..ea3fa2f --- /dev/null +++ b/src/senaite/instruments/instruments/data_import.py @@ -0,0 +1,13 @@ +from senaite.core.browser.form.adapters.data_import import EditForm as EF +import os + + +class EditForm(EF): + + def get_default_import_template(self): + """Returns the path of the default import template + """ + import senaite.instruments.instruments + path = os.path.dirname(senaite.instruments.instruments.__file__) + template = "instrument.pt" + return os.path.join(path, template) diff --git a/src/senaite/instruments/instruments/instrument.pt b/src/senaite/instruments/instruments/instrument.pt new file mode 100644 index 0000000..b5e51e7 --- /dev/null +++ b/src/senaite/instruments/instruments/instrument.pt @@ -0,0 +1,29 @@ +

+  +   +

+

Advanced options

+ + + + + + + + + +
  + +
+ +
+

+ +

diff --git a/src/senaite/instruments/instruments/overrides.zcml b/src/senaite/instruments/instruments/overrides.zcml new file mode 100644 index 0000000..5e96111 --- /dev/null +++ b/src/senaite/instruments/instruments/overrides.zcml @@ -0,0 +1,10 @@ + + + + + diff --git a/src/senaite/instruments/interfaces.py b/src/senaite/instruments/interfaces.py new file mode 100644 index 0000000..71ffb02 --- /dev/null +++ b/src/senaite/instruments/interfaces.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +"""Module where all interfaces, events and exceptions live.""" + +from zope.publisher.interfaces.browser import IDefaultBrowserLayer + + +class ISenaiteInstrumentsBrowserLayer(IDefaultBrowserLayer): + """Marker interface that defines a browser layer.""" diff --git a/src/senaite/instruments/overrides.zcml b/src/senaite/instruments/overrides.zcml new file mode 100644 index 0000000..288acfe --- /dev/null +++ b/src/senaite/instruments/overrides.zcml @@ -0,0 +1,7 @@ + + + + + diff --git a/src/senaite/instruments/profiles/default/browserlayer.xml b/src/senaite/instruments/profiles/default/browserlayer.xml new file mode 100644 index 0000000..37553bb --- /dev/null +++ b/src/senaite/instruments/profiles/default/browserlayer.xml @@ -0,0 +1,8 @@ + + + + +