2023-06-28 14:30:22 +02:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from os.path import join, expanduser
|
2017-04-12 16:42:04 +02:00
|
|
|
from collections import namedtuple
|
|
|
|
|
2023-06-28 12:41:47 +02:00
|
|
|
__version__ = '0.37.0'
|
2018-01-15 12:19:37 +01:00
|
|
|
|
2017-04-18 16:16:24 +02:00
|
|
|
App = namedtuple('App', ['instance', 'base_url', 'client_id', 'client_secret'])
|
|
|
|
User = namedtuple('User', ['instance', 'username', 'access_token'])
|
2017-04-12 16:42:04 +02:00
|
|
|
|
2023-03-07 10:37:03 +01:00
|
|
|
DEFAULT_INSTANCE = 'https://mastodon.social'
|
2017-04-12 16:42:04 +02:00
|
|
|
|
2017-04-19 14:47:30 +02:00
|
|
|
CLIENT_NAME = 'toot - a Mastodon CLI client'
|
2017-04-16 14:14:33 +02:00
|
|
|
CLIENT_WEBSITE = 'https://github.com/ihabunek/toot'
|
2023-06-28 14:30:22 +02:00
|
|
|
|
|
|
|
TOOT_CONFIG_DIR_NAME = "toot"
|
|
|
|
|
|
|
|
|
|
|
|
def get_config_dir():
|
|
|
|
"""Returns the path to toot config directory"""
|
|
|
|
|
|
|
|
# On Windows, store the config in roaming appdata
|
|
|
|
if sys.platform == "win32" and "APPDATA" in os.environ:
|
|
|
|
return join(os.getenv("APPDATA"), TOOT_CONFIG_DIR_NAME)
|
|
|
|
|
|
|
|
# Respect XDG_CONFIG_HOME env variable if set
|
|
|
|
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
|
|
|
if "XDG_CONFIG_HOME" in os.environ:
|
|
|
|
config_home = expanduser(os.environ["XDG_CONFIG_HOME"])
|
|
|
|
return join(config_home, TOOT_CONFIG_DIR_NAME)
|
|
|
|
|
|
|
|
# Default to ~/.config/toot/
|
|
|
|
return join(expanduser("~"), ".config", TOOT_CONFIG_DIR_NAME)
|