diff --git a/linkcheck/__init__.py b/linkcheck/__init__.py index 6869b3d0..40f292b6 100644 --- a/linkcheck/__init__.py +++ b/linkcheck/__init__.py @@ -43,11 +43,6 @@ from . import i18n import _LinkChecker_configdata as configdata -def main_is_frozen (): - """Return True iff running inside a py2exe-generated executable.""" - return hasattr(sys, "frozen") - - def module_path (): """Return absolute directory of system executable.""" return os.path.dirname(os.path.abspath(sys.executable)) @@ -55,16 +50,12 @@ def module_path (): def get_install_data (): """Return absolute path of LinkChecker data installation directory.""" - if main_is_frozen(): + from .loader import is_frozen + if is_frozen(): return module_path() return configdata.install_data -def get_config_dir (): - """Return absolute path of LinkChecker example configuration.""" - return os.path.join(get_install_data(), "share", "linkchecker") - - # application log areas LOG_ROOT = "linkcheck" LOG_CMDLINE = "linkcheck.cmdline" diff --git a/linkcheck/configuration/__init__.py b/linkcheck/configuration/__init__.py index c7305140..1b4c783b 100644 --- a/linkcheck/configuration/__init__.py +++ b/linkcheck/configuration/__init__.py @@ -28,7 +28,7 @@ import shutil import socket import _LinkChecker_configdata as configdata from .. import (log, LOG_CHECK, LOG_ROOT, ansicolor, lognames, - get_config_dir, fileutil, configdict) + get_install_data, fileutil, configdict) from . import confparse from ..decorators import memoized @@ -92,6 +92,11 @@ def get_modules_info (): return lines +def get_share_dir (): + """Return absolute path of LinkChecker example configuration.""" + return os.path.join(get_install_data(), "share", "linkchecker") + + def get_share_file (filename, devel_dir=None): """Return a filename in the share directory. @param devel_dir: directory to search when developing @@ -102,13 +107,7 @@ def get_share_file (filename, devel_dir=None): @rtype: string @raises: ValueError if not found """ - paths = [ - # when running under py2exe - os.path.join(os.path.dirname(os.path.abspath(sys.executable)), - "share", "linkchecker"), - # after installing as a package - configdata.config_dir, - ] + paths = [get_share_dir()] if devel_dir is not None: # when developing paths.insert(0, devel_dir) @@ -413,7 +412,7 @@ def get_user_config(): @rtype string """ # initial config (with all options explained) - initialconf = normpath(os.path.join(get_config_dir(), "linkcheckerrc")) + initialconf = normpath(os.path.join(get_share_dir(), "linkcheckerrc")) # per user config settings userconf = normpath("~/.linkchecker/linkcheckerrc") if os.path.isfile(initialconf) and not os.path.exists(userconf) and \