mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-28 15:48:16 +00:00
Merge pull request #87 from legrostdg/xdg
use xdg dirs for config & data
This commit is contained in:
commit
4e3909dbae
7 changed files with 31 additions and 6 deletions
|
|
@ -3,6 +3,9 @@
|
||||||
Features:
|
Features:
|
||||||
- checking: Support itms-services: URLs.
|
- checking: Support itms-services: URLs.
|
||||||
Closes: GH bug #532
|
Closes: GH bug #532
|
||||||
|
- checking: Support XDG Base Directory Specification for configuration
|
||||||
|
and data.
|
||||||
|
Closes: GH bug #44
|
||||||
|
|
||||||
Changes:
|
Changes:
|
||||||
- installation: Remove dependency on msgfmt.py by pre-generating the
|
- installation: Remove dependency on msgfmt.py by pre-generating the
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from xdg import xdg_config_home
|
||||||
|
|
||||||
# Windows filename encoding
|
# Windows filename encoding
|
||||||
nt_filename_encoding="mbcs"
|
nt_filename_encoding="mbcs"
|
||||||
|
|
@ -40,7 +41,7 @@ def get_profile_dir ():
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
dirpath = os.path.join(basedir, u"Library", u"Application Support")
|
dirpath = os.path.join(basedir, u"Library", u"Application Support")
|
||||||
else:
|
else:
|
||||||
dirpath = os.path.join(basedir, u".config")
|
dirpath = xdg_config_home
|
||||||
dirpath = os.path.join(dirpath, u"Google", u"Chrome")
|
dirpath = os.path.join(dirpath, u"Google", u"Chrome")
|
||||||
return dirpath
|
return dirpath
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
|
from xdg import xdg_config_home
|
||||||
|
|
||||||
|
|
||||||
# Windows filename encoding
|
# Windows filename encoding
|
||||||
|
|
@ -42,7 +43,7 @@ def get_profile_dir ():
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
dirpath = os.path.join(basedir, u"Library", u"Application Support")
|
dirpath = os.path.join(basedir, u"Library", u"Application Support")
|
||||||
else:
|
else:
|
||||||
dirpath = os.path.join(basedir, u".config")
|
dirpath = xdg_config_home
|
||||||
dirpath = os.path.join(dirpath, u"chromium")
|
dirpath = os.path.join(dirpath, u"chromium")
|
||||||
return dirpath
|
return dirpath
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import _LinkChecker_configdata as configdata
|
||||||
from .. import (log, LOG_CHECK, get_install_data, fileutil)
|
from .. import (log, LOG_CHECK, get_install_data, fileutil)
|
||||||
from . import confparse
|
from . import confparse
|
||||||
from ..decorators import memoized
|
from ..decorators import memoized
|
||||||
|
from xdg.BaseDirectory import xdg_config_home, xdg_data_home
|
||||||
|
|
||||||
Version = configdata.version
|
Version = configdata.version
|
||||||
ReleaseDate = configdata.release_date
|
ReleaseDate = configdata.release_date
|
||||||
|
|
@ -364,10 +365,24 @@ class Configuration (dict):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def get_user_data():
|
||||||
|
"""Get the user data folder.
|
||||||
|
Returns "~/.linkchecker/" if this folder exists, \
|
||||||
|
"$XDG_DATA_HOME/linkchecker" if it does not.
|
||||||
|
@rtype string
|
||||||
|
"""
|
||||||
|
homedotdir = normpath("~/.linkchecker/")
|
||||||
|
userdata = homedotdir if os.path.isdir(homedotdir) \
|
||||||
|
else os.path.join(xdg_data_home, "linkchecker")
|
||||||
|
return userdata
|
||||||
|
|
||||||
def get_plugin_folders():
|
def get_plugin_folders():
|
||||||
"""Get linkchecker plugin folders. Default is ~/.linkchecker/plugins/."""
|
"""Get linkchecker plugin folders. Default is
|
||||||
|
"$XDG_DATA_HOME/linkchecker/plugins/". "~/.linkchecker/plugins/" is also
|
||||||
|
supported for backwards compatibility, and is used if both directories
|
||||||
|
exist."""
|
||||||
folders = []
|
folders = []
|
||||||
defaultfolder = normpath("~/.linkchecker/plugins")
|
defaultfolder = os.path.join(get_user_data(), "plugins")
|
||||||
if not os.path.exists(defaultfolder) and not Portable:
|
if not os.path.exists(defaultfolder) and not Portable:
|
||||||
try:
|
try:
|
||||||
make_userdir(defaultfolder)
|
make_userdir(defaultfolder)
|
||||||
|
|
@ -403,7 +418,9 @@ def get_user_config():
|
||||||
# initial config (with all options explained)
|
# initial config (with all options explained)
|
||||||
initialconf = normpath(os.path.join(get_share_dir(), "linkcheckerrc"))
|
initialconf = normpath(os.path.join(get_share_dir(), "linkcheckerrc"))
|
||||||
# per user config settings
|
# per user config settings
|
||||||
userconf = normpath("~/.linkchecker/linkcheckerrc")
|
homedotfile = normpath("~/.linkchecker/linkcheckerrc")
|
||||||
|
userconf = homedotfile if os.path.isfile(homedotfile) \
|
||||||
|
else os.path.join(xdg_config_home, "linkchecker", "linkcheckerrc")
|
||||||
if os.path.isfile(initialconf) and not os.path.exists(userconf) and \
|
if os.path.isfile(initialconf) and not os.path.exists(userconf) and \
|
||||||
not Portable:
|
not Portable:
|
||||||
# copy the initial configuration to the user configuration
|
# copy the initial configuration to the user configuration
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ A blacklist logger.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import codecs
|
import codecs
|
||||||
|
from linkcheck.configuration import get_user_data
|
||||||
from . import _Logger
|
from . import _Logger
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -33,7 +34,7 @@ class BlacklistLogger (_Logger):
|
||||||
LoggerName = "blacklist"
|
LoggerName = "blacklist"
|
||||||
|
|
||||||
LoggerArgs = {
|
LoggerArgs = {
|
||||||
"filename": "~/.linkchecker/blacklist",
|
"filename": os.path.join(get_user_data(), "blacklist"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__ (self, **kwargs):
|
def __init__ (self, **kwargs):
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
# required:
|
# required:
|
||||||
requests<2.15,>=2.2
|
requests<2.15,>=2.2
|
||||||
|
pyxdg
|
||||||
# optional:
|
# optional:
|
||||||
argcomplete
|
argcomplete
|
||||||
|
|
|
||||||
1
setup.py
1
setup.py
|
|
@ -481,6 +481,7 @@ args = dict(
|
||||||
# Requirements, usable with setuptools or the new Python packaging module.
|
# Requirements, usable with setuptools or the new Python packaging module.
|
||||||
install_requires = [
|
install_requires = [
|
||||||
'requests<2.15,>=2.2',
|
'requests<2.15,>=2.2',
|
||||||
|
'pyxdg',
|
||||||
],
|
],
|
||||||
# Commented out since they are untested and not officially supported.
|
# Commented out since they are untested and not officially supported.
|
||||||
# See also doc/install.txt for more detailed dependency documentation.
|
# See also doc/install.txt for more detailed dependency documentation.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue