2024-04-05 17:00:19 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import buku
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
class Configuration:
|
|
|
|
|
|
|
|
def init_db(jid_bare):
|
|
|
|
filename = jid_bare + '.db'
|
|
|
|
data_dir = Configuration.get_db_directory()
|
|
|
|
pathname = data_dir + '/' + filename
|
|
|
|
bookmarks_db = buku.BukuDb(dbfile=pathname)
|
|
|
|
return bookmarks_db
|
|
|
|
|
|
|
|
def get_db_directory():
|
|
|
|
if os.environ.get('HOME'):
|
|
|
|
data_home = os.path.join(os.environ.get('HOME'), '.local', 'share')
|
2024-05-31 10:42:37 +02:00
|
|
|
return os.path.join(data_home, 'bukubot')
|
2024-04-05 17:00:19 +02:00
|
|
|
elif sys.platform == 'win32':
|
|
|
|
data_home = os.environ.get('APPDATA')
|
|
|
|
if data_home is None:
|
|
|
|
return os.path.join(
|
2024-05-31 10:42:37 +02:00
|
|
|
os.path.dirname(__file__) + '/bukubot_data')
|
2024-04-05 17:00:19 +02:00
|
|
|
else:
|
2024-05-31 10:42:37 +02:00
|
|
|
return os.path.join(os.path.dirname(__file__) + '/bukubot_data')
|