@@ -107,54 +107,71 @@ def _add_first_contact(session, row, thing):
107107 "nma_pk_owners" : row .OwnerKey ,
108108 "addresses" : [],
109109 "emails" : [],
110- "phones" : []
110+ "phones" : [],
111111 }
112112
113113 contact = _make_contact_and_assoc (session , contact_data , thing )
114114
115115 if row .Email :
116- email = _make_email ('first' , row .OwnerKey , email = row .Email ,
117- email_type = "Primary" ,
118- release_status = release_status )
116+ email = _make_email (
117+ "first" ,
118+ row .OwnerKey ,
119+ email = row .Email ,
120+ email_type = "Primary" ,
121+ release_status = release_status ,
122+ )
119123 if email :
120124 contact .emails .append (email )
121125
122126 if row .Phone :
123- phone = _make_phone ('first' , row .OwnerKey , phone_number = row .Phone ,
124- phone_type = "Primary" ,
125- release_status = release_status )
127+ phone = _make_phone (
128+ "first" ,
129+ row .OwnerKey ,
130+ phone_number = row .Phone ,
131+ phone_type = "Primary" ,
132+ release_status = release_status ,
133+ )
126134 if phone :
127135 contact .phones .append (phone )
128136
129137 if row .CellPhone :
130- phone = _make_phone ('first' , row .OwnerKey , phone_number = row .CellPhone ,
131- phone_type = "Mobile" ,
132- release_status = release_status )
138+ phone = _make_phone (
139+ "first" ,
140+ row .OwnerKey ,
141+ phone_number = row .CellPhone ,
142+ phone_type = "Mobile" ,
143+ release_status = release_status ,
144+ )
133145 if phone :
134146 contact .phones .append (phone )
135147
136148 if row .MailingAddress :
137- address = _make_address ('first' , row .OwnerKey ,
138- 'mailing' ,
139- address_line_1 = row .MailingAddress ,
140- city = row .MailCity ,
141- state = row .MailState ,
142- postal_code = row .MailZipCode ,
143- address_type = "Mailing" ,
144- release_status = release_status )
149+ address = _make_address (
150+ "first" ,
151+ row .OwnerKey ,
152+ "mailing" ,
153+ address_line_1 = row .MailingAddress ,
154+ city = row .MailCity ,
155+ state = row .MailState ,
156+ postal_code = row .MailZipCode ,
157+ address_type = "Mailing" ,
158+ release_status = release_status ,
159+ )
145160 if address :
146161 contact .addresses .append (address )
147162
148163 if row .PhysicalAddress :
149- address = _make_address ('first' , row .OwnerKey ,
150- 'physical' ,
151- address_line_1 = row .PhysicalAddress ,
152- city = row .PhysicalCity ,
153- state = row .PhysicalState ,
154- postal_code = row .PhysicalZipCode ,
155- address_type = "Physical" ,
156- release_status = release_status
157- )
164+ address = _make_address (
165+ "first" ,
166+ row .OwnerKey ,
167+ "physical" ,
168+ address_line_1 = row .PhysicalAddress ,
169+ city = row .PhysicalCity ,
170+ state = row .PhysicalState ,
171+ postal_code = row .PhysicalZipCode ,
172+ address_type = "Physical" ,
173+ release_status = release_status ,
174+ )
158175 if address :
159176 contact .addresses .append (address )
160177
@@ -174,22 +191,30 @@ def _add_second_contact(session, row, thing):
174191 "nma_pk_owners" : row .OwnerKey ,
175192 "addresses" : [],
176193 "emails" : [],
177- "phones" : []
194+ "phones" : [],
178195 }
179196
180197 contact = _make_contact_and_assoc (session , contact_data , thing )
181198
182199 if row .SecondCtctEmail :
183- email = _make_email ('second' , row .OwnerKey , email = row .SecondCtctEmail ,
184- email_type = "Primary" ,
185- release_status = release_status )
200+ email = _make_email (
201+ "second" ,
202+ row .OwnerKey ,
203+ email = row .SecondCtctEmail ,
204+ email_type = "Primary" ,
205+ release_status = release_status ,
206+ )
186207 if email :
187208 contact .emails .append (email )
188209
189210 if row .SecondCtctPhone :
190- phone = _make_phone ('second' , row .OwnerKey , phone_number = row .SecondCtctPhone ,
191- phone_type = "Primary" ,
192- release_status = release_status )
211+ phone = _make_phone (
212+ "second" ,
213+ row .OwnerKey ,
214+ phone_number = row .SecondCtctPhone ,
215+ phone_type = "Primary" ,
216+ release_status = release_status ,
217+ )
193218 if phone :
194219 contact .phones .append (phone )
195220
@@ -205,6 +230,7 @@ def _make_name(first, last):
205230 else :
206231 return f"{ first } { last } "
207232
233+
208234def _make_email (first_second , ownerkey , ** kw ):
209235 try :
210236 email = CreateEmail (** kw )
@@ -214,6 +240,7 @@ def _make_email(first_second, ownerkey, **kw):
214240 f"{ first_second } '{ ownerkey } ' Skipping email. Validation error: { e } "
215241 )
216242
243+
217244def _make_phone (first_second , ownerkey , ** kw ):
218245 try :
219246 phone = CreatePhone (** kw )
@@ -223,6 +250,7 @@ def _make_phone(first_second, ownerkey, **kw):
223250 f"{ first_second } '{ ownerkey } ' Skipping phone . Validation error: { e } "
224251 )
225252
253+
226254def _make_address (first_second , ownerkey , kind , ** kw ):
227255 try :
228256 address = CreateAddress (** kw )
@@ -231,6 +259,8 @@ def _make_address(first_second, ownerkey, kind, **kw):
231259 logger .warning (
232260 f"{ first_second } '{ ownerkey } ' Skipping { kind } address. Validation error: { e } "
233261 )
262+
263+
234264#
235265def _make_contact_and_assoc (session , data , thing ):
236266 contact = CreateContact (** data )
0 commit comments