@@ -94,7 +94,7 @@ def parse_ref(text: str) -> dict:
9494 match = pattern .search (text )
9595 if not match :
9696 return {}
97-
97+
9898 archive = match .group ("archive" ).strip ()
9999 to_remove = ["kyrkoarkiv" , "stadsarkiv" ]
100100 for word in to_remove :
@@ -127,7 +127,7 @@ def parse_ref(text: str) -> dict:
127127# Gramplet class
128128# ------------------------
129129class ArchiveAssist (Gramplet ):
130-
130+
131131 # I am bad at GUI. Double check...
132132 def init (self ):
133133 if getattr (self , "_initialized" , False ):
@@ -170,7 +170,7 @@ def build_gui(self):
170170 vbox .pack_start (self .status_label , False , False , 0 )
171171
172172 return vbox
173-
173+
174174 def get_or_create_repository (self , name , trans ):
175175 for handle in self .dbstate .db .get_repository_handles ():
176176 repo = self .dbstate .db .get_repository_from_handle (handle )
@@ -195,11 +195,11 @@ def on_create_clicked(self, widget):
195195 if not parsed :
196196 self .status_label .set_text ("Could not parse the reference string." )
197197 return
198-
198+
199199 # Find existing Source (by title)
200200 src = None
201201 src_handle = None
202-
202+
203203 for handle in self .dbstate .db .get_source_handles ():
204204 candidate = self .dbstate .db .get_source_from_handle (handle )
205205 for attr in candidate .get_attribute_list ():
@@ -213,7 +213,7 @@ def on_create_clicked(self, widget):
213213
214214 try :
215215 with DbTxn ("Create Source and Citation" , self .dbstate .db ) as trans :
216-
216+
217217 # Source
218218 if src :
219219 self .status_label .set_text (
@@ -223,14 +223,14 @@ def on_create_clicked(self, widget):
223223 src = Source ()
224224 src .set_title (parsed ["abr" ])
225225 src .set_publication_info (parsed ["years" ])
226-
226+
227227 # FIXED NAD attribute
228228 nad_attr = Attribute ()
229229 nad_attr .set_type ("NAD" )
230230 nad_attr .set_value (parsed ["NAD" ])
231231 src .add_attribute (nad_attr )
232-
233- # FIXED AID attribute (if present)
232+
233+ # FIXED AID attribute (if present)
234234 if parsed ["AID" ]:
235235 aid_attr = Attribute ()
236236 aid_attr .set_type ("AID" )
@@ -239,46 +239,46 @@ def on_create_clicked(self, widget):
239239
240240 # First add the Source WITHOUT repo refs
241241 src_handle = self .dbstate .db .add_source (src , trans )
242-
242+
243243 # Now add RepoRef AFTER the source exists
244244 repo_ref = RepoRef ()
245245 repo_handle = self .get_or_create_repository (parsed ["provider" ], trans )
246246 repo_ref .set_reference_handle (repo_handle )
247-
247+
248248 src .add_repo_reference (repo_ref )
249-
249+
250250 # Persist the updated Source with its RepoRef
251251 self .dbstate .db .commit_source (src , trans )
252-
252+
253253 # Citation
254254 if parsed ["page" ]:
255255 cit = Citation ()
256256 cit .set_confidence_level (2 )
257257 cit .set_page (parsed ["page" ])
258-
258+
259259 years = parsed ["years" ]
260260 cit_date = Date ()
261261 if years and "-" in years :
262262 start_year , end_year = [y .strip () for y in years .split ("-" )]
263263 cit_date .set (
264- modifier = Date .MOD_RANGE ,
264+ modifier = Date .MOD_RANGE ,
265265 value = (0 , 0 , int (start_year ), False , 0 , 0 , int (end_year ), False ))
266266 cit .set_date_object (cit_date )
267267
268268 elif years :
269269 cit_date .set_year (int (years .strip ()))
270270 cit .set_date_object (cit_date )
271-
272- cit .set_reference_handle (src_handle )
273-
271+
272+ cit .set_reference_handle (src_handle )
273+
274274 if parsed ["full_AID" ]:
275275 AID = Attribute ()
276276 AID .set_type ("AID" )
277277 AID .set_value (parsed ["full_AID" ])
278278 cit .add_attribute (AID )
279-
279+
280280 cit_handle = self .dbstate .db .add_citation (cit , trans )
281-
281+
282282 self .status_label .set_text (
283283 f"Created Source ({ src .get_gramps_id ()} ) and Citation ({ cit .get_gramps_id ()} )."
284284 )
@@ -287,7 +287,7 @@ def on_create_clicked(self, widget):
287287 f"Created Source ({ src .get_gramps_id ()} ). No Citation created due to missing page info."
288288 )
289289
290- except Exception as e :
290+ except Exception as e :
291291 LOG .error ("ArchiveAssist failed: %s" , str (e ), exc_info = True )
292292 self .status_label .set_text (
293- "Failed to create Source/Citation. Check logs." )
293+ "Failed to create Source/Citation. Check logs." )
0 commit comments