Skip to content

Commit

Permalink
feat: checking directory and get information closes #8
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsanima committed Feb 13, 2023
1 parent 3188ed5 commit 3c098f3
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/mdsanima_cli/utils.py
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

0 comments on commit 3c098f3

Please sign in to comment.