Skip to content

Commit

Permalink
Added warning to importer
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejmets committed Nov 9, 2024
1 parent 6c70786 commit 971cb3b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/senaite/timeseries/importer/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,19 @@ def parse_headerline(self, line):
return 0
brains = get_as_by_keyword(keyword)
if len(brains) != 1:
self.warn('Anaysis Service {} not found'.format(keyword))
return 0
AS = api.get_object(brains[0])
if not AS:
self.warn('Anaysis Service object for {} not found'.format(keyword))
return 0
self._analysis_service = AS
if AS.TimeSeriesColumns:
self._column_headers = [
col["ColumnTitle"] for col in AS.TimeSeriesColumns
]
if not hasattr(AS, 'TimeSeriesColumns'):
self.warn('Anaysis Service {} is not Timeseries result type'.format(keyword))
return 0
self._column_headers = [
col["ColumnTitle"] for col in AS.TimeSeriesColumns
]

if splitted[0] == "Start Date":
self._start_date = splitted[1].strip()
Expand Down Expand Up @@ -90,6 +94,9 @@ def format_values(self, result):

def parse_resultsline(self, line):
"""Parses result lines"""
if len(self._column_headers) == 0:
return 0

splitted = [token.strip() for token in line.split(self._delimiter)]
if len(filter(lambda x: len(x), splitted)) == 0:
return 0
Expand Down
2 changes: 1 addition & 1 deletion src/senaite/timeseries/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<metadata>
<version>1000</version>
<dependencies>
<dependency>profile-collective.monkeypatcher:default</dependency>
<dependency>profile-plone.app.dexterity:default</dependency>
</dependencies>
</metadata>

0 comments on commit 971cb3b

Please sign in to comment.