-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFSG_Sync.py
More file actions
38 lines (28 loc) · 1.15 KB
/
Copy pathFSG_Sync.py
File metadata and controls
38 lines (28 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -*- coding: utf-8 -*-
from __future__ import annotations
# ---- Vendored gedcomx_v1 (runs when FSG_Sync.py is loaded) ----
from pathlib import Path
import sys
import importlib
import os
PLUGIN_DIR = Path(__file__).resolve().parent
VENDOR_DIR = PLUGIN_DIR / "fs_vendor"
# Always prefer our vendored gedcomx_v1 over any pre-imported copy
if "gedcomx_v1" in sys.modules:
del sys.modules["gedcomx_v1"]
# Ensure our vendor dir is first on sys.path, then import & pin
if (VENDOR_DIR / "gedcomx_v1").exists():
if str(VENDOR_DIR) not in sys.path:
sys.path.insert(0, str(VENDOR_DIR))
gx = importlib.import_module("gedcomx_v1")
sys.modules["gedcomx_v1"] = gx # pin vendored copy
# Log where it came from (force flush so it shows in gdb output)
print(f"[FS Sync] gedcomx_v1 resolved to: {Path(gx.__file__).resolve()}", flush=True)
# -------------------------------------------------------------------------
# Keep the plugin dir importable when Gramps loads plugins flat
_PLUGIN_DIR = os.path.dirname(__file__)
if _PLUGIN_DIR not in sys.path:
sys.path.insert(0, _PLUGIN_DIR)
# Load the refactored class
from fs_person import FSG_Sync
__all__ = ["FSG_Sync"]