From ed88746cd33c0f861e9c45bf05bf9e44d86089ba Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sat, 6 Jun 2020 20:37:56 +0100 Subject: filesystem module : gather all the folder and file paths used by sisyphus under one module, and expose them to other modules from there --- src/backend/branchreset.py | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) (limited to 'src/backend/branchreset.py') diff --git a/src/backend/branchreset.py b/src/backend/branchreset.py index 6168a25..def225a 100644 --- a/src/backend/branchreset.py +++ b/src/backend/branchreset.py @@ -3,36 +3,33 @@ import animation import os import shutil - -gentooEbuildDir = '/usr/ports/gentoo' -redcoreEbuildDir = '/usr/ports/redcore' -portageConfigDir = '/opt/redcore-build' +import sisyphus.filesystem @animation.wait('resetting branch configuration') def start(): - if os.path.isdir(gentooEbuildDir): - for files in os.listdir(gentooEbuildDir): - if os.path.isfile(os.path.join(gentooEbuildDir, files)): - os.remove(os.path.join(gentooEbuildDir, files)) + if os.path.isdir(sisyphus.filesystem.gentooEbuildDir): + for files in os.listdir(sisyphus.filesystem.gentooEbuildDir): + if os.path.isfile(os.path.join(sisyphus.filesystem.gentooEbuildDir, files)): + os.remove(os.path.join(sisyphus.filesystem.gentooEbuildDir, files)) else: - shutil.rmtree(os.path.join(gentooEbuildDir, files)) + shutil.rmtree(os.path.join(sisyphus.filesystem.gentooEbuildDir, files)) else: - os.makedirs(gentooEbuildDir) + os.makedirs(sisyphus.filesystem.gentooEbuildDir) - if os.path.isdir(redcoreEbuildDir): - for files in os.listdir(redcoreEbuildDir): - if os.path.isfile(os.path.join(redcoreEbuildDir, files)): - os.remove(os.path.join(redcoreEbuildDir, files)) + if os.path.isdir(sisyphus.filesystem.redcoreEbuildDir): + for files in os.listdir(sisyphus.filesystem.redcoreEbuildDir): + if os.path.isfile(os.path.join(sisyphus.filesystem.redcoreEbuildDir, files)): + os.remove(os.path.join(sisyphus.filesystem.redcoreEbuildDir, files)) else: - shutil.rmtree(os.path.join(redcoreEbuildDir, files)) + shutil.rmtree(os.path.join(sisyphus.filesystem.redcoreEbuildDir, files)) else: - os.makedirs(redcoreEbuildDir) + os.makedirs(sisyphus.filesystem.redcoreEbuildDir) - if os.path.isdir(portageConfigDir): - for files in os.listdir(portageConfigDir): - if os.path.isfile(os.path.join(portageConfigDir, files)): - os.remove(os.path.join(portageConfigDir, files)) + if os.path.isdir(sisyphus.filesystem.portageConfigDir): + for files in os.listdir(sisyphus.filesystem.portageConfigDir): + if os.path.isfile(os.path.join(sisyphus.filesystem.portageConfigDir, files)): + os.remove(os.path.join(sisyphus.filesystem.portageConfigDir, files)) else: - shutil.rmtree(os.path.join(portageConfigDir, files)) + shutil.rmtree(os.path.join(sisyphus.filesystem.portageConfigDir, files)) else: - os.makedirs(portageConfigDir) + os.makedirs(sisyphus.filesystem.portageConfigDir) -- cgit v1.2.3