mirror of
https://codeberg.org/sch/BukuBot
synced 2024-11-17 19:48:40 +01:00
28 lines
857 B
Python
28 lines
857 B
Python
|
#!/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')
|
||
|
return os.path.join(data_home, 'bukubot')
|
||
|
elif sys.platform == 'win32':
|
||
|
data_home = os.environ.get('APPDATA')
|
||
|
if data_home is None:
|
||
|
return os.path.join(
|
||
|
os.path.dirname(__file__) + '/bukubot_data')
|
||
|
else:
|
||
|
return os.path.join(os.path.dirname(__file__) + '/bukubot_data')
|