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

View File

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