@@ -119,7 +119,7 @@ def parse_ref(text: str) -> dict:
119119# Gramplet class
120120# ------------------------
121121class ArchiveAssist (Gramplet ):
122-
122+
123123 # I am bad at GUI. Double check...
124124 def init (self ):
125125 if getattr (self , "_initialized" , False ):
@@ -162,7 +162,7 @@ def build_gui(self):
162162 vbox .pack_start (self .status_label , False , False , 0 )
163163
164164 return vbox
165-
165+
166166 def get_or_create_repository (self , name , trans ):
167167 for handle in self .dbstate .db .get_repository_handles ():
168168 repo = self .dbstate .db .get_repository_from_handle (handle )
@@ -187,11 +187,11 @@ def on_create_clicked(self, widget):
187187 if not parsed :
188188 self .status_label .set_text ("Could not parse the reference string." )
189189 return
190-
190+
191191 # Find existing Source (by title)
192192 src = None
193193 src_handle = None
194-
194+
195195 for handle in self .dbstate .db .get_source_handles ():
196196 candidate = self .dbstate .db .get_source_from_handle (handle )
197197 for attr in candidate .get_attribute_list ():
@@ -205,7 +205,7 @@ def on_create_clicked(self, widget):
205205
206206 try :
207207 with DbTxn ("Create Source and Citation" , self .dbstate .db ) as trans :
208-
208+
209209 # Source
210210 if src :
211211 self .status_label .set_text (
@@ -215,14 +215,14 @@ def on_create_clicked(self, widget):
215215 src = Source ()
216216 src .set_title (parsed ["abr" ])
217217 src .set_publication_info (parsed ["years" ])
218-
218+
219219 # FIXED NAD attribute
220220 nad_attr = Attribute ()
221221 nad_attr .set_type ("NAD" )
222222 nad_attr .set_value (parsed ["NAD" ])
223223 src .add_attribute (nad_attr )
224-
225- # FIXED AID attribute (if present)
224+
225+ # FIXED AID attribute (if present)
226226 if parsed ["AID" ]:
227227 aid_attr = Attribute ()
228228 aid_attr .set_type ("AID" )
@@ -231,50 +231,50 @@ def on_create_clicked(self, widget):
231231
232232 # First add the Source WITHOUT repo refs
233233 src_handle = self .dbstate .db .add_source (src , trans )
234-
234+
235235 # Now add RepoRef AFTER the source exists
236236 repo_ref = RepoRef ()
237237 repo_handle = self .get_or_create_repository (parsed ["provider" ], trans )
238238 repo_ref .set_reference_handle (repo_handle )
239-
239+
240240 src .add_repo_reference (repo_ref )
241-
241+
242242 # Persist the updated Source with its RepoRef
243243 self .dbstate .db .commit_source (src , trans )
244-
244+
245245 # Citation
246246 cit = Citation ()
247247 cit .set_confidence_level (2 )
248248 cit .set_page (parsed ["page" ])
249-
249+
250250 years = parsed ["years" ]
251251 cit_date = Date ()
252252 if years and "-" in years :
253253 start_year , end_year = [y .strip () for y in years .split ("-" )]
254254 cit_date .set (
255- modifier = Date .MOD_RANGE ,
255+ modifier = Date .MOD_RANGE ,
256256 value = (0 , 0 , int (start_year ), False , 0 , 0 , int (end_year ), False ))
257257 cit .set_date_object (cit_date )
258258
259259 elif years :
260260 cit_date .set_year (int (years .strip ()))
261261 cit .set_date_object (cit_date )
262-
263- cit .set_reference_handle (src_handle )
264-
262+
263+ cit .set_reference_handle (src_handle )
264+
265265 if parsed ["full_AID" ]:
266266 AID = Attribute ()
267267 AID .set_type ("AID" )
268268 AID .set_value (parsed ["full_AID" ])
269269 cit .add_attribute (AID )
270-
270+
271271 cit_handle = self .dbstate .db .add_citation (cit , trans )
272-
272+
273273 self .status_label .set_text (
274274 f"Created Source ({ src .get_gramps_id ()} ) and Citation ({ cit .get_gramps_id ()} )."
275275 )
276276
277- except Exception as e :
277+ except Exception as e :
278278 LOG .error ("ArchiveAssist failed: %s" , str (e ), exc_info = True )
279279 self .status_label .set_text (
280- "Failed to create Source/Citation. Check logs." )
280+ "Failed to create Source/Citation. Check logs." )
0 commit comments