From dfd4dbc78956b21bd66dc05a29d8cc392512b439 Mon Sep 17 00:00:00 2001 From: guanjihuan Date: Mon, 6 Nov 2023 04:55:20 +0800 Subject: [PATCH] 0.1.18 --- PyPI/setup.cfg | 2 +- PyPI/src/guan.egg-info/PKG-INFO | 2 +- PyPI/src/guan/file_processing.py | 24 +++++++++++++++++------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/PyPI/setup.cfg b/PyPI/setup.cfg index 363a24c..2c5ee10 100644 --- a/PyPI/setup.cfg +++ b/PyPI/setup.cfg @@ -1,7 +1,7 @@ [metadata] # replace with your username: name = guan -version = 0.1.17 +version = 0.1.18 author = guanjihuan author_email = guanjihuan@163.com description = An open source python package diff --git a/PyPI/src/guan.egg-info/PKG-INFO b/PyPI/src/guan.egg-info/PKG-INFO index 08e8621..65ad05e 100644 --- a/PyPI/src/guan.egg-info/PKG-INFO +++ b/PyPI/src/guan.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: guan -Version: 0.1.17 +Version: 0.1.18 Summary: An open source python package Home-page: https://py.guanjihuan.com Author: guanjihuan diff --git a/PyPI/src/guan/file_processing.py b/PyPI/src/guan/file_processing.py index 50d4b71..2860754 100644 --- a/PyPI/src/guan/file_processing.py +++ b/PyPI/src/guan/file_processing.py @@ -308,7 +308,7 @@ def find_repeated_file_with_same_filename(directory='./', ignored_directory_with return repeated_file # 统计各个子文件夹中的文件数量 -def count_file_in_sub_directory(directory='./', smaller_than_num=None, sort=0, print_show=1): +def count_file_in_sub_directory(directory='./', sort=0, reverse=1, print_show=1, smaller_than_num=None): import os import numpy as np dirs_list = [] @@ -335,23 +335,33 @@ def count_file_in_sub_directory(directory='./', smaller_than_num=None, sort=0, p print(sub_dir) print(count_file) print() + if sort == 0: + sub_directory = dirs_list + num_in_sub_directory = count_file_array if sort == 1: - if print_show == 1: + sub_directory = [] + num_in_sub_directory = [] + if reverse == 1: + index_array = np.argsort(count_file_array)[::-1] + else: index_array = np.argsort(count_file_array) - if smaller_than_num == None: - for i0 in index_array: + for i0 in index_array: + sub_directory.append(dirs_list[i0]) + num_in_sub_directory.append(count_file_array[i0]) + if print_show == 1: + if smaller_than_num == None: print(dirs_list[i0]) print(count_file_array[i0]) print() - else: - for i0 in index_array: + else: if count_file_array[i0]