From 33265ccb8dab97dc8dda8a8bf32394a9f32ac0d6 Mon Sep 17 00:00:00 2001 From: imahdimir Date: Sun, 15 Oct 2023 19:25:42 +0330 Subject: [PATCH] 25.0.0 --- pyproject.toml | 2 +- src/mirutil/dirr.py | 11 ------ src/mirutil/run_modules.py | 80 -------------------------------------- 3 files changed, 1 insertion(+), 92 deletions(-) delete mode 100644 src/mirutil/run_modules.py diff --git a/pyproject.toml b/pyproject.toml index 9781fe9..734d237 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "mirutil" -version = "24.3.1" +version = "25.0.0" authors = [{ name = "Mahdi Mir", email = "imahdimir@gmail.com" }] description = "Tools for getting and cleaning TSE data" readme = "README.md" diff --git a/src/mirutil/dirr.py b/src/mirutil/dirr.py index 7a89c51..fd63133 100644 --- a/src/mirutil/dirr.py +++ b/src/mirutil/dirr.py @@ -4,17 +4,6 @@ from pathlib import Path -from githubdata import default_containing_dir - -class DefaultDirs : - m = Path('modules/') - m.mkdir(exist_ok = True) - - gd = default_containing_dir - - t = Path('temp_data/') - t.mkdir(exist_ok = True) - def get_all_subdirs(root_dir) : """ returns all subdirectories of the root_dir""" return Path(root_dir).glob('**') diff --git a/src/mirutil/run_modules.py b/src/mirutil/run_modules.py deleted file mode 100644 index 1ef1b7e..0000000 --- a/src/mirutil/run_modules.py +++ /dev/null @@ -1,80 +0,0 @@ -""" - - """ - -import runpy -import shutil -from pathlib import Path - -from .dirr import DefaultDirs - -def get_modules_to_run_from_path(modules_dir: Path | str) -> list[Path] : - """ - finds all .py files in modules_dir that start with '_' and - sorts them based on the number after '_'. This is the convention - I use to specify modules to run in order. The number after '_' is - used to specify the order. There might be other modules in the same - dir that are not prefixed with '_' and they will not be run. There - are auxiliary modules. - """ - - # get all .py files in modules_dir - pys = Path(modules_dir).glob('*.py') - - # filter those that start with '_' - ms = [x for x in pys if x.name.startswith('_')] - - # sort .py files them based on the number after _ - ms = sorted(ms) - - return ms - -def run_modules_from_dir_in_order(modules_dir: Path | str = DefaultDirs().m) -> None : - """ - runs all modules in modules_dir that start with '_' based on the number - after '_'. - """ - ms = get_modules_to_run_from_path(modules_dir) - # run modules in order - for m in ms : - print('\n\t*** Running The Module \" {} \" ***\n'.format(m.name)) - - runpy.run_path(str(m) , run_name = '__main__') - - print('\n\t*** The Module \" {} \" Done! ***\n'.format(m.name)) - -def clean_cache_dirs(inculding_set: set[Path] = None , - excluding_set: set[Path] = None , - inculde_defaults: bool = True - ) -> None : - """ - removes cache dirs - some defaults + some manual to include - some to exculde - - include_defaults: whether to include defaults - """ - - # default argument values - if excluding_set is None : - excluding_set = {} - if inculding_set is None : - inculding_set = {} - - # default dirs - if inculde_defaults : - dyr = DefaultDirs() - dyrs = {dyr.gd , dyr.t} - else : - dyrs = {} - - # include & exclude manually - dyrs = dyrs.union(inculding_set) - dyrs = dyrs.difference(excluding_set) - - # remove the final set of dirs one by one - print('Cleaning cache directories : ' , dyrs) - - for di in dyrs : - shutil.rmtree(di , ignore_errors = True) - - print('All cache dirs got removed.')