Use parameter for ignored fields
This commit is contained in:
parent
c0c401074b
commit
c008dcb3c1
5 changed files with 24 additions and 14 deletions
|
@ -31,6 +31,10 @@ Options:
|
||||||
-D, --duplicates-destination TEXT
|
-D, --duplicates-destination TEXT
|
||||||
Directory to move duplicates files, relative
|
Directory to move duplicates files, relative
|
||||||
to the directory containing the vCards. Default: duplicates
|
to the directory containing the vCards. Default: duplicates
|
||||||
|
-i, --ignore-field TEXT Fields to ignore when considering duplicate
|
||||||
|
contacts. Default: ["prodid", "uid", "version",
|
||||||
|
"rev", "x-thunderbird-etag", "x-mozilla-html", "photo",
|
||||||
|
"categories"]
|
||||||
--config FILE Read configuration from FILE.
|
--config FILE Read configuration from FILE.
|
||||||
--help Show this message and exit.```
|
--help Show this message and exit.```
|
||||||
|
|
||||||
|
|
|
@ -37,16 +37,6 @@ class FindDuplicateContacts:
|
||||||
)
|
)
|
||||||
self._init_log()
|
self._init_log()
|
||||||
|
|
||||||
self.ignore_fields = [
|
|
||||||
"prodid",
|
|
||||||
"uid",
|
|
||||||
"version",
|
|
||||||
"rev",
|
|
||||||
"x-thunderbird-etag",
|
|
||||||
"x-mozilla-html",
|
|
||||||
"photo"
|
|
||||||
]
|
|
||||||
|
|
||||||
self.duplicates_folder = os.path.join(
|
self.duplicates_folder = os.path.join(
|
||||||
self.config['directory'],
|
self.config['directory'],
|
||||||
self.config['duplicates_destination']
|
self.config['duplicates_destination']
|
||||||
|
@ -80,7 +70,7 @@ class FindDuplicateContacts:
|
||||||
vcard = vobject.readOne(content)
|
vcard = vobject.readOne(content)
|
||||||
|
|
||||||
for key in vcard.contents.keys():
|
for key in vcard.contents.keys():
|
||||||
if key not in self.ignore_fields:
|
if key not in self.config['ignore_field']:
|
||||||
card['content'][key] = list()
|
card['content'][key] = list()
|
||||||
for item in vcard.contents[key]:
|
for item in vcard.contents[key]:
|
||||||
card['content'][key].append(item.value)
|
card['content'][key].append(item.value)
|
||||||
|
@ -242,6 +232,22 @@ class FindDuplicateContacts:
|
||||||
default='duplicates',
|
default='duplicates',
|
||||||
help='Directory to move duplicates files, relative to the directory containing the vCards.'
|
help='Directory to move duplicates files, relative to the directory containing the vCards.'
|
||||||
)
|
)
|
||||||
|
@click.option(
|
||||||
|
'--ignore-field',
|
||||||
|
'-i',
|
||||||
|
multiple=True,
|
||||||
|
default = [
|
||||||
|
"prodid",
|
||||||
|
"uid",
|
||||||
|
"version",
|
||||||
|
"rev",
|
||||||
|
"x-thunderbird-etag",
|
||||||
|
"x-mozilla-html",
|
||||||
|
"photo",
|
||||||
|
"categories"
|
||||||
|
],
|
||||||
|
help='Fields to ignore when considering duplicate contacts.',
|
||||||
|
)
|
||||||
@click_config_file.configuration_option()
|
@click_config_file.configuration_option()
|
||||||
def __main__(**kwargs):
|
def __main__(**kwargs):
|
||||||
return FindDuplicateContacts(**kwargs)
|
return FindDuplicateContacts(**kwargs)
|
||||||
|
|
|
@ -7,7 +7,7 @@ Homepage = "https://repos.susurrando.com/adelgado/find_duplicate_contacts"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "find_duplicate_contacts"
|
name = "find_duplicate_contacts"
|
||||||
version = "1.0.0"
|
version = "1.0.1"
|
||||||
description = "Find duplicate contacts in vCard files"
|
description = "Find duplicate contacts in vCard files"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
authors = [{ name = "Antonio J. Delgado", email = "TXj6QGdwejbTD1iWAj2ws9pnV@susurrando.com" }]
|
authors = [{ name = "Antonio J. Delgado", email = "TXj6QGdwejbTD1iWAj2ws9pnV@susurrando.com" }]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[metadata]
|
[metadata]
|
||||||
name = find_duplicate_contacts
|
name = find_duplicate_contacts
|
||||||
version = 1.0.0
|
version = 1.0.1
|
||||||
|
|
||||||
[options]
|
[options]
|
||||||
packages = find_duplicate_contacts
|
packages = find_duplicate_contacts
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -11,7 +11,7 @@ config.read('setup.cfg')
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
scripts=['find_duplicate_contacts/find_duplicate_contacts.py'],
|
scripts=['find_duplicate_contacts/find_duplicate_contacts.py'],
|
||||||
author="Antonio J. Delgado",
|
author="Antonio J. Delgado",
|
||||||
version='1.0.0',
|
version='1.0.1',
|
||||||
name='find_duplicate_contacts',
|
name='find_duplicate_contacts',
|
||||||
author_email="TXj6QGdwejbTD1iWAj2ws9pnV@susurrando.com",
|
author_email="TXj6QGdwejbTD1iWAj2ws9pnV@susurrando.com",
|
||||||
url="https://susurrando.com",
|
url="https://susurrando.com",
|
||||||
|
|
Loading…
Reference in a new issue