contact-person-profile-csv-imp-local 0.0.26__py3-none-any.whl → 0.0.27__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- contact_person_profile_csv_imp_local/CSVToContactPersonProfile.py +24 -2
- {contact_person_profile_csv_imp_local-0.0.26.dist-info → contact_person_profile_csv_imp_local-0.0.27.dist-info}/METADATA +2 -1
- {contact_person_profile_csv_imp_local-0.0.26.dist-info → contact_person_profile_csv_imp_local-0.0.27.dist-info}/RECORD +5 -5
- {contact_person_profile_csv_imp_local-0.0.26.dist-info → contact_person_profile_csv_imp_local-0.0.27.dist-info}/WHEEL +0 -0
- {contact_person_profile_csv_imp_local-0.0.26.dist-info → contact_person_profile_csv_imp_local-0.0.27.dist-info}/top_level.txt +0 -0
|
@@ -2,6 +2,7 @@ import csv
|
|
|
2
2
|
import os
|
|
3
3
|
from datetime import datetime
|
|
4
4
|
from zoneinfo import ZoneInfo
|
|
5
|
+
import chardet
|
|
5
6
|
|
|
6
7
|
from .contact_person_profile_csv_imp_local_constants import CSVToContactPersonProfileConstants
|
|
7
8
|
from data_source_local.data_source import DataSources
|
|
@@ -185,7 +186,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
185
186
|
contact_fields_to_keep = (
|
|
186
187
|
'name_prefix', 'additional_name', 'name_suffix', 'nickname', 'full_name', 'title', 'department', 'notes',
|
|
187
188
|
'first_name', 'last_name', 'phone1', 'phone2', 'phone3', 'birthday', 'email1', 'email2', 'email3',
|
|
188
|
-
'hashtag', 'url',
|
|
189
|
+
'hashtag', 'url', 'groups',
|
|
189
190
|
'website1', 'handle', 'address1_street', 'address1_city', 'address1_state', 'address1_postal_code',
|
|
190
191
|
'address1_country', 'address2_street', 'address2_city', 'address2_state', 'address2_postal_code',
|
|
191
192
|
'address2_country', 'job_title', 'organization', 'display_as')
|
|
@@ -201,8 +202,9 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
201
202
|
fields_dictonary = self.data_sources.get_fields_name_from_csv(data_source_type_id)
|
|
202
203
|
keys = list(fields_dictonary.keys())
|
|
203
204
|
contact_data_by_contact_id_dict = {}
|
|
205
|
+
encoding = CSVToContactPersonProfile.detect_encoding(file_path=csv_file_path, data_source_type_id=data_source_type_id)
|
|
204
206
|
# TODO: break this into smaller functions
|
|
205
|
-
with (open(csv_file_path, 'r', encoding=
|
|
207
|
+
with (open(csv_file_path, 'r', encoding=encoding) as csv_file):
|
|
206
208
|
for row_index, row in enumerate(csv.DictReader(csv_file)):
|
|
207
209
|
if end_index is not None and not start_index <= row_index <= end_index:
|
|
208
210
|
continue
|
|
@@ -455,6 +457,10 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
455
457
|
groups.append(contact_dict.get("organization"))
|
|
456
458
|
if contact_dict.get("job_title"):
|
|
457
459
|
groups.append(contact_dict.get("job_title"))
|
|
460
|
+
if contact_dict.get("groups"):
|
|
461
|
+
_groups = contact_dict.get("groups").split(", ")
|
|
462
|
+
for group in _groups:
|
|
463
|
+
groups.append(group)
|
|
458
464
|
if len(groups) > 0:
|
|
459
465
|
groups_linked = self.contact_groups.insert_link_contact_group_with_group_local(
|
|
460
466
|
contact_id=contact_id, groups_names=groups)
|
|
@@ -548,6 +554,11 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
548
554
|
domain_insert_information_list.append(domain_insert_information)
|
|
549
555
|
website_count += 1
|
|
550
556
|
website_url = contact_dict.get("website" + str(website_count))
|
|
557
|
+
url = contact_dict.get("url")
|
|
558
|
+
if url:
|
|
559
|
+
domain_insert_information = self.domain_local.link_contact_to_domain(
|
|
560
|
+
contact_id=contact_id, url=url)
|
|
561
|
+
domain_insert_information_list.append(domain_insert_information)
|
|
551
562
|
|
|
552
563
|
return domain_insert_information_list
|
|
553
564
|
|
|
@@ -571,6 +582,8 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
571
582
|
url = "www.outlook.com"
|
|
572
583
|
elif data_source_type_id == 18:
|
|
573
584
|
url = "www.linkedin.com"
|
|
585
|
+
elif data_source_type_id == 57:
|
|
586
|
+
url = None
|
|
574
587
|
else:
|
|
575
588
|
raise ValueError("data_source_type_id is not valid")
|
|
576
589
|
importer_id = self.importers_local.insert(
|
|
@@ -744,3 +757,12 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
744
757
|
}
|
|
745
758
|
)
|
|
746
759
|
return data_source_instance_id
|
|
760
|
+
|
|
761
|
+
@staticmethod
|
|
762
|
+
def detect_encoding(file_path: str, data_source_type_id: int = None):
|
|
763
|
+
if data_source_type_id == 16 or data_source_type_id == 17 or data_source_type_id == 18:
|
|
764
|
+
return "utf-8"
|
|
765
|
+
else:
|
|
766
|
+
with open(file_path, 'rb') as f:
|
|
767
|
+
result = chardet.detect(f.read())
|
|
768
|
+
return result['encoding']
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: contact-person-profile-csv-imp-local
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.27
|
|
4
4
|
Summary: PyPI Package for Circles CSVToContactPersonProfile-local Local/Remote Python
|
|
5
5
|
Home-page: https://github.com/circles-zone/contact-person-profile-csv-imp-local-python-package
|
|
6
6
|
Author: Circles
|
|
@@ -29,5 +29,6 @@ Requires-Dist: organizations-local >=0.0.14
|
|
|
29
29
|
Requires-Dist: python-sdk-remote >=0.0.93
|
|
30
30
|
Requires-Dist: url-remote >=0.0.91
|
|
31
31
|
Requires-Dist: user-external-local >=0.0.42
|
|
32
|
+
Requires-Dist: chardet >=5.2.0
|
|
32
33
|
|
|
33
34
|
This is a package for sharing common XXX function used in different repositories
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
contact_person_profile_csv_imp_local/CSVToContactPersonProfile.py,sha256=
|
|
1
|
+
contact_person_profile_csv_imp_local/CSVToContactPersonProfile.py,sha256=149GozSMO6KHLNYJEyqpJagP7kgc4hjmN8tL0R-fPTI,41366
|
|
2
2
|
contact_person_profile_csv_imp_local/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
contact_person_profile_csv_imp_local/contact_person_profile_csv_imp_local_constants.py,sha256=eE0Bg2dCPrmG72K20k0_KOckc61C9cGSgH0Zgae_lbk,957
|
|
4
|
-
contact_person_profile_csv_imp_local-0.0.
|
|
5
|
-
contact_person_profile_csv_imp_local-0.0.
|
|
6
|
-
contact_person_profile_csv_imp_local-0.0.
|
|
7
|
-
contact_person_profile_csv_imp_local-0.0.
|
|
4
|
+
contact_person_profile_csv_imp_local-0.0.27.dist-info/METADATA,sha256=btOZUFx6tiDB2DE5UDJmqAZxE7cIYz8YcSXCo3U34e0,1481
|
|
5
|
+
contact_person_profile_csv_imp_local-0.0.27.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
6
|
+
contact_person_profile_csv_imp_local-0.0.27.dist-info/top_level.txt,sha256=at6BnVzULDB109KZx9Cl9ClCHU4c0ykfV38WX-QR71U,37
|
|
7
|
+
contact_person_profile_csv_imp_local-0.0.27.dist-info/RECORD,,
|
|
File without changes
|