Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ActiveState/appdirs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.4.4
Choose a base ref
...
head repository: ActiveState/appdirs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 95 additions and 103 deletions.
  1. +9 −6 .travis.yml
  2. +12 −8 CHANGES.rst
  3. +2 −2 Dockerfile
  4. +1 −2 LICENSE.txt
  5. +7 −5 README.rst
  6. +0 −1 TODO.md
  7. +35 −40 appdirs.py
  8. +2 −2 setup.cfg
  9. +24 −30 setup.py
  10. +1 −5 test/test_api.py
  11. +2 −2 tox.ini
15 changes: 9 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
dist: xenial
language: python
python:
- "2.6"
- "2.7"
- "pypy"
- "3.2"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
script: python setup.py test
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "pypy3"

script: python -m unittest discover
20 changes: 12 additions & 8 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
appdirs Changelog
=================

UNRELEASED
----------
- Add Python 3.7 support
- Remove support for end-of-life Pythons 2.6, 3.2, and 3.3

appdirs 1.4.4
-------------
- [PR #92] Don't import appdirs from setup.py which
fixes #91 - Don't get version from appdirs.__version__
- [PR #92] Don't import appdirs from setup.py which resolves issue #91
- [PR #100] Corrects the config directory on OSX/macOS, which resolves issue #63.

Project officially classified as Stable which is important
for inclusion in other distros such as ActivePython.
@@ -56,7 +61,7 @@ appdirs 1.1.0

- [issue 4] Add ``AppDirs.user_log_dir``.
- [Unix, issue 2, issue 7] appdirs now conforms to `XDG base directory spec
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
<https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
- [Mac, issue 5] Fix ``site_data_dir()`` on Mac.
- [Mac] Drop use of 'Carbon' module in favour of hardcoded paths; supports
Python3 now.
@@ -83,10 +88,9 @@ appdirs 1.0.1 (never released)
------------------------------

Started this changelog 27 July 2010. Before that this module originated in the
`Komodo <http://www.activestate.com/komodo>`_ product as ``applib.py`` and then
`Komodo <https://www.activestate.com/komodo-ide>`_ product as ``applib.py`` and then
as `applib/location.py
<http://github.com/ActiveState/applib/blob/master/applib/location.py>`_ (used by
`PyPM <http://code.activestate.com/pypm/>`_ in `ActivePython
<http://www.activestate.com/activepython>`_). This is basically a fork of
<https://github.com/ActiveState/applib/blob/master/applib/location.py>`_ (used by
`PyPM <https://code.activestate.com/pypm/>`_ in `ActivePython
<https://www.activestate.com/activepython>`_). This is basically a fork of
applib.py 1.0.1 and applib/location.py 1.0.1.

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@ RUN apt-get -y update && apt-get -y install python3-setuptools && \

WORKDIR /app
ADD . /app
RUN python setup.py install && python setup.py test
RUN python3 setup.py install && python3 setup.py test
RUN python setup.py install && python -m unittest discover
RUN python3 setup.py install && python3 -m unittest

RUN python -m appdirs
RUN python3 -m appdirs
3 changes: 1 addition & 2 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This is the MIT license
The MIT License (MIT)

Copyright (c) 2010 ActiveState Software Inc.

@@ -20,4 +20,3 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

12 changes: 7 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
.. image:: https://secure.travis-ci.org/ActiveState/appdirs.png
:target: http://travis-ci.org/ActiveState/appdirs
:target: https://travis-ci.org/ActiveState/appdirs

Note: This project has been officially deprecated. You may want to check out https://pypi.org/project/platformdirs/ which is a more active fork of appdirs. Thanks to everyone who has used appdirs. Shout out to ActiveState for the time they gave their employees to work on this over the years.

the problem
===========

What directory should your app use for storing user data? If running on Mac OS X, you
What directory should your app use for storing user data? If running on macOS, you
should use::

~/Library/Application Support/<AppName>
@@ -17,10 +19,10 @@ or possibly::

C:\Documents and Settings\<User>\Application Data\<AppAuthor>\<AppName>

for `roaming profiles <http://bit.ly/9yl3b6>`_ but that is another story.
for `roaming profiles <https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-vista/cc766489(v=ws.10)>`_ but that is another story.

On Linux (and other Unices) the dir, according to the `XDG
spec <http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_, is::
spec <https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_, is::

~/.local/share/<AppName>

@@ -48,7 +50,7 @@ and also:
some example output
===================

On Mac OS X::
On macOS::

>>> from appdirs import *
>>> appname = "SuperApp"
1 change: 0 additions & 1 deletion TODO.md

This file was deleted.

75 changes: 35 additions & 40 deletions appdirs.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2005-2010 ActiveState Software Inc.
# Copyright (c) 2013 Eddy Petrișor

"""Utilities for determining application-specific dirs.
See <http://github.com/ActiveState/appdirs> for details and usage.
See <https://github.com/ActiveState/appdirs> for details and usage.
"""
# Dev Notes:
# - MSDN on where to store app data files:
# http://support.microsoft.com/default.aspx?scid=kb;en-us;310294#XSLTH3194121123120121120120
# - Mac OS X: http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/index.html
# - XDG spec for Un*x: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
# - XDG spec for Un*x: https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

__version__ = "1.4.4"
__version_info__ = tuple(int(segment) for segment in __version__.split("."))
@@ -77,7 +76,7 @@ def user_data_dir(appname=None, appauthor=None, version=None, roaming=False):
if system == "win32":
if appauthor is None:
appauthor = appname
const = roaming and "CSIDL_APPDATA" or "CSIDL_LOCAL_APPDATA"
const = "CSIDL_APPDATA" if roaming else "CSIDL_LOCAL_APPDATA"
path = os.path.normpath(_get_win_folder(const))
if appname:
if appauthor is not False:
@@ -185,15 +184,19 @@ def user_config_dir(appname=None, appauthor=None, version=None, roaming=False):
for a discussion of issues.
Typical user config directories are:
Mac OS X: same as user_data_dir
Mac OS X: ~/Library/Preferences/<AppName>
Unix: ~/.config/<AppName> # or in $XDG_CONFIG_HOME, if defined
Win *: same as user_data_dir
For Unix, we follow the XDG spec and support $XDG_CONFIG_HOME.
That means, by default "~/.config/<AppName>".
"""
if system in ["win32", "darwin"]:
if system == "win32":
path = user_data_dir(appname, appauthor, None, roaming)
elif system == 'darwin':
path = os.path.expanduser('~/Library/Preferences/')
if appname:
path = os.path.join(path, appname)
else:
path = os.getenv('XDG_CONFIG_HOME', os.path.expanduser("~/.config"))
if appname:
@@ -233,10 +236,14 @@ def site_config_dir(appname=None, appauthor=None, version=None, multipath=False)
WARNING: Do not use this on Windows. See the Vista-Fail note above for why.
"""
if system in ["win32", "darwin"]:
if system == 'win32':
path = site_data_dir(appname, appauthor)
if appname and version:
path = os.path.join(path, version)
elif system == 'darwin':
path = os.path.expanduser('/Library/Preferences')
if appname:
path = os.path.join(path, appname)
else:
# XDG default for $XDG_CONFIG_DIRS
# only first, if multipath is False
@@ -476,33 +483,6 @@ def _get_win_folder_from_registry(csidl_name):
return dir


def _get_win_folder_with_pywin32(csidl_name):
from win32com.shell import shellcon, shell
dir = shell.SHGetFolderPath(0, getattr(shellcon, csidl_name), 0, 0)
# Try to make this a unicode path because SHGetFolderPath does
# not return unicode strings when there is unicode data in the
# path.
try:
dir = unicode(dir)

# Downgrade to short path name if have highbit chars. See
# <http://bugs.activestate.com/show_bug.cgi?id=85099>.
has_high_char = False
for c in dir:
if ord(c) > 255:
has_high_char = True
break
if has_high_char:
try:
import win32api
dir = win32api.GetShortPathName(dir)
except ImportError:
pass
except UnicodeError:
pass
return dir


def _get_win_folder_with_ctypes(csidl_name):
import ctypes

@@ -555,20 +535,35 @@ def _get_win_folder_with_jna(csidl_name):

return dir

def _get_win_folder_from_environ(csidl_name):
env_var_name = {
"CSIDL_APPDATA": "APPDATA",
"CSIDL_COMMON_APPDATA": "ALLUSERSPROFILE",
"CSIDL_LOCAL_APPDATA": "LOCALAPPDATA",
}[csidl_name]

return os.environ[env_var_name]

if system == "win32":
try:
import win32com.shell
_get_win_folder = _get_win_folder_with_pywin32
from ctypes import windll
except ImportError:
try:
from ctypes import windll
_get_win_folder = _get_win_folder_with_ctypes
import com.sun.jna
except ImportError:
try:
import com.sun.jna
_get_win_folder = _get_win_folder_with_jna
if PY3:
import winreg as _winreg
else:
import _winreg
except ImportError:
_get_win_folder = _get_win_folder_from_environ
else:
_get_win_folder = _get_win_folder_from_registry
else:
_get_win_folder = _get_win_folder_with_jna
else:
_get_win_folder = _get_win_folder_with_ctypes


#---- self test code
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[wheel]
universal=1
[bdist_wheel]
universal = 1
54 changes: 24 additions & 30 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
#!/usr/bin/env python
import sys
from io import open
import os
import os.path
# appdirs is a dependency of setuptools, so allow installing without it.
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
import ast

tests_require = []
if sys.version_info < (2, 7):
tests_require.append("unittest2")


def read(fname):
inf = open(os.path.join(os.path.dirname(__file__), fname))
inf = open(os.path.join(os.path.dirname(__file__), fname), encoding='utf8')
out = "\n" + inf.read().replace("\r\n", "\n")
inf.close()
return out
@@ -34,32 +29,31 @@ def read(fname):
description='A small Python module for determining appropriate ' + \
'platform-specific dirs, e.g. a "user data dir".',
long_description=read('README.rst') + '\n' + read('CHANGES.rst'),
classifiers=[c.strip() for c in """
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python :: 2
Programming Language :: Python :: 2.6
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.2
Programming Language :: Python :: 3.3
Programming Language :: Python :: 3.4
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: Implementation :: PyPy
Programming Language :: Python :: Implementation :: CPython
Topic :: Software Development :: Libraries :: Python Modules
""".split('\n') if c.strip()],
test_suite='test.test_api',
tests_require=tests_require,
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: Implementation :: PyPy',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Software Development :: Libraries :: Python Modules',
],
keywords='application directory log cache user',
author='Trent Mick',
author_email='trentm@gmail.com',
maintainer='Trent Mick; Sridhar Ratnakumar; Jeff Rouse',
maintainer_email='trentm@gmail.com; github@srid.name; jr@its.to',
url='http://github.com/ActiveState/appdirs',
maintainer='Jeff Rouse',
maintainer_email='jr@its.to',
url='https://github.com/ActiveState/appdirs',
license='MIT',
py_modules=["appdirs"],
)
6 changes: 1 addition & 5 deletions test/test_api.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import sys
import unittest
import appdirs

if sys.version_info < (2, 7):
import unittest2 as unittest
else:
import unittest

if sys.version_info[0] < 3:
STRING_TYPE = basestring
else:
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py26, py27, py32, py33, py34, py35, py36
envlist = py{27,py,35,36,37,38,py3}

[testenv]
commands = python setup.py test
commands = {envpython} -m unittest discover