[elbe-devel] [PATCH v1 7/8] Change to 'lexist' for "/etc/apt/{sources.list, preferences}"
dion at linutronix.de
dion at linutronix.de
Wed May 22 15:33:47 CEST 2019
From: Olivier Dion <dion at linutronix.de>
Signed-off-by: Olivier Dion <dion at linutronix.de>
---
elbepack/virtapt.py | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/elbepack/virtapt.py b/elbepack/virtapt.py
index 8be68b0a..901ea054 100644
--- a/elbepack/virtapt.py
+++ b/elbepack/virtapt.py
@@ -215,22 +215,20 @@ class VirtApt(object):
def create_apt_sources_list(self, mirror):
filename = os.path.join(self.projectpath, "etc/apt/sources.list")
- if os.path.exists(filename):
+ if os.path.lexists(filename):
os.remove(filename)
- file = open(filename, "w")
- file.write(mirror)
- file.close()
+ with open(filename, "w") as f:
+ f.write(mirror)
def create_apt_prefs(self, prefs):
filename = os.path.join(self.projectpath, "etc/apt/preferences")
- if os.path.exists(filename):
+ if os.path.lexists(filename):
os.remove(filename)
- file = open(filename, "w")
- file.write(prefs)
- file.close()
+ with open(filename, "w") as f:
+ f.write(prefs)
def get_uri(self, target_pkg, incl_deps=False):
--
2.11.0
More information about the elbe-devel
mailing list