Changeset 7b50f14 in sasview
- Timestamp:
- Sep 22, 2017 7:40:41 PM (7 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- d04ac05
- Parents:
- 46cf4c9
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/file_reader_base_class.py
r26183bf r7b50f14 6 6 7 7 import os 8 import sys 8 9 import re 9 10 import logging … … 18 19 logger = logging.getLogger(__name__) 19 20 21 if sys.version_info[0] < 3: 22 def decode(s): 23 return s 24 else: 25 def decode(s): 26 return s.decode() if isinstance(s, bytes) else s 20 27 21 28 class FileReader(object): … … 85 92 """ 86 93 #return self.f_open.readline() 87 return self.f_open.readline().decode()94 return decode(self.f_open.readline()) 88 95 89 96 def nextlines(self): … … 93 100 for line in self.f_open: 94 101 #yield line 95 yield line.decode()102 yield decode(line) 96 103 97 104 def readall(self): … … 100 107 """ 101 108 #return self.f_open.read() 102 return self.f_open.read().decode()109 return decode(self.f_open.read()) 103 110 104 111 def handle_error_message(self, msg): -
src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py
r5c5e7fd r7b50f14 9 9 import sys 10 10 11 from sas.sascalc.dataloader.data_info import plottable_1D, plottable_2D,\11 from ..data_info import plottable_1D, plottable_2D,\ 12 12 Data1D, Data2D, DataInfo, Process, Aperture, Collimation, \ 13 13 TransmissionSpectrum, Detector 14 from sas.sascalc.dataloader.data_info import combine_data_info_with_plottable 15 from sas.sascalc.dataloader.loader_exceptions import FileContentsException, DefaultReaderException 16 from sas.sascalc.dataloader.file_reader_base_class import FileReader 17 18 def decode(s): 19 return s.decode() if isinstance(s, bytes) else s 14 from ..data_info import combine_data_info_with_plottable 15 from ..loader_exceptions import FileContentsException, DefaultReaderException 16 from ..file_reader_base_class import FileReader, decode 20 17 21 18 def h5attr(node, key, default=None): … … 135 132 # Get all information for the current key 136 133 value = data.get(key) 137 class name = h5attr(value, u'canSAS_class')138 if class name is None:134 class_name = h5attr(value, u'canSAS_class') 135 if class_name is None: 139 136 class_name = h5attr(value, u'NX_class') 140 137 if class_name is not None: … … 240 237 run_dict = {data_point: run_name} 241 238 self.current_datainfo.run_name = run_dict 242 except :239 except Exception: 243 240 pass 244 241 elif key == u'title': -
src/sas/sascalc/dataloader/readers/xml_reader.py
r5a6a84e r7b50f14 20 20 from lxml.builder import E 21 21 22 from sas.sascalc.dataloader.file_reader_base_class import FileReader22 from ..file_reader_base_class import FileReader, decode 23 23 24 24 logger = logging.getLogger(__name__) … … 153 153 Converts an etree element into a string 154 154 """ 155 return etree.tostring(elem, pretty_print=pretty_print,156 encoding=encoding).decode()155 return decode(etree.tostring(elem, pretty_print=pretty_print, 156 encoding=encoding)) 157 157 158 158 def break_processing_instructions(self, string, dic): -
test/sasdataloader/test/utest_cansas.py
r56dac0b r7b50f14 4 4 import os 5 5 import sys 6 from io import StringIO7 6 import unittest 8 7 import logging 9 8 import warnings 9 if sys.version_info[0] >= 3: 10 from io import StringIO 11 else: 12 from StringIO import StringIO 10 13 11 14 from lxml import etree
Note: See TracChangeset
for help on using the changeset viewer.