Math.convertcore: remove unnecessary StringIO usage

Since the unit data is already a variable, we can read from it as is
This commit is contained in:
James Lu 2017-09-29 15:54:04 -07:00
parent 21a729d95a
commit 2460c0abca

View File

@ -1059,12 +1059,7 @@ class UnitData(dict):
"Read all unit data from file"
types = []
typeUnits = {}
try:
f = minisix.io.StringIO(unitData)
lines = f.readlines()
f.close()
except IOError:
raise UnitDataError('Can not read "units.dat" file')
lines = unitData.splitlines()
for i in range(len(lines)): # join continuation lines
delta = 1
while lines[i].rstrip().endswith('\\'):
@ -1229,5 +1224,3 @@ def units(type):
return '%s units: %s' % (type, ', '.join(unitsByType[type]))
else:
return 'valid types: ' + ', '.join(types)