Change default value to None for optional arguments

This commit is contained in:
Cédric Leporcq 2021-11-06 17:07:38 +01:00
parent adc738cab3
commit 63c8c66660
2 changed files with 11 additions and 11 deletions

View File

@ -47,14 +47,14 @@ _filter_options = [
click.option( click.option(
'--exclude', '--exclude',
'-E', '-E',
default=set(), default=None,
multiple=True, multiple=True,
help='Directories or files to exclude.', help='Directories or files to exclude.',
), ),
click.option( click.option(
'--ext', '--ext',
'-e', '-e',
default=set(), default=None,
multiple=True, multiple=True,
help="""Use filename help="""Use filename
extension to filter files for sorting. If value is '*', use extension to filter files for sorting. If value is '*', use
@ -64,7 +64,7 @@ _filter_options = [
click.option( click.option(
'--ignore-tags', '--ignore-tags',
'-I', '-I',
default=set(), default=None,
multiple=True, multiple=True,
help='Specific tags or group that will be ignored when\ help='Specific tags or group that will be ignored when\
searching for file data. Example \'File:FileModifyDate\' or \'Filename\'', searching for file data. Example \'File:FileModifyDate\' or \'Filename\'',
@ -300,7 +300,7 @@ def _sort(**kwargs):
@click.option( @click.option(
'--dedup-regex', '--dedup-regex',
'-d', '-d',
default=set(), default=None,
multiple=True, multiple=True,
help='Regex to match duplicate strings parts', help='Regex to match duplicate strings parts',
) )

View File

@ -309,8 +309,8 @@ class Paths:
def __init__( def __init__(
self, self,
exclude=set(), exclude=None,
extensions=set(), extensions=None,
glob='**/*', glob='**/*',
interactive=False, interactive=False,
logger=logging.getLogger(), logger=logging.getLogger(),
@ -320,7 +320,7 @@ class Paths:
# Options # Options
self.exclude = exclude self.exclude = exclude
if '%media' in extensions: if extensions and '%media' in extensions:
extensions.remove('%media') extensions.remove('%media')
self.extensions = extensions.union(Media.extensions) self.extensions = extensions.union(Media.extensions)
else: else:
@ -802,8 +802,8 @@ class Collection(SortMedias):
cache=False, cache=False,
day_begins=0, day_begins=0,
dry_run=False, dry_run=False,
exclude=set(), exclude=None,
extensions=set(), extensions=None,
glob='**/*', glob='**/*',
interactive=False, interactive=False,
ignore_tags=None, ignore_tags=None,
@ -1067,7 +1067,7 @@ class Collection(SortMedias):
return self.summary return self.summary
def dedup_regex(self, paths, dedup_regex, remove_duplicates=False): def dedup_regex(self, paths, dedup_regex=None, remove_duplicates=False):
"""Deduplicate file path parts""" """Deduplicate file path parts"""
# Check db # Check db
@ -1079,7 +1079,7 @@ class Collection(SortMedias):
d = r'\d{2}' d = r'\d{2}'
# Numeric date regex # Numeric date regex
if len(dedup_regex) == 0: if not dedup_regex:
date_num2 = re.compile( date_num2 = re.compile(
fr'([^0-9]{d}{delim}{d}{delim}|{delim}{d}{delim}{d}[^0-9])' fr'([^0-9]{d}{delim}{d}{delim}|{delim}{d}{delim}{d}[^0-9])'
) )