update
This commit is contained in:
parent
11885055f8
commit
c1cecd4d1d
@ -14,27 +14,27 @@ def main():
|
|||||||
# guan.delete_file_with_specific_name(directory)
|
# guan.delete_file_with_specific_name(directory)
|
||||||
|
|
||||||
|
|
||||||
def creat_necessary_file(directory, filename='readme', file_format='.md', content='', overwrite=None, missed_directory_with_words=[]):
|
def creat_necessary_file(directory, filename='readme', file_format='.md', content='', overwrite=None, ignored_directory_with_words=[]):
|
||||||
import os
|
import os
|
||||||
directory_with_file = []
|
directory_with_file = []
|
||||||
missed_directory = []
|
ignored_directory = []
|
||||||
for root, dirs, files in os.walk(directory):
|
for root, dirs, files in os.walk(directory):
|
||||||
for i0 in range(len(files)):
|
for i0 in range(len(files)):
|
||||||
if root not in directory_with_file:
|
if root not in directory_with_file:
|
||||||
directory_with_file.append(root)
|
directory_with_file.append(root)
|
||||||
if files[i0] == filename+file_format:
|
if files[i0] == filename+file_format:
|
||||||
if root not in missed_directory:
|
if root not in ignored_directory:
|
||||||
missed_directory.append(root)
|
ignored_directory.append(root)
|
||||||
if overwrite == None:
|
if overwrite == None:
|
||||||
for root in missed_directory:
|
for root in ignored_directory:
|
||||||
directory_with_file.remove(root)
|
directory_with_file.remove(root)
|
||||||
missed_directory_more =[]
|
ignored_directory_more =[]
|
||||||
for root in directory_with_file:
|
for root in directory_with_file:
|
||||||
for word in missed_directory_with_words:
|
for word in ignored_directory_with_words:
|
||||||
if word in root:
|
if word in root:
|
||||||
if root not in missed_directory_more:
|
if root not in ignored_directory_more:
|
||||||
missed_directory_more.append(root)
|
ignored_directory_more.append(root)
|
||||||
for root in missed_directory_more:
|
for root in ignored_directory_more:
|
||||||
directory_with_file.remove(root)
|
directory_with_file.remove(root)
|
||||||
for root in directory_with_file:
|
for root in directory_with_file:
|
||||||
os.chdir(root)
|
os.chdir(root)
|
||||||
|
@ -13,23 +13,26 @@ def main():
|
|||||||
print(repeated_file)
|
print(repeated_file)
|
||||||
|
|
||||||
# import guan
|
# import guan
|
||||||
# repeated_file = guan.find_repeated_file_with_same_filename(directory='./', missed_directory_with_words=[], missed_file_with_words=[], num=1000)
|
# repeated_file = guan.find_repeated_file_with_same_filename(directory='./', ignored_directory_with_words=[], ignored_file_with_words=[], num=1000)
|
||||||
# print(repeated_file)
|
# print(repeated_file)
|
||||||
|
|
||||||
|
|
||||||
def find_repeated_file_with_same_filename(directory='./', missed_directory_with_words=[], missed_file_with_words=[], num=1000):
|
def find_repeated_file_with_same_filename(directory='./', ignored_directory_with_words=[], ignored_file_with_words=[], num=1000):
|
||||||
import os
|
import os
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
file_list = []
|
file_list = []
|
||||||
for root, dirs, files in os.walk(directory):
|
for root, dirs, files in os.walk(directory):
|
||||||
for i0 in range(len(files)):
|
for i0 in range(len(files)):
|
||||||
file_list.append(files[i0])
|
file_list.append(files[i0])
|
||||||
for word in missed_file_with_words:
|
for word in ignored_directory_with_words:
|
||||||
if word in files[i0]:
|
|
||||||
file_list.remove(files[i0])
|
|
||||||
for word in missed_directory_with_words:
|
|
||||||
if word in root:
|
if word in root:
|
||||||
file_list.remove(files[i0])
|
file_list.remove(files[i0])
|
||||||
|
for word in ignored_file_with_words:
|
||||||
|
if word in files[i0]:
|
||||||
|
try:
|
||||||
|
file_list.remove(files[i0])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
count_file = Counter(file_list).most_common(num)
|
count_file = Counter(file_list).most_common(num)
|
||||||
repeated_file = []
|
repeated_file = []
|
||||||
for item in count_file:
|
for item in count_file:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user