From 056b6006f64f29fe437ae9081e06f32a6c87fd24 Mon Sep 17 00:00:00 2001 From: Terrtia Date: Wed, 10 Feb 2021 15:27:31 +0100 Subject: [PATCH] fix: [gitignore] --- .gitignore | 3 +++ bin/lib/item_basic.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/.gitignore b/.gitignore index 046d0cbc..f9d2344e 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,9 @@ DATA_ARDB indexdir/ logs/ old/ +pgpdump/ +temp/ + DEFAULT_PASSWORD diff --git a/bin/lib/item_basic.py b/bin/lib/item_basic.py index 9ad6161d..010e30b6 100755 --- a/bin/lib/item_basic.py +++ b/bin/lib/item_basic.py @@ -166,3 +166,38 @@ def add_map_obj_id_item_id(obj_id, item_id, obj_type): # delete twitter id ##-- --## + +## COMMON ## +def _get_dir_source_name(directory, source_name=None, l_sources_name=set()): + if source_name: + l_dir = os.listdir(os.path.join(directory, source_name)) + else: + l_dir = os.listdir(directory) + # empty directory + if not l_dir: + return l_sources_name.add(source_name) + return l_sources_name + else: + for src_name in l_dir: + if len(src_name) == 4: + try: + int(src_name) + l_sources_name.add(os.path.join(source_name)) + return l_sources_name + except: + pass + if source_name: + src_name = os.path.join(source_name, src_name) + l_sources_name = _get_dir_source_name(directory, source_name=src_name, l_sources_name=l_sources_name) + return l_sources_name + + +def get_all_items_sources(): + res = _get_dir_source_name(PASTES_FOLDER) + print(res) + +##-- --## + + +if __name__ == '__main__': + get_all_items_sources()