Add a limit of images to process
This commit is contained in:
parent
232a48faef
commit
7b1aa22050
1 changed files with 14 additions and 3 deletions
|
@ -51,7 +51,8 @@ class CustomFormatter(logging.Formatter):
|
|||
class image_classifier:
|
||||
|
||||
def __init__(self, debug_level, log_file, faces_directory, directory,
|
||||
no_move, people_folder, recursive, folder_date_format):
|
||||
no_move, people_folder, recursive, folder_date_format,
|
||||
limit):
|
||||
''' Initial function called when object is created '''
|
||||
self.debug_level = debug_level
|
||||
if log_file is None:
|
||||
|
@ -72,12 +73,17 @@ class image_classifier:
|
|||
self.people_folder = people_folder
|
||||
self.recursive = recursive
|
||||
self.folder_date_format = folder_date_format
|
||||
self.limit = limit
|
||||
|
||||
if self.recursive:
|
||||
entries = self.recursive_scandir(directory)
|
||||
else:
|
||||
entries = list()
|
||||
count = 0
|
||||
for entry in os.scandir(directory):
|
||||
count += 1
|
||||
if count > limit:
|
||||
break
|
||||
entries.append(entry)
|
||||
self._log.debug(f"Processing {len(entries)} files...")
|
||||
for entry in entries:
|
||||
|
@ -415,13 +421,18 @@ for files in the provided --directory')
|
|||
help='Format for the folder with the file date according to \
|
||||
https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior'
|
||||
)
|
||||
@click.option(
|
||||
'--limit', '-l',
|
||||
default=1000,
|
||||
help='Limit the number of files to process'
|
||||
)
|
||||
@click_config_file.configuration_option()
|
||||
def __main__(debug_level, log_file, faces_directory, directory, no_move,
|
||||
people_folder, recursive, folder_date_format):
|
||||
people_folder, recursive, folder_date_format, limit):
|
||||
return image_classifier(
|
||||
debug_level, log_file, faces_directory, directory,
|
||||
no_move, people_folder, recursive,
|
||||
folder_date_format
|
||||
folder_date_format, limit
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue