Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix import of format_keyword from new place in utils #4

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
ignore = E501
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`
2 changes: 2 additions & 0 deletions src/senaite/instruments/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

<five:registerPackage package="." initialize=".initialize" />
Expand All @@ -16,4 +17,5 @@

<include package=".instruments" />


</configure>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down
13 changes: 13 additions & 0 deletions src/senaite/instruments/instruments/data_import.py
Original file line number Diff line number Diff line change
@@ -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)
29 changes: 29 additions & 0 deletions src/senaite/instruments/instruments/instrument.pt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<p></p>
<label for='instrument_results_file'>File</label>&nbsp;
<input type="file" name="instrument_results_file" id="instrument_results_file"/>&nbsp;&nbsp;
<p></p>
<h3>Advanced options</h3>
<table cellpadding="0" cellspacing="0">
<tr>
<td><label for="artoapply">Samples state</label>&nbsp;</td>
<td>
<select name="artoapply" id="artoapply">
<option value="received">Received</option>
<option value="received_tobeverified">Received and to be verified</option>
</select>
</td>
</tr>
<tr>
<td><label for="results_override">Results override</label></td>
<td>
<select name="results_override" id="results_override">
<option value="nooverride">Don't override results</option>
<option value="override">Override non-empty results</option>
<option value="overrideempty">Override non-empty results (also with empty)</option>
</select>
</td>
</tr>
</table>
<p></p>
<input name="firstsubmit" type="submit" value="Submit" i18n:attributes="value"/>
<p></p>
10 changes: 10 additions & 0 deletions src/senaite/instruments/instruments/overrides.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<configure xmlns="http://namespaces.zope.org/zope"
i18n_domain="senaite.instruments">

<adapter
name="data_import_form"
for="Products.CMFCore.interfaces.ISiteRoot
zope.publisher.interfaces.browser.IBrowserRequest"
factory=".data_import.EditForm"/>

</configure>
8 changes: 8 additions & 0 deletions src/senaite/instruments/interfaces.py
Original file line number Diff line number Diff line change
@@ -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."""
7 changes: 7 additions & 0 deletions src/senaite/instruments/overrides.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<configure xmlns="http://namespaces.zope.org/zope"
xmlns:zcml="http://namespaces.zope.org/browser"
i18n_domain="senaite.instruments">

<include package=".instruments" file="overrides.zcml" />

</configure>
8 changes: 8 additions & 0 deletions src/senaite/instruments/profiles/default/browserlayer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<layers>
<layer
name="bika.instruments"
interface="senaite.instruments.interfaces.ISenaiteInstrumentsBrowserLayer"
/>
</layers>