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