From 67b54180c8e93b6fba312e4c75f416b832afbc6a Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sat, 6 Mar 2021 22:31:11 +0000 Subject: merge similar modules together --- src/backend/__init__.py | 4 +--- src/backend/branchreset.py | 35 ------------------------------- src/backend/branchsetup.py | 10 ++++----- src/backend/cache.py | 13 ------------ src/backend/metadata.py | 15 -------------- src/backend/purge.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++ src/backend/update.py | 3 ++- 7 files changed, 58 insertions(+), 73 deletions(-) delete mode 100644 src/backend/branchreset.py delete mode 100644 src/backend/cache.py delete mode 100644 src/backend/metadata.py create mode 100644 src/backend/purge.py (limited to 'src') diff --git a/src/backend/__init__.py b/src/backend/__init__.py index d868abb..7833aba 100644 --- a/src/backend/__init__.py +++ b/src/backend/__init__.py @@ -1,8 +1,6 @@ from .autoremove import * from .binhost import * -from .branchreset import * from .branchsetup import * -from .cache import * from .check import * from .csvfiles import * from .database import * @@ -13,8 +11,8 @@ from .filesystem import * from .forceuninstall import * from .install import * from .killportage import * -from .metadata import * from .mirror import * +from .purge import * from .rescue import * from .search import * from .setjobs import * diff --git a/src/backend/branchreset.py b/src/backend/branchreset.py deleted file mode 100644 index 6df4347..0000000 --- a/src/backend/branchreset.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/python3 - -import animation -import os -import shutil -import sisyphus.filesystem - -@animation.wait('resetting branch configuration') -def start(): - if os.path.isdir(sisyphus.filesystem.portageRepoDir): - for files in os.listdir(sisyphus.filesystem.portageRepoDir): - if os.path.isfile(os.path.join(sisyphus.filesystem.portageRepoDir, files)): - os.remove(os.path.join(sisyphus.filesystem.portageRepoDir, files)) - else: - shutil.rmtree(os.path.join(sisyphus.filesystem.portageRepoDir, files)) - else: - os.makedirs(sisyphus.filesystem.portageRepoDir) - - if os.path.isdir(sisyphus.filesystem.redcoreRepoDir): - for files in os.listdir(sisyphus.filesystem.redcoreRepoDir): - if os.path.isfile(os.path.join(sisyphus.filesystem.redcoreRepoDir, files)): - os.remove(os.path.join(sisyphus.filesystem.redcoreRepoDir, files)) - else: - shutil.rmtree(os.path.join(sisyphus.filesystem.redcoreRepoDir, files)) - else: - os.makedirs(sisyphus.filesystem.redcoreRepoDir) - - 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(sisyphus.filesystem.portageConfigDir, files)) - else: - os.makedirs(sisyphus.filesystem.portageConfigDir) diff --git a/src/backend/branchsetup.py b/src/backend/branchsetup.py index 793376b..2b12c3d 100644 --- a/src/backend/branchsetup.py +++ b/src/backend/branchsetup.py @@ -4,11 +4,9 @@ import animation import git import os import sys -import sisyphus.cache import sisyphus.check -import sisyphus.branchreset import sisyphus.filesystem -import sisyphus.metadata +import sisyphus.purge import sisyphus.setjobs import sisyphus.setprofile @@ -84,9 +82,9 @@ def warnAboutBinaryRepository(branch,remote): def start(branch,remote): if sisyphus.check.root(): - sisyphus.branchreset.start() - sisyphus.cache.purge() - sisyphus.metadata.purge() + sisyphus.purge.branch() + sisyphus.purge.cache() + sisyphus.purge.metadata() injectGentooPortageTree(branch,remote) injectRedcoreEbuildOverlay(branch,remote) injectRedcorePortageConfig(branch,remote) diff --git a/src/backend/cache.py b/src/backend/cache.py deleted file mode 100644 index ed291f0..0000000 --- a/src/backend/cache.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/python3 - -import os -import shutil -import sisyphus.filesystem - -def purge(): - if os.path.isdir(sisyphus.filesystem.portageCacheDir): - for files in os.listdir(sisyphus.filesystem.portageCacheDir): - if os.path.isfile(os.path.join(sisyphus.filesystem.portageCacheDir, files)): - os.remove(os.path.join(sisyphus.filesystem.portageCacheDir, files)) - else: - shutil.rmtree(os.path.join(sisyphus.filesystem.portageCacheDir, files)) diff --git a/src/backend/metadata.py b/src/backend/metadata.py deleted file mode 100644 index f906c95..0000000 --- a/src/backend/metadata.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/python3 - -import animation -import os -import shutil -import subprocess -import sisyphus.filesystem - -def purge(): - if os.path.isdir(sisyphus.filesystem.portageMetadataDir): - for files in os.listdir(sisyphus.filesystem.portageMetadataDir): - if os.path.isfile(os.path.join(sisyphus.filesystem.portageMetadataDir, files)): - os.remove(os.path.join(sisyphus.filesystem.portageMetadataDir, files)) - else: - shutil.rmtree(os.path.join(sisyphus.filesystem.portageMetadataDir, files)) diff --git a/src/backend/purge.py b/src/backend/purge.py new file mode 100644 index 0000000..3a94cff --- /dev/null +++ b/src/backend/purge.py @@ -0,0 +1,51 @@ +#!/usr/bin/python3 + +import animation +import os +import shutil +import sisyphus.filesystem + +@animation.wait('purging branch configuration') +def branch(): + if os.path.isdir(sisyphus.filesystem.portageRepoDir): + for files in os.listdir(sisyphus.filesystem.portageRepoDir): + if os.path.isfile(os.path.join(sisyphus.filesystem.portageRepoDir, files)): + os.remove(os.path.join(sisyphus.filesystem.portageRepoDir, files)) + else: + shutil.rmtree(os.path.join(sisyphus.filesystem.portageRepoDir, files)) + else: + os.makedirs(sisyphus.filesystem.portageRepoDir) + + if os.path.isdir(sisyphus.filesystem.redcoreRepoDir): + for files in os.listdir(sisyphus.filesystem.redcoreRepoDir): + if os.path.isfile(os.path.join(sisyphus.filesystem.redcoreRepoDir, files)): + os.remove(os.path.join(sisyphus.filesystem.redcoreRepoDir, files)) + else: + shutil.rmtree(os.path.join(sisyphus.filesystem.redcoreRepoDir, files)) + else: + os.makedirs(sisyphus.filesystem.redcoreRepoDir) + + 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(sisyphus.filesystem.portageConfigDir, files)) + else: + os.makedirs(sisyphus.filesystem.portageConfigDir) + +def cache(): + if os.path.isdir(sisyphus.filesystem.portageCacheDir): + for files in os.listdir(sisyphus.filesystem.portageCacheDir): + if os.path.isfile(os.path.join(sisyphus.filesystem.portageCacheDir, files)): + os.remove(os.path.join(sisyphus.filesystem.portageCacheDir, files)) + else: + shutil.rmtree(os.path.join(sisyphus.filesystem.portageCacheDir, files)) + +def metadata(): + if os.path.isdir(sisyphus.filesystem.portageMetadataDir): + for files in os.listdir(sisyphus.filesystem.portageMetadataDir): + if os.path.isfile(os.path.join(sisyphus.filesystem.portageMetadataDir, files)): + os.remove(os.path.join(sisyphus.filesystem.portageMetadataDir, files)) + else: + shutil.rmtree(os.path.join(sisyphus.filesystem.portageMetadataDir, files)) diff --git a/src/backend/update.py b/src/backend/update.py index 82281fe..0253118 100644 --- a/src/backend/update.py +++ b/src/backend/update.py @@ -3,13 +3,14 @@ import animation import sys import time -import sisyphus.cache import sisyphus.binhost import sisyphus.check import sisyphus.database +import sisyphus.purge import sisyphus.sync def syncAll(): + sisyphus.purge.cache() sisyphus.sync.portage() sisyphus.sync.overlay() sisyphus.sync.portageCfg() -- cgit v1.2.3