add limit
This commit is contained in:
parent
06a897f6c2
commit
e084740d9e
1 changed files with 7 additions and 3 deletions
|
@ -17,7 +17,7 @@ import re
|
|||
|
||||
class find_duplicate_files:
|
||||
|
||||
def __init__(self, debug_level, log_file, dummy, first_directory, second_directory, exclude):
|
||||
def __init__(self, debug_level, log_file, dummy, first_directory, second_directory, exclude, limit):
|
||||
''' Initial function called when object is created '''
|
||||
self.config = dict()
|
||||
self.config['debug_level'] = debug_level
|
||||
|
@ -30,6 +30,7 @@ class find_duplicate_files:
|
|||
self.first_directory = first_directory
|
||||
self.second_directory = second_directory
|
||||
self.exclude = exclude
|
||||
self.limit = limit
|
||||
|
||||
self._init_db_cache()
|
||||
|
||||
|
@ -89,6 +90,8 @@ class find_duplicate_files:
|
|||
files = dict()
|
||||
try:
|
||||
for file in os.scandir(path):
|
||||
if len(files) > self.limit:
|
||||
break
|
||||
if not file.name.startswith('.'):
|
||||
if not self._test_exclude(file.path):
|
||||
if file.is_file():
|
||||
|
@ -155,9 +158,10 @@ class find_duplicate_files:
|
|||
@click.option('--first-directory', '-f', required=True, help='First directory to find files AND TO DELETE FILES FROM!!!')
|
||||
@click.option('--second-directory', '-s', required=True, help='Second directory to find files')
|
||||
@click.option('--exclude', '-e', multiple=True, help='Regular expression pattern to exclude from files and directories.')
|
||||
@click.option('--limit', '-l', default=None, help='Limit to a certain number of files to check.')
|
||||
@click_config_file.configuration_option()
|
||||
def __main__(debug_level, log_file, dummy, first_directory, second_directory, exclude):
|
||||
return find_duplicate_files(debug_level, log_file, dummy, first_directory, second_directory, exclude)
|
||||
def __main__(debug_level, log_file, dummy, first_directory, second_directory, exclude, limit):
|
||||
return find_duplicate_files(debug_level, log_file, dummy, first_directory, second_directory, exclude, limit)
|
||||
|
||||
if __name__ == "__main__":
|
||||
__main__()
|
||||
|
|
Loading…
Reference in a new issue