contact-person-profile-csv-imp-local 0.0.39__tar.gz → 0.0.43__tar.gz
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-0.0.39 → contact_person_profile_csv_imp_local-0.0.43}/PKG-INFO +2 -2
- {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.43}/contact_person_profile_csv_imp_local/src/CSVToContactPersonProfile.py +87 -47
- {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.43}/contact_person_profile_csv_imp_local.egg-info/PKG-INFO +2 -2
- {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.43}/contact_person_profile_csv_imp_local.egg-info/requires.txt +1 -1
- {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.43}/pyproject.toml +1 -1
- {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.43}/setup.py +2 -2
- {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.43}/README.md +0 -0
- {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.43}/contact_person_profile_csv_imp_local/src/__init__.py +0 -0
- {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.43}/contact_person_profile_csv_imp_local/src/contact_person_profile_csv_imp_local_constants.py +0 -0
- {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.43}/contact_person_profile_csv_imp_local.egg-info/SOURCES.txt +0 -0
- {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.43}/contact_person_profile_csv_imp_local.egg-info/dependency_links.txt +0 -0
- {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.43}/contact_person_profile_csv_imp_local.egg-info/top_level.txt +0 -0
- {contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.43}/setup.cfg +0 -0
{contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.43}/PKG-INFO
RENAMED
|
@@ -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.43
|
|
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
|
|
@@ -14,7 +14,7 @@ Requires-Dist: logger-local>=0.0.135
|
|
|
14
14
|
Requires-Dist: database-mysql-local>=0.0.290
|
|
15
15
|
Requires-Dist: user-context-remote>=0.0.77
|
|
16
16
|
Requires-Dist: contact-email-address-local>=0.0.8
|
|
17
|
-
Requires-Dist: contact-group-local>=0.0.
|
|
17
|
+
Requires-Dist: contact-group-local>=0.0.68
|
|
18
18
|
Requires-Dist: contact-location-local>=0.0.14
|
|
19
19
|
Requires-Dist: contact-notes-local>=0.0.33
|
|
20
20
|
Requires-Dist: contact-persons-local>=0.0.8
|
|
@@ -30,10 +30,10 @@ from contact_local.contact_local import ContactsLocal
|
|
|
30
30
|
from contact_group_local.contact_group import ContactGroups
|
|
31
31
|
from contact_email_address_local.contact_email_addresses_local import ContactEmailAdressesLocal
|
|
32
32
|
|
|
33
|
-
# import pycountry
|
|
34
33
|
from phonenumbers import NumberParseException
|
|
35
34
|
from user_context_remote.user_context import UserContext
|
|
36
35
|
from user_external_local.user_externals_local import UserExternalsLocal
|
|
36
|
+
from group_local.group_type import group_type
|
|
37
37
|
|
|
38
38
|
# from contact_local.contact_local import ContactsLocal
|
|
39
39
|
# from database_mysql_local.generic_crud import GenericCRUD
|
|
@@ -107,39 +107,58 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
107
107
|
object=CSVToContactPersonProfileConstants.CSV_LOCAL_PYTHON_PACKAGE_CODE_LOGGER_OBJECT):
|
|
108
108
|
# TODO Shall we have the groups_str parameter in the constructor or when running the each import so we can use different groups_str for every import
|
|
109
109
|
def __init__(self, groups_str: str = None, is_test_data: bool = False) -> None:
|
|
110
|
+
self._instances = {}
|
|
111
|
+
self.classes = [ContactsLocal, OrganizationProfilesLocal, ContactPersonsLocal, ContactUserExternalLocal,
|
|
112
|
+
ContactProfilesLocal, ContactGroups, ContactEmailAdressesLocal, ContactPhoneLocal,
|
|
113
|
+
ContactLocationLocal, UserExternalsLocal, OrganizationsLocal, DomainLocal, ImportersLocal]
|
|
114
|
+
self.instances_names = ['contacts_local', 'organization_profiles', 'contact_persons', 'contact_user_external',
|
|
115
|
+
'contact_profiles', 'contact_groups', 'contact_email_addresses', 'contact_phone',
|
|
116
|
+
'contact_location', 'user_externals_local', 'organizations_local', 'domain_local',
|
|
117
|
+
'importers_local']
|
|
110
118
|
GenericCRUD.__init__(self, default_schema_name="field", default_column_name="field_id",
|
|
111
119
|
default_table_name="field_table", default_view_table_name="field_view",
|
|
112
120
|
is_test_data=is_test_data)
|
|
113
121
|
self.contact_entity_type_id = self.select_one_value_by_column_and_value(
|
|
114
122
|
schema_name="entity_type", view_table_name="entity_type_ml_en_view",
|
|
115
123
|
select_clause_value="entity_type_id", column_name="title", column_value="Contact")
|
|
116
|
-
self.
|
|
124
|
+
self.list_of_group_dicts: list[str] = [group.strip() for group in groups_str.split(",")] if groups_str else []
|
|
117
125
|
self.user_context = UserContext()
|
|
118
|
-
self.organization_profiles =
|
|
119
|
-
self.contact_persons =
|
|
120
|
-
self.contact_user_external =
|
|
121
|
-
self.contact_profiles =
|
|
122
|
-
self.contact_groups =
|
|
123
|
-
self.contact_email_addresses =
|
|
124
|
-
self.contact_phone =
|
|
125
|
-
self.contact_location =
|
|
126
|
-
self.contacts_local =
|
|
127
|
-
self.user_externals_local =
|
|
128
|
-
self.organizations_local =
|
|
129
|
-
self.domain_local =
|
|
130
|
-
self.importers_local =
|
|
126
|
+
self.organization_profiles: OrganizationProfilesLocal = None
|
|
127
|
+
self.contact_persons: ContactPersonsLocal = None
|
|
128
|
+
self.contact_user_external: ContactUserExternalLocal = None
|
|
129
|
+
self.contact_profiles: ContactProfilesLocal = None
|
|
130
|
+
self.contact_groups: ContactGroups = None
|
|
131
|
+
self.contact_email_addresses: ContactEmailAdressesLocal = None
|
|
132
|
+
self.contact_phone: ContactPhoneLocal = None
|
|
133
|
+
self.contact_location: ContactLocationLocal = None
|
|
134
|
+
self.contacts_local: ContactsLocal = None
|
|
135
|
+
self.user_externals_local: UserExternalsLocal = None
|
|
136
|
+
self.organizations_local: OrganizationsLocal = None
|
|
137
|
+
self.domain_local: DomainLocal = None
|
|
138
|
+
self.importers_local: ImportersLocal = None
|
|
139
|
+
|
|
131
140
|
self.data_sources = DataSources()
|
|
132
|
-
self.
|
|
133
|
-
self.unknown_main_group_type_id =
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
self.list_of_group_dicts = None
|
|
142
|
+
self.unknown_main_group_type_id = group_type.get('Unknown')
|
|
143
|
+
self.organization_main_group_type_id = group_type.get('Organization')
|
|
144
|
+
self.job_title_main_group_type_id = group_type.get('Job Title')
|
|
145
|
+
|
|
146
|
+
def __getattribute__(self, name):
|
|
147
|
+
# Call the original __getattribute__
|
|
148
|
+
value = super().__getattribute__(name)
|
|
149
|
+
|
|
150
|
+
# If value is None and name is in instances_names, initialize it
|
|
151
|
+
if value is None and name in self.instances_names:
|
|
152
|
+
for index, cls in enumerate(self.classes):
|
|
153
|
+
if self.instances_names[index] == name:
|
|
154
|
+
instance = cls()
|
|
155
|
+
self._instances[name] = instance
|
|
156
|
+
setattr(self, name, instance)
|
|
157
|
+
return instance
|
|
158
|
+
|
|
159
|
+
# Otherwise, return the value
|
|
160
|
+
return value
|
|
161
|
+
|
|
143
162
|
|
|
144
163
|
# # TODO Does this function should be here on in https://github.com/circles-zone/variable-local-python-package/tree/dev/variable_local_python_package/variable_local/src "field/field.py"?
|
|
145
164
|
# def __get_field_name(self, field_id: int, data_source_type_id: int) -> str:
|
|
@@ -173,10 +192,10 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
173
192
|
# TODO Align the parameters between import-contact-csv with sync-google-contact
|
|
174
193
|
# TODO Can we please add groups_str parameter to both sync-google-contact and import-contact-csv where we add all contacts to those groups?
|
|
175
194
|
def insert_update_contact_from_csv(
|
|
176
|
-
self, *,
|
|
195
|
+
self, *, user_external_username: str, email_address: str, data_source_type_id: int, file_name: str = None, system_id: int = None,
|
|
177
196
|
# TODO Add support to criteria_set_id
|
|
178
197
|
directory_name: str = None, csv_path: str = None, start_index: int = 0, end_index: int = None,
|
|
179
|
-
|
|
198
|
+
list_of_group_dicts: list[dict] = None) -> dict:
|
|
180
199
|
"""
|
|
181
200
|
Insert contacts from CSV file to the database
|
|
182
201
|
:param data_source_type_id: The data source id
|
|
@@ -193,14 +212,23 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
193
212
|
:return:
|
|
194
213
|
"""
|
|
195
214
|
data_source_type_name = DataSources().get_data_source_name_by_id(data_source_type_id)
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
215
|
+
# TODO There can be multiple profiles with the same email, why not to query `user_external_table`.`main_profile_id`?
|
|
216
|
+
# Answer: first, We can't query tables with GenericCRUD, second, we may not find profile_id in user_external table
|
|
217
|
+
# and may have to insert a new record to user_external_table, in this case we need profile_id from profile_view
|
|
218
|
+
profile_id = self.select_one_value_by_column_and_value(
|
|
219
|
+
schema_name="user_external", view_table_name="user_external_view",
|
|
220
|
+
select_clause_value="main_profile_id", column_name="username", column_value=user_external_username)
|
|
221
|
+
if profile_id is None:
|
|
222
|
+
profile_id = ProfilesLocal().select_one_value_by_column_and_value(
|
|
223
|
+
schema_name="profile", view_table_name="profile_view",
|
|
224
|
+
select_clause_value="profile_id", column_name="profile.main_email_address",
|
|
225
|
+
column_value=email_address)
|
|
226
|
+
if profile_id is None:
|
|
227
|
+
self.logger.error("Couldn't find profile_id in profile_view by email_address.")
|
|
228
|
+
raise Exception("Couldn't find profile_id in user_external or profile_view.")
|
|
200
229
|
system_id = system_id or CONTACT_PERSON_PROFILE_CSV_SYSTEM_ID
|
|
201
230
|
self.set_schema(schema_name="field")
|
|
202
|
-
|
|
203
|
-
self.groups_list = groups_dicts if groups_dicts else []
|
|
231
|
+
self.list_of_group_dicts = list_of_group_dicts if list_of_group_dicts else []
|
|
204
232
|
'''
|
|
205
233
|
profile_id = ProfilesLocal().select_one_value_by_column_and_value(
|
|
206
234
|
schema_name="profile", view_table_name="profile_view",
|
|
@@ -219,7 +247,6 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
219
247
|
csv_file_path = os.path.join(script_dir, '..', directory_name or '', file_name)
|
|
220
248
|
if not os.path.exists(csv_file_path):
|
|
221
249
|
raise FileNotFoundError(f"File {csv_file_path} not found")
|
|
222
|
-
|
|
223
250
|
# TODO Why do we need it? - Those fields will be added to the contact_dict
|
|
224
251
|
contact_fields_to_keep = (
|
|
225
252
|
'name_prefix', 'additional_name', 'name_suffix', 'nickname', 'full_name', 'title', 'department', 'notes',
|
|
@@ -229,13 +256,13 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
229
256
|
'address1_country', 'address2_street', 'address2_city', 'address2_state', 'address2_postal_code',
|
|
230
257
|
'address2_country', 'job_title', 'organization', 'display_as')
|
|
231
258
|
|
|
232
|
-
user_external_id = self.__get_user_external_id(user_external_username=
|
|
259
|
+
user_external_id = self.__get_user_external_id(user_external_username=user_external_username,
|
|
233
260
|
profile_id=profile_id, system_id=system_id)
|
|
234
261
|
# We create a new data_source_instance_id everytime we import a new csv file
|
|
235
262
|
data_source_instance_id = self.__get_data_source_instance_id(
|
|
236
263
|
data_source_type_id=data_source_type_id, csv_file_path=csv_file_path,
|
|
237
264
|
user_external_id=user_external_id, file_name=file_name,
|
|
238
|
-
user_external_username=
|
|
265
|
+
user_external_username=user_external_username,
|
|
239
266
|
start_index=start_index, end_index=end_index
|
|
240
267
|
)
|
|
241
268
|
fields_dictonary = self.data_sources.get_fields_name_from_csv(data_source_type_id)
|
|
@@ -509,9 +536,8 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
509
536
|
|
|
510
537
|
def __insert_link_contact_groups(self, contact_dict: dict) -> list:
|
|
511
538
|
contact_id = contact_dict.get("contact_id")
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
linked_groups_results_list = None
|
|
539
|
+
groups_dicts_list = []
|
|
540
|
+
linked_groups_results_list = []
|
|
515
541
|
organization = contact_dict.get("organization")
|
|
516
542
|
if organization:
|
|
517
543
|
organization_group_dict = {
|
|
@@ -524,7 +550,8 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
524
550
|
"is_main_title": False,
|
|
525
551
|
"title": organization,
|
|
526
552
|
}
|
|
527
|
-
|
|
553
|
+
# TODO Lvalue group Rvalue organization?
|
|
554
|
+
groups_dicts_list.append(organization_group_dict)
|
|
528
555
|
job_title = contact_dict.get("job_title")
|
|
529
556
|
if job_title:
|
|
530
557
|
job_title_group_dict = {
|
|
@@ -537,7 +564,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
537
564
|
"is_main_title": False,
|
|
538
565
|
"title": job_title,
|
|
539
566
|
}
|
|
540
|
-
|
|
567
|
+
groups_dicts_list.append(job_title_group_dict)
|
|
541
568
|
if contact_dict.get("groups"):
|
|
542
569
|
# TODO _contacts_groups_names_list?
|
|
543
570
|
_groups = contact_dict.get("groups").split(", ")
|
|
@@ -552,12 +579,12 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
552
579
|
"is_main_title": False,
|
|
553
580
|
"title": group,
|
|
554
581
|
}
|
|
555
|
-
|
|
556
|
-
for group in self.
|
|
557
|
-
|
|
558
|
-
if len(
|
|
582
|
+
groups_dicts_list.append(group_dict)
|
|
583
|
+
for group in self.list_of_group_dicts:
|
|
584
|
+
groups_dicts_list.append(group)
|
|
585
|
+
if len(groups_dicts_list) > 0:
|
|
559
586
|
linked_groups_results_list = self.contact_groups.insert_link_contact_group_with_group_local(
|
|
560
|
-
contact_id=contact_id, groups_list_of_dicts=
|
|
587
|
+
contact_id=contact_id, groups_list_of_dicts=groups_dicts_list)
|
|
561
588
|
contact_dict["linked_group_results_list"] = linked_groups_results_list
|
|
562
589
|
|
|
563
590
|
return linked_groups_results_list
|
|
@@ -797,6 +824,8 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
797
824
|
proccessed_location_dicts.append(current_location_dict)
|
|
798
825
|
for email_address in email_addresses_list:
|
|
799
826
|
country = Country.get_country_name_by_email_address(email_address)
|
|
827
|
+
if country is None:
|
|
828
|
+
continue
|
|
800
829
|
current_location_dict = {
|
|
801
830
|
"address_local_language": None,
|
|
802
831
|
"city": None,
|
|
@@ -863,9 +892,20 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
863
892
|
system_id=system_id,
|
|
864
893
|
access_token=""
|
|
865
894
|
)
|
|
895
|
+
# TODO There can be the same username in multiple user_external_id, we should add more fields system_id, end_timestamp ...
|
|
866
896
|
user_external_id = self.user_externals_local.select_one_value_by_column_and_value(
|
|
867
897
|
select_clause_value="user_external_id", column_name="username",
|
|
868
898
|
column_value=user_external_username, order_by="user_external_id DESC")
|
|
899
|
+
if user_external_id is None:
|
|
900
|
+
self.logger.error("Couldn't find user_external_id in user_external by username.")
|
|
901
|
+
raise Exception("Couldn't find user_external_id in user_external by username.")
|
|
902
|
+
# TODO: Why do we have profile_user_external schema? user_external_table already has profile_id
|
|
903
|
+
profile_user_external_data_dict = {"profile_id": profile_id, "user_external_id": user_external_id}
|
|
904
|
+
profile_user_external_id = self.insert_if_not_exists(
|
|
905
|
+
schema_name="profile_user_external", table_name="profile_user_external_table",
|
|
906
|
+
view_table_name="profile_user_external_view", data_dict=profile_user_external_data_dict,
|
|
907
|
+
data_dict_compare=profile_user_external_data_dict
|
|
908
|
+
)
|
|
869
909
|
|
|
870
910
|
return user_external_id
|
|
871
911
|
|
|
@@ -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.43
|
|
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
|
|
@@ -14,7 +14,7 @@ Requires-Dist: logger-local>=0.0.135
|
|
|
14
14
|
Requires-Dist: database-mysql-local>=0.0.290
|
|
15
15
|
Requires-Dist: user-context-remote>=0.0.77
|
|
16
16
|
Requires-Dist: contact-email-address-local>=0.0.8
|
|
17
|
-
Requires-Dist: contact-group-local>=0.0.
|
|
17
|
+
Requires-Dist: contact-group-local>=0.0.68
|
|
18
18
|
Requires-Dist: contact-location-local>=0.0.14
|
|
19
19
|
Requires-Dist: contact-notes-local>=0.0.33
|
|
20
20
|
Requires-Dist: contact-persons-local>=0.0.8
|
|
@@ -3,7 +3,7 @@ logger-local>=0.0.135
|
|
|
3
3
|
database-mysql-local>=0.0.290
|
|
4
4
|
user-context-remote>=0.0.77
|
|
5
5
|
contact-email-address-local>=0.0.8
|
|
6
|
-
contact-group-local>=0.0.
|
|
6
|
+
contact-group-local>=0.0.68
|
|
7
7
|
contact-location-local>=0.0.14
|
|
8
8
|
contact-notes-local>=0.0.33
|
|
9
9
|
contact-persons-local>=0.0.8
|
|
@@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta"
|
|
|
10
10
|
name = "<project-name>"
|
|
11
11
|
# I believe we are still using the version from setup.py and not from here until potery will work
|
|
12
12
|
version = "0.0.2" # https://pypi.org/project/<project-name> i.e. https://pypi.org/project/storage-local/
|
|
13
|
-
description = "
|
|
13
|
+
description = "Contact Person Profile CSV Imp Python Package"
|
|
14
14
|
readme = "README.md"
|
|
15
15
|
authors = [
|
|
16
16
|
"Circlez.ai <info@circlez.ai>",
|
{contact_person_profile_csv_imp_local-0.0.39 → contact_person_profile_csv_imp_local-0.0.43}/setup.py
RENAMED
|
@@ -5,7 +5,7 @@ package_dir = PACKAGE_NAME.replace("-", "_")
|
|
|
5
5
|
|
|
6
6
|
setuptools.setup(
|
|
7
7
|
name=PACKAGE_NAME,
|
|
8
|
-
version='0.0.
|
|
8
|
+
version='0.0.43', # https://pypi.org/project/contact-person-profile-csv-imp-local/
|
|
9
9
|
author="Circles",
|
|
10
10
|
author_email="info@circles.ai",
|
|
11
11
|
description="PyPI Package for Circles CSVToContactPersonProfile-local Local/Remote Python",
|
|
@@ -26,7 +26,7 @@ setuptools.setup(
|
|
|
26
26
|
'database-mysql-local>=0.0.290',
|
|
27
27
|
'user-context-remote>=0.0.77',
|
|
28
28
|
'contact-email-address-local>=0.0.8',
|
|
29
|
-
'contact-group-local>=0.0.
|
|
29
|
+
'contact-group-local>=0.0.68',
|
|
30
30
|
'contact-location-local>=0.0.14',
|
|
31
31
|
'contact-notes-local>=0.0.33',
|
|
32
32
|
'contact-persons-local>=0.0.8',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|