Skip to main content

A library for destructing folders content for data like txt, image, npy

Project description

destructfolder

A library for destructing folders content for data like txt, image, npy

Exmaple:

File structure:

- data
    - txt_folder1
        1.txt
        2.txt
    - txt_folder2
        1.txt
        2.txt
    - txt_folder3
        1.txt
        2.txt
- cache
    - foreach_folder
        - txt_folder_n1
            1.txt
            2.txt
        - txt_folder_n1
            1.txt
            2.txt
        - txt_folder_n1
            1.txt
            2.txt
    - txt_folder4
        1.txt
        2.txt
    - txt_folder6
        1.txt
        2.txt
from destructfolder import *

folderStructure =  [
    Folder("data",[
        TxtFolder("txt_folder1", key_for_contents="txt_folder1_key"),
        TxtFolder("txt_folder2", key_for_contents="txt_folder2_key"),
        TxtFolder("txt_folder3", key_for_contents="txt_folder3_key"),
    ]),
    Folder("cache", [
        TxtFolder("txt_folder4", key_for_contents="txt_folder4_key"),
        ForEachFolder("foreach_folder", key_for_path="foreach_folder_key_for_path", key_for_subfolder="foreach_folder_key", subfolder=
            TxtFolder("txt_folder5_inside_foreach_folder", key_for_contents="txt_folder5_inside_foreach_folder_key")
        ),
        TxtFolder("txt_folder6", key_for_contents="txt_folder6_key")
    ])
]

rootPath = Path(__file__).parent
buildFramework(rootPath, folderStructure)

folderDict = destructFolder(rootPath, folderStructure)

print(folderDict)
print()
print(folderDict["txt_folder1_key"])
print(folderDict["txt_folder2_key"])
print(folderDict["txt_folder3_key"])
print()
print(folderDict["txt_folder4_key"])
print(folderDict["foreach_folder_key"]["txt_folder_n1"])
print(folderDict["foreach_folder_key"]["txt_folder_n2"])
print(folderDict["foreach_folder_key"]["txt_folder_n3"])
print(folderDict["txt_folder6_key"])

Output:

Loading TxtFolder contents (txt_folder1) ...
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<?, ?it/s] 

Loading TxtFolder contents (txt_folder2) ...
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<?, ?it/s] 

Loading TxtFolder contents (txt_folder3) ...
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<?, ?it/s] 

Loading TxtFolder contents (txt_folder4) ...
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<?, ?it/s] 

Loading TxtFolder contents (txt_folder_n1) ...
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<?, ?it/s] 

Loading TxtFolder contents (txt_folder_n2) ...
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<?, ?it/s] 

Loading TxtFolder contents (txt_folder_n3) ...
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<?, ?it/s] 

Loading TxtFolder contents (txt_folder6) ...
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<?, ?it/s] 

{'txt_folder1_key': {'1': 'this is txt file in txt_folder1', '2': 'this is another txt file in txt_folder1'}, 'txt_folder2_key': {'1': 'txt file in txt_folder2', '2': 'another txt file in txt_folder2'}, 'txt_folder3_key': {'1': 'txt in txt_folder3', '2': 'another txt in txt_folder3'}, 'txt_folder4_key': {'1': 'this is txt file in txt_folder4', '2': 'this is another txt file in txt_folder4'}, 'foreach_folder_key_for_path': WindowsPath('D:/Develop/Python/DestructFolder/example/cache/foreach_folder'), 'foreach_folder_key': {'txt_folder_n1': {'txt_folder5_inside_foreach_folder_key': {'1': 'this is txt file in txt_folder_n1', '2': 'this is another txt file in txt_folder_n1'}}, 'txt_folder_n2': {'txt_folder5_inside_foreach_folder_key': {'1': 'this is txt file in txt_folder_n2', '2': 'this is another txt file in txt_folder_n2'}}, 'txt_folder_n3': {'txt_folder5_inside_foreach_folder_key': {'1': 'this is txt file in txt_folder_n3', '2': 'this is another txt file in txt_folder_n3'}}}, 'txt_folder6_key': {'1': 'this is txt file in txt_folder6', '2': 'this is another txt file in txt_folder6'}}

{'1': 'this is txt file in txt_folder1', '2': 'this is another txt file in txt_folder1'}
{'1': 'txt file in txt_folder2', '2': 'another txt file in txt_folder2'}
{'1': 'txt in txt_folder3', '2': 'another txt in txt_folder3'}

{'1': 'this is txt file in txt_folder4', '2': 'this is another txt file in txt_folder4'}
{'txt_folder5_inside_foreach_folder_key': {'1': 'this is txt file in txt_folder_n1', '2': 'this is another txt file in txt_folder_n1'}}
{'txt_folder5_inside_foreach_folder_key': {'1': 'this is txt file in txt_folder_n2', '2': 'this is another txt file in txt_folder_n2'}}
{'txt_folder5_inside_foreach_folder_key': {'1': 'this is txt file in txt_folder_n3', '2': 'this is another txt file in txt_folder_n3'}}
{'1': 'this is txt file in txt_folder6', '2': 'this is another txt file in txt_folder6'}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

destructfolder-0.0.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

destructfolder-0.0.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file destructfolder-0.0.1.tar.gz.

File metadata

  • Download URL: destructfolder-0.0.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.0

File hashes

Hashes for destructfolder-0.0.1.tar.gz
Algorithm Hash digest
SHA256 348593d1cd972f54a51fd12de338f3fb57702eae1338bcd8ccb9c3c2371454a9
MD5 abd815deebede408cb9f5dcd333804a1
BLAKE2b-256 d5f2ab839dd477e247a7de4b90d5eded5e8360a9b5f5fc004e83e63d842904b5

See more details on using hashes here.

File details

Details for the file destructfolder-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for destructfolder-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dabdacc43c1b9fa09b49331add39737f6fa063dfea58b4d07be47245f45b46dc
MD5 1dea532ef661b0453372ed1d7619368f
BLAKE2b-256 043646e7d9fc4f57d510a0af71a9fa6b2cab10f25de60c05c853acc0d1fdce11

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page