remove temporary non-datalad implementation

This commit is contained in:
Justus Kuhlmann 2025-12-04 15:14:28 +01:00
commit bc57087a5a
Signed by: jkuhl
GPG key ID: 00ED992DD79B85A6
3 changed files with 53 additions and 40 deletions

View file

@ -1,7 +1,9 @@
import os
from configparser import ConfigParser
from .trackers import datalad as dl
import datalad.api as dl
from typing import Optional
import shutil
from .tools import get_db_file
def get_tracker(path: str) -> str:
@ -18,7 +20,12 @@ def get_tracker(path: str) -> str:
def get(path: str, file: str) -> None:
tracker = get_tracker(path)
if tracker == 'datalad':
dl.get(path, file)
if file == get_db_file(path):
print("Downloading database...")
else:
print("Downloading data...")
dl.get(os.path.join(path, file), dataset=path)
print("> downloaded file")
elif tracker == 'None':
pass
else:
@ -29,7 +36,9 @@ def get(path: str, file: str) -> None:
def save(path: str, message: str, files: Optional[list[str]]=None) -> None:
tracker = get_tracker(path)
if tracker == 'datalad':
dl.save(path, message, files)
if files is not None:
files = [os.path.join(path, f) for f in files]
dl.save(files, message=message, dataset=path)
elif tracker == 'None':
pass
else:
@ -44,3 +53,38 @@ def init(path: str, tracker: str='datalad') -> None:
else:
raise ValueError(f"Tracker {tracker} is not supported.")
return
def unlock(path: str, file: str) -> None:
tracker = get_tracker(path)
if tracker == 'datalad':
dl.unlock(file, dataset=path)
elif tracker == 'None':
pass
else:
raise ValueError(f"Tracker {tracker} is not supported.")
return
def clone(path: str, source: str, target: str) -> None:
tracker = get_tracker(path)
if tracker == 'datalad':
dl.clone(target=target, source=source, dataset=path)
elif tracker == 'None':
os.makedirs(path, exist_ok=True)
# Implement a simple clone by copying files
shutil.copytree(source, target, dirs_exist_ok=False)
else:
raise ValueError(f"Tracker {tracker} is not supported.")
return
def drop(path: str, reckless: Optional[str]=None) -> None:
tracker = get_tracker(path)
if tracker == 'datalad':
dl.drop(path, reckless=reckless)
elif tracker == 'None':
shutil.rmtree(path)
else:
raise ValueError(f"Tracker {tracker} is not supported.")
return