python3: replace file function by open (#41132)

This commit is contained in:
Nicolas Roche 2020-03-28 20:50:48 +01:00
parent 0105a7bd29
commit d20db7a3f7
3 changed files with 5 additions and 5 deletions

View File

@ -100,7 +100,7 @@ class WcsRobotFrameworkLibrary:
'--data-dir', WCS_DATA_DIR,
'--port', str(self.port), '--http', '--silent']
sp = subprocess.Popen(wcs_command)
fd = file('/tmp/.tests/pid', 'w')
fd = open('/tmp/.tests/pid', 'w')
fd.write(str(sp.pid))
fd.close()
@ -111,7 +111,7 @@ class WcsRobotFrameworkLibrary:
def stop_wcs_server(self):
if not os.path.exists('/tmp/.tests/pid'):
return
fd = file('/tmp/.tests/pid')
fd = open('/tmp/.tests/pid')
pid = int(fd.read())
fd.close()
try:

View File

@ -61,7 +61,7 @@ class CmdHoboNotify(Command):
# get environment definition from stdin
return json.load(sys.stdin)
else:
return json.load(file(args[0]))
return json.load(open(args[0]))
@classmethod
def check_valid_notification(cls, notification):

View File

@ -45,12 +45,12 @@ for icon_id, icon_name in mapping.items():
svg_path = 'src/icon_%s/' % icon_id
svg_path = os.path.join(svg_path, [x for x in os.listdir(svg_path) if x.endswith('.svg')][0])
if options.colour:
tree = ET.fromstring(file(svg_path).read().replace('#000000', '#%s' % options.colour))
tree = ET.fromstring(open(svg_path).read().replace('#000000', '#%s' % options.colour))
for elem in tree.findall('*'):
if not elem.attrib.get('style'):
elem.attrib['style'] = 'fill:#%s' % options.colour
else:
tree = ET.fromstring(file(svg_path).read())
tree = ET.fromstring(open(svg_path).read())
author = None
for elem in tree: