def log_dir():
    """
    Return the application log directory.
    """
    init()
    if sys.platform == "darwin":
        name = str(QCoreApplication.applicationName())
        logdir = os.path.join(os.path.expanduser("~/Library/Logs"), name)
    else:
        logdir = data_dir()

    if not os.path.exists(logdir):
        os.makedirs(logdir)
    return logdir
Exemple #2
0
def log_dir():
    """
    Return the application log directory.
    """
    init()
    if sys.platform == "darwin":
        name = str(QCoreApplication.applicationName())
        logdir = os.path.join(os.path.expanduser("~/Library/Logs"), name)
    else:
        logdir = data_dir()

    if not os.path.exists(logdir):
        os.makedirs(logdir)
    return logdir
def log_dir():
    """
    Return the application log directory.
    """
    warnings.warn(f"'{__name__}.log_dir' is deprecated.",
                  DeprecationWarning,
                  stacklevel=2)
    if sys.platform == "darwin":
        name = QCoreApplication.applicationName() or "Orange"
        logdir = os.path.join(os.path.expanduser("~/Library/Logs"), name)
    else:
        logdir = data_dir()

    try:
        os.makedirs(logdir, exist_ok=True)
    except OSError:
        pass
    return logdir
def cache_dir():
    """Return the application cache directory. If the directory path
    does not yet exists then create it.
    """
    warnings.warn(f"'{__name__}.cache_dir' is deprecated.",
                  DeprecationWarning,
                  stacklevel=2)
    base = QStandardPaths.writableLocation(QStandardPaths.GenericCacheLocation)
    name = QCoreApplication.applicationName()
    version = QCoreApplication.applicationVersion()
    if not name:
        name = "Orange"
    if not version:
        version = "0.0.0"
    path = os.path.join(base, name, version)
    try:
        os.makedirs(path, exist_ok=True)
    except OSError:
        pass
    return path
def data_dir(versioned=True):
    """
    Return the platform dependent application data directory.

    This is ``data_dir_base()``/{NAME}/{VERSION}/ directory if versioned is
    `True` and ``data_dir_base()``/{NAME}/ otherwise, where NAME is
    `QCoreApplication.applicationName()` and VERSION is
    `QCoreApplication.applicationVersion()`.
    """
    base = data_dir_base()
    assert base
    name = QCoreApplication.applicationName()
    version = QCoreApplication.applicationVersion()
    if not name:
        name = "Orange"
    if not version:
        version = "0.0.0"
    if versioned:
        return os.path.join(base, name, version)
    else:
        return os.path.join(base, name)