conversion to new python3

This commit is contained in:
Markus Rosenstihl
2026-02-27 22:09:44 +01:00
parent 0b152b31fd
commit 29f003c99e
6 changed files with 78 additions and 73 deletions
+9 -9
View File
@@ -104,7 +104,7 @@ class ResultReader:
self.result_job_number = None
# Job Date is set in __read_file()
self.__filetype = None
for elem in xml.etree.cElementTree.ElementTree(file=in_file).getiterator():
for elem in xml.etree.cElementTree.ElementTree(file=in_file).iter():
if elem.tag == 'result':
self.result_job_number = int(elem.get("job"))
pass
@@ -114,7 +114,7 @@ class ResultReader:
self.result_description = {}
self.in_description_section=True
self.in_description_data=()
for an_item in elem.getchildren():
for an_item in elem.iter():
self.in_description_data = (an_item.get("key"), an_item.get("type"), an_item.text)
# make item contents to dictionary item:
k,t,v=self.in_description_data
@@ -173,7 +173,7 @@ class ResultReader:
self.adc_result_trailing_chars = "".join(elem.text.splitlines())
tmp_string = base64.standard_b64decode(self.adc_result_trailing_chars)
self.adc_result_trailing_chars = None
tmp = numpy.fromstring(tmp_string,dtype='Int16')
tmp = numpy.fromstring(tmp_string,dtype='int16')
tmp_string = None
self.adc_result_parts.append(tmp)
tmp = None
@@ -213,13 +213,13 @@ class ResultReader:
self.adc_result_sample_counter>0:
# fill the ADC_Result with collected data
# x data
self.result.x=numpy.arange(self.adc_result_sample_counter, dtype="Float64")/\
self.result.x=numpy.arange(self.adc_result_sample_counter, dtype="float64")/\
self.result.get_sampling_rate()
self.result.y = []
nChannels = self.result.get_nChannels()
# initialise the y arrays
for i in range(nChannels):
self.result.y.append(numpy.empty(self.adc_result_sample_counter, dtype='Int16'))
self.result.y.append(numpy.empty(self.adc_result_sample_counter, dtype='int16'))
# remove from result stack
tmp_index = 0
while self.adc_result_parts:
@@ -293,12 +293,12 @@ class ResultReader:
self.__filetype == ResultReader.ADCDATA_TYPE and \
self.adc_result_sample_counter>0:
# fill the ADC_Result with collected data
self.result.x=numpy.arange(self.adc_result_sample_counter, dtype="Float64")/\
self.result.x=numpy.arange(self.adc_result_sample_counter, dtype="float64")/\
self.result.get_sampling_rate()
self.result.y=[]
self.result.index=[]
for i in range(2):
self.result.y.append(numpy.empty((self.adc_result_sample_counter,), dtype="Int16"))
self.result.y.append(numpy.empty((self.adc_result_sample_counter,), dtype="int16"))
tmp_sample_counter=0
while self.adc_result_parts:
tmp_part=self.adc_result_parts.pop(0)
@@ -468,10 +468,10 @@ class ResultReader:
tmp=None
if self.adc_data_encoding=="a":
values=list(map(int,self.adc_result_trailing_chars.split()))
tmp=numpy.array(values, dtype="Int16")
tmp=numpy.array(values, dtype="int16")
elif self.adc_data_encoding=="b":
tmp_string=base64.standard_b64decode(self.adc_result_trailing_chars)
tmp=numpy.fromstring(tmp_string, dtype="Int16")
tmp=numpy.fromstring(tmp_string, dtype="int16")
del tmp_string
else:
print("unknown ADC data format")