contact-person-profile-csv-imp-local 0.0.40__tar.gz → 0.0.44__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.40 → contact_person_profile_csv_imp_local-0.0.44}/PKG-INFO +2 -2
- {contact_person_profile_csv_imp_local-0.0.40 → contact_person_profile_csv_imp_local-0.0.44}/contact_person_profile_csv_imp_local/src/CSVToContactPersonProfile.py +65 -39
- {contact_person_profile_csv_imp_local-0.0.40 → contact_person_profile_csv_imp_local-0.0.44}/contact_person_profile_csv_imp_local.egg-info/PKG-INFO +2 -2
- {contact_person_profile_csv_imp_local-0.0.40 → contact_person_profile_csv_imp_local-0.0.44}/contact_person_profile_csv_imp_local.egg-info/requires.txt +1 -1
- {contact_person_profile_csv_imp_local-0.0.40 → contact_person_profile_csv_imp_local-0.0.44}/pyproject.toml +1 -1
- {contact_person_profile_csv_imp_local-0.0.40 → contact_person_profile_csv_imp_local-0.0.44}/setup.py +2 -2
- {contact_person_profile_csv_imp_local-0.0.40 → contact_person_profile_csv_imp_local-0.0.44}/README.md +0 -0
- {contact_person_profile_csv_imp_local-0.0.40 → contact_person_profile_csv_imp_local-0.0.44}/contact_person_profile_csv_imp_local/src/__init__.py +0 -0
- {contact_person_profile_csv_imp_local-0.0.40 → contact_person_profile_csv_imp_local-0.0.44}/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.40 → contact_person_profile_csv_imp_local-0.0.44}/contact_person_profile_csv_imp_local.egg-info/SOURCES.txt +0 -0
- {contact_person_profile_csv_imp_local-0.0.40 → contact_person_profile_csv_imp_local-0.0.44}/contact_person_profile_csv_imp_local.egg-info/dependency_links.txt +0 -0
- {contact_person_profile_csv_imp_local-0.0.40 → contact_person_profile_csv_imp_local-0.0.44}/contact_person_profile_csv_imp_local.egg-info/top_level.txt +0 -0
- {contact_person_profile_csv_imp_local-0.0.40 → contact_person_profile_csv_imp_local-0.0.44}/setup.cfg +0 -0
{contact_person_profile_csv_imp_local-0.0.40 → contact_person_profile_csv_imp_local-0.0.44}/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.44
|
|
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,11 +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
|
-
|
|
177
|
-
self, *, username: str, email_address: str, data_source_type_id: int, file_name: str = None, system_id: int = None,
|
|
195
|
+
self, *, user_external_username: str, email_address: str, data_source_type_id: int, file_name: str = None, system_id: int = None,
|
|
178
196
|
# TODO Add support to criteria_set_id
|
|
179
197
|
directory_name: str = None, csv_path: str = None, start_index: int = 0, end_index: int = None,
|
|
180
|
-
|
|
198
|
+
list_of_group_dicts: list[dict] = None) -> dict:
|
|
181
199
|
"""
|
|
182
200
|
Insert contacts from CSV file to the database
|
|
183
201
|
:param data_source_type_id: The data source id
|
|
@@ -194,16 +212,23 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
194
212
|
:return:
|
|
195
213
|
"""
|
|
196
214
|
data_source_type_name = DataSources().get_data_source_name_by_id(data_source_type_id)
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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)
|
|
201
226
|
if profile_id is None:
|
|
202
227
|
self.logger.error("Couldn't find profile_id in profile_view by email_address.")
|
|
203
|
-
raise Exception("Couldn't find profile_id in
|
|
228
|
+
raise Exception("Couldn't find profile_id in user_external or profile_view.")
|
|
204
229
|
system_id = system_id or CONTACT_PERSON_PROFILE_CSV_SYSTEM_ID
|
|
205
230
|
self.set_schema(schema_name="field")
|
|
206
|
-
self.
|
|
231
|
+
self.list_of_group_dicts = list_of_group_dicts if list_of_group_dicts else []
|
|
207
232
|
'''
|
|
208
233
|
profile_id = ProfilesLocal().select_one_value_by_column_and_value(
|
|
209
234
|
schema_name="profile", view_table_name="profile_view",
|
|
@@ -222,7 +247,6 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
222
247
|
csv_file_path = os.path.join(script_dir, '..', directory_name or '', file_name)
|
|
223
248
|
if not os.path.exists(csv_file_path):
|
|
224
249
|
raise FileNotFoundError(f"File {csv_file_path} not found")
|
|
225
|
-
|
|
226
250
|
# TODO Why do we need it? - Those fields will be added to the contact_dict
|
|
227
251
|
contact_fields_to_keep = (
|
|
228
252
|
'name_prefix', 'additional_name', 'name_suffix', 'nickname', 'full_name', 'title', 'department', 'notes',
|
|
@@ -232,13 +256,13 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
232
256
|
'address1_country', 'address2_street', 'address2_city', 'address2_state', 'address2_postal_code',
|
|
233
257
|
'address2_country', 'job_title', 'organization', 'display_as')
|
|
234
258
|
|
|
235
|
-
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,
|
|
236
260
|
profile_id=profile_id, system_id=system_id)
|
|
237
261
|
# We create a new data_source_instance_id everytime we import a new csv file
|
|
238
262
|
data_source_instance_id = self.__get_data_source_instance_id(
|
|
239
263
|
data_source_type_id=data_source_type_id, csv_file_path=csv_file_path,
|
|
240
264
|
user_external_id=user_external_id, file_name=file_name,
|
|
241
|
-
user_external_username=
|
|
265
|
+
user_external_username=user_external_username,
|
|
242
266
|
start_index=start_index, end_index=end_index
|
|
243
267
|
)
|
|
244
268
|
fields_dictonary = self.data_sources.get_fields_name_from_csv(data_source_type_id)
|
|
@@ -526,6 +550,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
526
550
|
"is_main_title": False,
|
|
527
551
|
"title": organization,
|
|
528
552
|
}
|
|
553
|
+
# TODO Lvalue group Rvalue organization?
|
|
529
554
|
groups_dicts_list.append(organization_group_dict)
|
|
530
555
|
job_title = contact_dict.get("job_title")
|
|
531
556
|
if job_title:
|
|
@@ -555,7 +580,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
555
580
|
"title": group,
|
|
556
581
|
}
|
|
557
582
|
groups_dicts_list.append(group_dict)
|
|
558
|
-
for group in self.
|
|
583
|
+
for group in self.list_of_group_dicts:
|
|
559
584
|
groups_dicts_list.append(group)
|
|
560
585
|
if len(groups_dicts_list) > 0:
|
|
561
586
|
linked_groups_results_list = self.contact_groups.insert_link_contact_group_with_group_local(
|
|
@@ -867,6 +892,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
|
|
|
867
892
|
system_id=system_id,
|
|
868
893
|
access_token=""
|
|
869
894
|
)
|
|
895
|
+
# TODO There can be the same username in multiple user_external_id, we should add more fields system_id, end_timestamp ...
|
|
870
896
|
user_external_id = self.user_externals_local.select_one_value_by_column_and_value(
|
|
871
897
|
select_clause_value="user_external_id", column_name="username",
|
|
872
898
|
column_value=user_external_username, order_by="user_external_id DESC")
|
|
@@ -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.44
|
|
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.40 → contact_person_profile_csv_imp_local-0.0.44}/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.44', # 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
|