Skip to content

Commit

Permalink
Use config dir on Linux and roaming on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Serial-ATA committed Aug 28, 2022
1 parent 3a2e5d9 commit ce49a28
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions vidl/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@
from colorboy import green
from vidl import log, package_name, package_author

user_data_dir = appdirs.user_data_dir(package_name, package_author)
config_path = os.path.join(user_data_dir, 'config.json')
user_md_parser_path = os.path.join(user_data_dir, 'user_md_parser.py')
if sys.platform == 'darwin':
# TODO:
# https://github.com/ActiveState/appdirs/issues/185
# or
# https://github.com/platformdirs/platformdirs/issues/98
user_config_dir = "~/Library/Application Support/" + package_name
else:
user_config_dir = appdirs.user_config_dir(package_name, package_author, roaming=True)

config_path = os.path.join(user_config_dir, 'config.json')
user_md_parser_path = os.path.join(user_config_dir, 'user_md_parser.py')
default_user_md_parser_path = os.path.join(os.path.dirname(__file__), 'default_user_md_parser.py')

def save_file(path, content, json=False):
try:
file = open(path, 'w+')
except FileNotFoundError:
os.makedirs(user_data_dir)
os.makedirs(user_config_dir)
file = open(path, 'w+')
file.write(content)
file.close()
Expand Down

0 comments on commit ce49a28

Please sign in to comment.