add tracker module, moularize tracking system

This commit is contained in:
Justus Kuhlmann 2025-12-04 10:47:53 +01:00
commit 3963b07c5f
Signed by: jkuhl
GPG key ID: 00ED992DD79B85A6
6 changed files with 40 additions and 3 deletions

22
corrlib/tracker.py Normal file
View file

@ -0,0 +1,22 @@
import os
from configparser import ConfigParser
from .trackers import datalad as dl
def get_tracker(path):
config_path = os.path.join(path, '.corrlib')
config = ConfigParser()
if os.path.exists(config_path):
config.read(config_path)
tracker = config.get('core', 'tracker', fallback='datalad')
return tracker
def get_file(path, file):
tracker = get_tracker(path)
if tracker == 'datalad':
dl.get_file(path, file)
else:
raise ValueError(f"Tracker {tracker} is not supported.")
return