# 1. Check external license file
# We store license acceptance in a separate JSON file so it survives cache clearing
license_file = os.path.join(
- os.path.dirname(self.db_path), "..", "license-agreement.json"
+ os.path.dirname(self.db_path), "license-agreement.json"
)
- license_file = os.path.abspath(license_file)
if os.path.exists(license_file):
try:
"auth": auth_header,
}
# Save to separate JSON file
- cookie_file = os.path.join(
- os.path.dirname(self.db_path), "..", "cookies.json"
- )
- cookie_file = os.path.abspath(cookie_file)
+ cookie_file = os.path.join(os.path.dirname(self.db_path), "cookies.json")
with open(cookie_file, "w", encoding="utf-8") as f:
json.dump(data, f)
def load_cookies(self):
"""load cookies and authorization header from JSON"""
- cookie_file = os.path.join(os.path.dirname(self.db_path), "..", "cookies.json")
- cookie_file = os.path.abspath(cookie_file)
+ cookie_file = os.path.join(os.path.dirname(self.db_path), "cookies.json")
if os.path.exists(cookie_file):
try:
"""add parents relationships
:param fids: a set of fids
"""
+ # Materialize once to avoid exhausting iterator
+ fids_list = [f for f in fids if f in self.indi]
parents = set()
- for fid in [f for f in fids if f in self.indi]:
+ for fid in fids_list:
for couple in self.indi[fid].parents:
parents |= set(couple)
if parents:
parents -= set(self.exclude)
self.add_indis(set(filter(None, parents)))
- for fid in [f for f in fids if f in self.indi]:
+ for fid in fids_list:
for father, mother in self.indi[fid].parents:
self.add_trio(
self.indi.get(father) if father else None,
resname.text = self.display_name
people = ET.SubElement(root, "people")
- for indi in sorted(self.indi.values(), key=lambda x: x.id):
+ for indi in sorted(self.indi.values(), key=lambda x: str(x.id or "")):
indi.printxml(people)
families = ET.SubElement(root, "families")
- for fam in sorted(self.fam.values(), key=lambda x: x.id):
+ for fam in sorted(self.fam.values(), key=lambda x: str(x.id or "")):
fam.printxml(families)
events = ET.SubElement(root, "events")
# Deduplicate names by string representation
def merge_names(target_set, source_set):
- target_set.update(source_set)
+ existing_names = {str(n) for n in target_set}
+ for n in source_set:
+ if str(n) not in existing_names:
+ target_set.add(n)
+ existing_names.add(str(n))
# Helper for whitespace normalization in quotes
def norm_space(s):