This commit is contained in:
guanjihuan 2022-09-30 05:26:36 +08:00
parent 6d5bb85a75
commit 3099218ca2
4 changed files with 29 additions and 3 deletions

View File

@ -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) 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.creat_necessary_file(directory, filename='readme', file_format='.md', content='', overwrite=None)
guan.delete_file_with_specific_name(directory, filename='readme', file_format='.md') guan.delete_file_with_specific_name(directory, filename='readme', file_format='.md')

View File

@ -1,7 +1,7 @@
[metadata] [metadata]
# replace with your username: # replace with your username:
name = guan name = guan
version = 0.0.139 version = 0.0.140
author = guanjihuan author = guanjihuan
author_email = guanjihuan@163.com author_email = guanjihuan@163.com
description = An open source python package description = An open source python package

View File

@ -1,6 +1,6 @@
Metadata-Version: 2.1 Metadata-Version: 2.1
Name: guan Name: guan
Version: 0.0.139 Version: 0.0.140
Summary: An open source python package Summary: An open source python package
Home-page: https://py.guanjihuan.com Home-page: https://py.guanjihuan.com
Author: guanjihuan Author: guanjihuan

View File

@ -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. # 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 # Installation: pip install --upgrade guan
@ -2680,6 +2680,30 @@ def find_repeated_file_with_same_filename(directory='./', missed_directory='./mi
repeated_file.append(item) repeated_file.append(item)
return repeated_file 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<smaller_than_num:
print(sub_dir)
print(count_file)
print()
def creat_necessary_file(directory, filename='readme', file_format='.md', content='', overwrite=None): def creat_necessary_file(directory, filename='readme', file_format='.md', content='', overwrite=None):
import os import os
directory_with_file = [] directory_with_file = []