From 5d919e9dc6e44cd4dd02e32e2d171344b7e5ad96 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Mon, 15 Aug 2022 07:23:19 +0200 Subject: [PATCH] f4pga/common_modules/place: use pathlib instead of os and shutil Signed-off-by: Unai Martinez-Corral --- f4pga/common_modules/place.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/f4pga/common_modules/place.py b/f4pga/common_modules/place.py index 258b113..8c113a3 100644 --- a/f4pga/common_modules/place.py +++ b/f4pga/common_modules/place.py @@ -18,8 +18,6 @@ # SPDX-License-Identifier: Apache-2.0 from pathlib import Path -import os -from shutil import move as sh_mv from re import match as re_match from f4pga.common import vpr_specific_values, vpr as common_vpr, VprArgs, save_vpr_log @@ -50,10 +48,10 @@ class PlaceModule(Module): def execute(self, ctx: ModuleContext): place_constraints, dummy = place_constraints_file(ctx) - place_constraints = os.path.realpath(place_constraints) + place_constraints = Path(place_constraints).resolve() if dummy: - with open(place_constraints, 'wb') as f: - f.write(b'') + with place_constraints.open('wb') as wfptr: + wfptr.write(b'') build_dir = Path(ctx.takes.eblif).parent @@ -78,8 +76,7 @@ class PlaceModule(Module): # modules may produce some temporary files with names that differ from # the ones in flow configuration. if ctx.is_output_explicit('place'): - output_file = default_output_name(place_constraints) - sh_mv(output_file, ctx.outputs.place) + Path(default_output_name(str(place_constraints))).rename(ctx.outputs.place) yield 'Saving log...' save_vpr_log('place.log', build_dir=str(build_dir))