diff --git a/API_Reference.py b/API_Reference.py index 207bd25..41bd882 100644 --- a/API_Reference.py +++ b/API_Reference.py @@ -343,6 +343,8 @@ guan.write_file_list_in_markdown(directory='./', filename='a', reverse_positive_ repeated_file = guan.find_repeated_file_with_same_filename(directory='./', missed_directory='./missed_directory', num=1000) +guan.count_file_in_sub_directory(directory='./', smaller_than_num=None) + guan.creat_necessary_file(directory, filename='readme', file_format='.md', content='', overwrite=None) guan.delete_file_with_specific_name(directory, filename='readme', file_format='.md') diff --git a/PyPI/setup.cfg b/PyPI/setup.cfg index 5e29fd0..24f12ea 100644 --- a/PyPI/setup.cfg +++ b/PyPI/setup.cfg @@ -1,7 +1,7 @@ [metadata] # replace with your username: name = guan -version = 0.0.139 +version = 0.0.140 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 dddd3b9..b5ec5cb 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.0.139 +Version: 0.0.140 Summary: An open source python package Home-page: https://py.guanjihuan.com Author: guanjihuan diff --git a/PyPI/src/guan/__init__.py b/PyPI/src/guan/__init__.py index ef25d2a..a191565 100644 --- a/PyPI/src/guan/__init__.py +++ b/PyPI/src/guan/__init__.py @@ -2,7 +2,7 @@ # With this package, you can calculate band structures, density of states, quantum transport and topological invariant of tight-binding models by invoking the functions you need. Other frequently used functions are also integrated in this package, such as file reading/writing, figure plotting, data processing. -# The current version is guan-0.0.139, updated on September 23, 2022. +# The current version is guan-0.0.140, updated on September 30, 2022. # Installation: pip install --upgrade guan @@ -2680,6 +2680,30 @@ def find_repeated_file_with_same_filename(directory='./', missed_directory='./mi repeated_file.append(item) return repeated_file +def count_file_in_sub_directory(directory='./', smaller_than_num=None): + import os + from collections import Counter + dirs_list = [] + for root, dirs, files in os.walk(directory): + if dirs != []: + for i0 in range(len(dirs)): + dirs_list.append(root+'/'+dirs[i0]) + for sub_dir in dirs_list: + file_list = [] + for root, dirs, files in os.walk(sub_dir): + for i0 in range(len(files)): + file_list.append(files[i0]) + count_file = len(file_list) + if smaller_than_num == None: + print(sub_dir) + print(count_file) + print() + else: + if count_file