You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.6 KiB
41 lines
1.6 KiB
# pybsv - Backup, Synchronization, Versioning.
|
|
# Copyright (C) 2025 Simon Boyé
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
import platform
|
|
|
|
|
|
def default_repository_path() -> Path:
|
|
"""Return the system-dependent default repository path."""
|
|
if platform.system() in ("Windows", "Darwin", "Java"):
|
|
msg = f"default_repository_path does not support {platform.system()} system"
|
|
raise NotImplementedError(msg)
|
|
else: # Assume Unix
|
|
# See https://specifications.freedesktop.org/basedir-spec/latest/
|
|
data_home = os.environ.get("XDG_DATA_HOME", "")
|
|
if data_home:
|
|
path = Path(data_home)
|
|
if not path.is_absolute() or not path.exists():
|
|
msg = (
|
|
f"invalid XDG_DATA_HOME ({path}): path is relative or does not "
|
|
"exists"
|
|
)
|
|
raise RuntimeError(msg)
|
|
else:
|
|
path = Path.home() / ".local/share"
|
|
return path / "bsv/repo"
|
|
|