The check happened in __main__ already

This commit is contained in:
KnugiHK
2024-07-13 12:12:32 +08:00
parent be469aed93
commit 823ed663e7
2 changed files with 3 additions and 11 deletions

View File

@@ -546,8 +546,8 @@ def main():
if (args.filter_empty):
data = {k: v for k, v in data.items() if not is_chat_empty(v)}
if contacts_names_from_vcards_enricher.should_enrich_names_from_vCards():
contacts_names_from_vcards_enricher.enrich_names_from_vCards(data)
if contact_store.should_enrich_from_vcards():
if isinstance(data[next(iter(data))], ChatStore):
data = {jik: chat.to_json() for jik, chat in data.items()}

View File

@@ -1,23 +1,15 @@
import itertools
from typing import List, TypedDict
try:
import vobject
except ModuleNotFoundError:
vcards_deps_installed = False
else:
vcards_deps_installed = True
import vobject
class ContactsNamesFromVCards:
def __init__(self) -> None:
self.l = []
def should_enrich_names_from_vCards(self):
def should_enrich_from_vcards(self):
return len(self.l) > 0
def load_vcf_file(self, vcfFilePath: str, default_country_calling_code: str):
if not vcards_deps_installed:
raise Exception('Invariant: vobject is missing')
self.l = readVCardsFile(vcfFilePath, default_country_calling_code)
def enrich_names_from_vCards(self, chats):