-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 116-add-linear-sweep-voltammetry-to-data-t…
…ypes
- Loading branch information
Showing
118 changed files
with
5,914 additions
and
390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,5 @@ test_manager/test_readers.py | |
/test_manager/test_profiles.py | ||
/test_files/ | ||
/.venv/ | ||
logs/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import logging | ||
import re | ||
|
||
from converter_app.readers.helper.reader import Readers | ||
from converter_app.readers.helper.base import Reader | ||
from converter_app.readers.helper.unit_converter import convert_units, search_terms_matrix | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class AfmReader(Reader): | ||
""" | ||
Implementation of the Afm Reader. It extends converter_app.readers.helper.base.Reader | ||
""" | ||
identifier = 'afm_reader' | ||
priority = 10 | ||
|
||
def check(self): | ||
return self.file.suffix.lower() == '.spm' | ||
|
||
def prepare_tables(self): | ||
tables = [] | ||
table = self.append_table(tables) | ||
header = False | ||
lines = [] | ||
|
||
for line in self.file.fp.readlines(): | ||
lines.append(line) | ||
try: | ||
row = line.decode('utf-8').strip() | ||
except UnicodeDecodeError: | ||
continue | ||
|
||
if re.search(r'[^-<|>!?+*:.,#@%&~_"\'/\\a-zA-Z0-9\[\](){}\s]', row): | ||
continue | ||
|
||
if len(row) > 1 and row[1] == '*': | ||
header = True | ||
|
||
if header: | ||
table['header'].append(row[2:]) | ||
header = False | ||
else: | ||
k_v = [x.strip() for x in row[1:].split(':', 1)] | ||
table['metadata'].add_unique(k_v[0], k_v[-1]) | ||
|
||
extracted_table = self.append_table(tables) | ||
for term in search_terms_matrix: | ||
value = table['metadata'].get(term[2]) if table['metadata'].get(term[2]) is not None else '' | ||
extracted_table['metadata'].add_unique(term[0], value) | ||
|
||
extracted_table['metadata'] = convert_units(extracted_table['metadata'], 2) | ||
|
||
return tables | ||
|
||
|
||
Readers.instance().register(AfmReader) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import logging | ||
|
||
from converter_app.readers.helper.reader import Readers | ||
from converter_app.readers.helper.unit_converter import convert_units, search_terms_matrix | ||
from converter_app.readers.html import HtmlReader | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class CsmReader(HtmlReader): | ||
""" | ||
Implementation of the Csm Reader. It extends converter_app.readers.helper.base.Reader | ||
""" | ||
identifier = 'csm_reader' | ||
priority = 10 | ||
|
||
def check(self): | ||
is_check = super().check() | ||
if is_check: | ||
return '<div id="metainfo">' in self.file.string | ||
|
||
def prepare_tables(self): | ||
tables = super().prepare_tables() | ||
table = self.append_table(tables) | ||
for term in search_terms_matrix: | ||
for key, val in tables[-2]['metadata'].items(): | ||
if key == term[1]: | ||
table['metadata'].add_unique(term[0], val) | ||
table = self.append_table(tables) | ||
table['metadata'] = convert_units(tables[-1]['metadata'] | tables[-2]['metadata'], 1) | ||
return tables | ||
|
||
|
||
Readers.instance().register(CsmReader) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.