mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-26 04:32:51 +01:00
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:
parent
21a729d95a
commit
2460c0abca
@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user