update
This commit is contained in:
		| @@ -14,7 +14,7 @@ def main(): | ||||
|     # guan.delete_file_with_specific_name(directory) | ||||
|  | ||||
|  | ||||
| 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, missed_directory_with_words=[]): | ||||
|     import os | ||||
|     directory_with_file = [] | ||||
|     missed_directory = [] | ||||
| @@ -28,6 +28,14 @@ def creat_necessary_file(directory, filename='readme', file_format='.md', conten | ||||
|     if overwrite == None: | ||||
|         for root in missed_directory: | ||||
|             directory_with_file.remove(root) | ||||
|     missed_directory_more =[] | ||||
|     for root in directory_with_file:  | ||||
|         for word in missed_directory_with_words: | ||||
|             if word in root: | ||||
|                 if root not in missed_directory_more: | ||||
|                     missed_directory_more.append(root) | ||||
|     for root in missed_directory_more: | ||||
|         directory_with_file.remove(root)  | ||||
|     for root in directory_with_file: | ||||
|         os.chdir(root) | ||||
|         f = open(filename+file_format, 'w', encoding="utf-8") | ||||
|   | ||||
| @@ -13,18 +13,23 @@ def main(): | ||||
|     print(repeated_file) | ||||
|  | ||||
|     # import guan | ||||
|     # 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_with_words=[], missed_file_with_words=[], num=1000) | ||||
|     # print(repeated_file) | ||||
|  | ||||
|  | ||||
| def find_repeated_file_with_same_filename(directory='./', missed_directory='./missed_directory', num=1000): | ||||
| def find_repeated_file_with_same_filename(directory='./', missed_directory_with_words=[], missed_file_with_words=[], num=1000): | ||||
|     import os | ||||
|     from collections import Counter | ||||
|     file_list = [] | ||||
|     for root, dirs, files in os.walk(directory): | ||||
|         for i0 in range(len(files)): | ||||
|             if missed_directory not in root: | ||||
|                 file_list.append(files[i0]) | ||||
|             file_list.append(files[i0]) | ||||
|             for word in missed_file_with_words: | ||||
|                 if word in files[i0]: | ||||
|                     file_list.remove(files[i0])    | ||||
|             for word in missed_directory_with_words: | ||||
|                 if word in root: | ||||
|                     file_list.remove(files[i0])    | ||||
|     count_file = Counter(file_list).most_common(num) | ||||
|     repeated_file = [] | ||||
|     for item in count_file: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user