Replace file() with open() for Python 3 compatibility
The built-in named 'file' has been removed since Python 3.0 [1] This patch replaces it by 'open' which is the same under Python 2 and 3. [1] https://docs.python.org/release/3.0/whatsnew/3.0.html#builtins Change-Id: Ib2abbd0f6aea4423acae0c7dceccf1ef67c1caae
This commit is contained in:
parent
7201fdce87
commit
7be92d78fc
@ -105,15 +105,15 @@ EVENT_TYPES_FILE = get_events_yaml_filename()
|
||||
if not os.path.isfile(EVENT_TYPES_FILE):
|
||||
exit (-1)
|
||||
|
||||
stream = file(EVENT_TYPES_FILE, 'r')
|
||||
event_types = yaml.load(stream)
|
||||
with open(EVENT_TYPES_FILE, 'r') as stream:
|
||||
event_types = yaml.load(stream)
|
||||
|
||||
for alarm_id in event_types:
|
||||
if isinstance(alarm_id, float):
|
||||
# force 3 digits after the decimal point,
|
||||
# to include trailing zero's (ex.: 200.010)
|
||||
formatted_alarm_id = "{:.3f}".format(alarm_id)
|
||||
event_types[formatted_alarm_id] = event_types.pop(alarm_id)
|
||||
formatted_alarm_id = "{:.3f}".format(alarm_id)
|
||||
event_types[formatted_alarm_id] = event_types.pop(alarm_id)
|
||||
|
||||
event_types = collections.OrderedDict(sorted(event_types.items()))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user