Better Windows support: Finding the user profile directory even on Win32 (#144)

* Better Windows support: Finding the user profile directory even on Win32

* Better Windows support: Finding the user profile directory even on Win32
This commit is contained in:
Cthulhux 2017-04-02 22:28:26 +02:00 committed by Arun Prakash Jana
parent a1c1092987
commit 3297499fe4
3 changed files with 17 additions and 9 deletions

View File

@ -236,7 +236,8 @@ SYMBOLS:
- The database file is stored in:
- **$XDG_DATA_HOME/buku/bookmarks.db**, if XDG_DATA_HOME is defined (first preference) or
- **$HOME/.local/share/buku/bookmarks.db**, if HOME is defined (second preference) or
- **$PWD**
- **%USERPROFILE%\buku\bookmarks.db**, if you are on Windows or
- **$PWD** on both Windows and non-Windows systems.
- If the URL contains characters like `;`, `&` or brackets they may be interpreted specially by the shell. To avoid it, add the URL within single or double quotes (`'`/`"`).
- URLs are unique in DB. The same URL cannot be added twice.
- Bookmarks with immutable titles are listed with bold `(L)` after the URL.

3
buku.1
View File

@ -27,7 +27,8 @@ is a command-line utility to store, tag, search and organize bookmarks.
The database file is stored in:
- \fI$XDG_DATA_HOME/buku/bookmarks.db\fR, if XDG_DATA_HOME is defined (first preference) or
- \fI$HOME/.local/share/buku/bookmarks.db\fR, if HOME is defined (second preference) or
- \fI$PWD\fR
- \fI%USERPROFILE%\buku\bookmarks.db\fR, if you are on Windows or
- \fI$PWD\fR on both Windows and non-Windows systems.
.PP
.IP 2. 4
If the URL contains characters like ';', '&' or brackets they may be interpreted specially by the shell. To avoid it, add the URL within single or double quotes ('/").

View File

@ -352,13 +352,19 @@ class BukuDb:
@staticmethod
def get_default_dbdir():
'''Determine the directory path where dbfile will be stored:
if $XDG_DATA_HOME is defined, use it
if the platform is Windows, use %USERPROFILE%
else if $XDG_DATA_HOME is defined, use it
else if $HOME exists, use it
else use the current directory
:return: path to database file
'''
if sys.platform == 'win32':
data_home = os.environ.get('USERPROFILE')
if data_home is None:
return os.path.abspath('.')
else:
data_home = os.environ.get('XDG_DATA_HOME')
if data_home is None:
if os.environ.get('HOME') is None: