-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: checking directory and get information closes #8
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyritht © 2023 Marcin Różewski MDSANIMA | ||
|
||
|
||
"""This module is for several utils that we may be use for command line tools. | ||
The module may be used in development. | ||
""" | ||
|
||
|
||
from __future__ import annotations | ||
|
||
import os | ||
|
||
|
||
def get_directory_info() -> dict: | ||
"""Checking the directory and returning information about that.""" | ||
real_path = os.path.realpath(os.curdir) | ||
directory = os.listdir() | ||
|
||
files_count = len(directory) | ||
image_png_count = 0 | ||
image_jpg_count = 0 | ||
|
||
for file in directory: | ||
extension = os.path.splitext(file)[-1].lower() | ||
if extension == ".png": | ||
image_png_count += 1 | ||
if extension == ".jpg": | ||
image_jpg_count += 1 | ||
|
||
directory_info = { | ||
"real_path": real_path, | ||
"files_count": files_count, | ||
"image_png_count": image_png_count, | ||
"image_jpg_count": image_jpg_count, | ||
} | ||
|
||
return directory_info |