Browse Source

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
Vu Cong Tuan 9 months ago
parent
commit
7be92d78fc
1 changed files with 4 additions and 4 deletions
  1. 4
    4
      fm-common/sources/fm_db_sync_event_suppression.py

+ 4
- 4
fm-common/sources/fm_db_sync_event_suppression.py View File

@@ -105,15 +105,15 @@ EVENT_TYPES_FILE = get_events_yaml_filename()
105 105
 if not os.path.isfile(EVENT_TYPES_FILE):
106 106
     exit (-1)
107 107
 
108
-stream = file(EVENT_TYPES_FILE, 'r')
109
-event_types = yaml.load(stream)
108
+with open(EVENT_TYPES_FILE, 'r') as stream:
109
+    event_types = yaml.load(stream)
110 110
 
111 111
 for alarm_id in event_types:
112 112
     if isinstance(alarm_id, float):
113 113
         # force 3 digits after the decimal point,
114 114
         # to include trailing zero's (ex.: 200.010)
115
-        formatted_alarm_id = "{:.3f}".format(alarm_id)               
116
-        event_types[formatted_alarm_id] = event_types.pop(alarm_id)  
115
+        formatted_alarm_id = "{:.3f}".format(alarm_id)
116
+        event_types[formatted_alarm_id] = event_types.pop(alarm_id)
117 117
 
118 118
 event_types = collections.OrderedDict(sorted(event_types.items()))
119 119
 

Loading…
Cancel
Save