Codebase list appdirs / f7a8ffb
Imported Upstream version 1.4.0 Benjamin Drung 8 years ago
8 changed file(s) with 125 addition(s) and 32 deletion(s). Raw diff Collapse all Expand all
00 appdirs Changelog
11 =================
2
3 appdirs 1.4.0
4 -------------
5 - [PR #42] AppAuthor is now optional on Windows
6 - [issue 41] Support Jython on Windows, Mac, and Unix-like platforms. Windows
7 support requires `JNA <https://github.com/twall/jna>`_.
8 - [PR #44] Fix incorrect behaviour of the site_config_dir method
29
310 appdirs 1.3.0
411 -------------
11 include CHANGES.rst
22 include LICENSE.txt
33 include *.py
4 include test/*.py
00 Metadata-Version: 1.1
11 Name: appdirs
2 Version: 1.3.0
2 Version: 1.4.0
33 Summary: A small Python module for determining appropriate " + "platform-specific dirs, e.g. a "user data dir".
44 Home-page: http://github.com/ActiveState/appdirs
55 Author: Trent Mick; Sridhar Ratnakumar
149149 appdirs Changelog
150150 =================
151151
152 appdirs 1.4.0
153 -------------
154 - [PR #42] AppAuthor is now optional on Windows
155 - [issue 41] Support Jython on Windows, Mac, and Unix-like platforms. Windows
156 support requires `JNA <https://github.com/twall/jna>`_.
157 - [PR #44] Fix incorrect behaviour of the site_config_dir method
158
152159 appdirs 1.3.0
153160 -------------
154161 - [Unix, issue 16] Conform to XDG standard, instead of breaking it for
00 Metadata-Version: 1.1
11 Name: appdirs
2 Version: 1.3.0
2 Version: 1.4.0
33 Summary: A small Python module for determining appropriate " + "platform-specific dirs, e.g. a "user data dir".
44 Home-page: http://github.com/ActiveState/appdirs
55 Author: Trent Mick; Sridhar Ratnakumar
149149 appdirs Changelog
150150 =================
151151
152 appdirs 1.4.0
153 -------------
154 - [PR #42] AppAuthor is now optional on Windows
155 - [issue 41] Support Jython on Windows, Mac, and Unix-like platforms. Windows
156 support requires `JNA <https://github.com/twall/jna>`_.
157 - [PR #44] Fix incorrect behaviour of the site_config_dir method
158
152159 appdirs 1.3.0
153160 -------------
154161 - [Unix, issue 16] Conform to XDG standard, instead of breaking it for
33 Makefile.py
44 README.rst
55 appdirs.py
6 setup.cfg
67 setup.py
78 appdirs.egg-info/PKG-INFO
89 appdirs.egg-info/SOURCES.txt
910 appdirs.egg-info/dependency_links.txt
1011 appdirs.egg-info/top_level.txt
12 test/__init__.py
1113 test/test_api.py
1212 # - Mac OS X: http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/index.html
1313 # - XDG spec for Un*x: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
1414
15 __version_info__ = (1, 3, 0)
15 __version_info__ = (1, 4, 0)
1616 __version__ = '.'.join(map(str, __version_info__))
1717
1818
2424 if PY3:
2525 unicode = str
2626
27 if sys.platform.startswith('java'):
28 import platform
29 os_name = platform.java_ver()[3][0]
30 if os_name.startswith('Windows'): # "Windows XP", "Windows 7", etc.
31 system = 'win32'
32 elif os_name.startswith('Mac'): # "Mac OS X", etc.
33 system = 'darwin'
34 else: # "Linux", "SunOS", "FreeBSD", etc.
35 # Setting this to "linux2" is not ideal, but only Windows or Mac
36 # are actually checked for and the rest of the module expects
37 # *sys.platform* style strings.
38 system = 'linux2'
39 else:
40 system = sys.platform
41
42
2743
2844 def user_data_dir(appname=None, appauthor=None, version=None, roaming=False):
2945 r"""Return full path to the user-specific data dir for this application.
3046
3147 "appname" is the name of application.
3248 If None, just the system directory is returned.
33 "appauthor" (only required and used on Windows) is the name of the
49 "appauthor" (only used on Windows) is the name of the
3450 appauthor or distributing body for this application. Typically
35 it is the owning company name. This falls back to appname.
51 it is the owning company name. This falls back to appname. You may
52 pass False to disable it.
3653 "version" is an optional version path element to append to the
3754 path. You might want to use this if you want multiple versions
3855 of your app to be able to run independently. If used, this
5673 For Unix, we follow the XDG spec and support $XDG_DATA_HOME.
5774 That means, by default "~/.local/share/<AppName>".
5875 """
59 if sys.platform == "win32":
76 if system == "win32":
6077 if appauthor is None:
6178 appauthor = appname
6279 const = roaming and "CSIDL_APPDATA" or "CSIDL_LOCAL_APPDATA"
6380 path = os.path.normpath(_get_win_folder(const))
6481 if appname:
65 path = os.path.join(path, appauthor, appname)
66 elif sys.platform == 'darwin':
82 if appauthor is not False:
83 path = os.path.join(path, appauthor, appname)
84 else:
85 path = os.path.join(path, appname)
86 elif system == 'darwin':
6787 path = os.path.expanduser('~/Library/Application Support/')
6888 if appname:
6989 path = os.path.join(path, appname)
81101
82102 "appname" is the name of application.
83103 If None, just the system directory is returned.
84 "appauthor" (only required and used on Windows) is the name of the
104 "appauthor" (only used on Windows) is the name of the
85105 appauthor or distributing body for this application. Typically
86 it is the owning company name. This falls back to appname.
106 it is the owning company name. This falls back to appname. You may
107 pass False to disable it.
87108 "version" is an optional version path element to append to the
88109 path. You might want to use this if you want multiple versions
89110 of your app to be able to run independently. If used, this
106127
107128 WARNING: Do not use this on Windows. See the Vista-Fail note above for why.
108129 """
109 if sys.platform == "win32":
130 if system == "win32":
110131 if appauthor is None:
111132 appauthor = appname
112133 path = os.path.normpath(_get_win_folder("CSIDL_COMMON_APPDATA"))
113134 if appname:
114 path = os.path.join(path, appauthor, appname)
115 elif sys.platform == 'darwin':
135 if appauthor is not False:
136 path = os.path.join(path, appauthor, appname)
137 else:
138 path = os.path.join(path, appname)
139 elif system == 'darwin':
116140 path = os.path.expanduser('/Library/Application Support')
117141 if appname:
118142 path = os.path.join(path, appname)
143167
144168 "appname" is the name of application.
145169 If None, just the system directory is returned.
146 "appauthor" (only required and used on Windows) is the name of the
170 "appauthor" (only used on Windows) is the name of the
147171 appauthor or distributing body for this application. Typically
148 it is the owning company name. This falls back to appname.
172 it is the owning company name. This falls back to appname. You may
173 pass False to disable it.
149174 "version" is an optional version path element to append to the
150175 path. You might want to use this if you want multiple versions
151176 of your app to be able to run independently. If used, this
166191 For Unix, we follow the XDG spec and support $XDG_CONFIG_HOME.
167192 That means, by deafult "~/.config/<AppName>".
168193 """
169 if sys.platform in ["win32", "darwin"]:
194 if system in ["win32", "darwin"]:
170195 path = user_data_dir(appname, appauthor, None, roaming)
171196 else:
172197 path = os.getenv('XDG_CONFIG_HOME', os.path.expanduser("~/.config"))
182207
183208 "appname" is the name of application.
184209 If None, just the system directory is returned.
185 "appauthor" (only required and used on Windows) is the name of the
210 "appauthor" (only used on Windows) is the name of the
186211 appauthor or distributing body for this application. Typically
187 it is the owning company name. This falls back to appname.
212 it is the owning company name. This falls back to appname. You may
213 pass False to disable it.
188214 "version" is an optional version path element to append to the
189215 path. You might want to use this if you want multiple versions
190216 of your app to be able to run independently. If used, this
206232
207233 WARNING: Do not use this on Windows. See the Vista-Fail note above for why.
208234 """
209 if sys.platform in ["win32", "darwin"]:
235 if system in ["win32", "darwin"]:
210236 path = site_data_dir(appname, appauthor)
211237 if appname and version:
212238 path = os.path.join(path, version)
232258
233259 "appname" is the name of application.
234260 If None, just the system directory is returned.
235 "appauthor" (only required and used on Windows) is the name of the
261 "appauthor" (only used on Windows) is the name of the
236262 appauthor or distributing body for this application. Typically
237 it is the owning company name. This falls back to appname.
263 it is the owning company name. This falls back to appname. You may
264 pass False to disable it.
238265 "version" is an optional version path element to append to the
239266 path. You might want to use this if you want multiple versions
240267 of your app to be able to run independently. If used, this
259286 OPINION: This function appends "Cache" to the `CSIDL_LOCAL_APPDATA` value.
260287 This can be disabled with the `opinion=False` option.
261288 """
262 if sys.platform == "win32":
289 if system == "win32":
263290 if appauthor is None:
264291 appauthor = appname
265292 path = os.path.normpath(_get_win_folder("CSIDL_LOCAL_APPDATA"))
266293 if appname:
267 path = os.path.join(path, appauthor, appname)
294 if appauthor is not False:
295 path = os.path.join(path, appauthor, appname)
296 else:
297 path = os.path.join(path, appname)
268298 if opinion:
269299 path = os.path.join(path, "Cache")
270 elif sys.platform == 'darwin':
300 elif system == 'darwin':
271301 path = os.path.expanduser('~/Library/Caches')
272302 if appname:
273303 path = os.path.join(path, appname)
285315
286316 "appname" is the name of application.
287317 If None, just the system directory is returned.
288 "appauthor" (only required and used on Windows) is the name of the
318 "appauthor" (only used on Windows) is the name of the
289319 appauthor or distributing body for this application. Typically
290 it is the owning company name. This falls back to appname.
320 it is the owning company name. This falls back to appname. You may
321 pass False to disable it.
291322 "version" is an optional version path element to append to the
292323 path. You might want to use this if you want multiple versions
293324 of your app to be able to run independently. If used, this
311342 value for Windows and appends "log" to the user cache dir for Unix.
312343 This can be disabled with the `opinion=False` option.
313344 """
314 if sys.platform == "darwin":
345 if system == "darwin":
315346 path = os.path.join(
316347 os.path.expanduser('~/Library/Logs'),
317348 appname)
318 elif sys.platform == "win32":
349 elif system == "win32":
319350 path = user_data_dir(appname, appauthor, version)
320351 version = False
321352 if opinion:
357388
358389 @property
359390 def site_config_dir(self):
360 return site_data_dir(self.appname, self.appauthor,
391 return site_config_dir(self.appname, self.appauthor,
361392 version=self.version, multipath=self.multipath)
362393
363394 @property
447478
448479 return buf.value
449480
450 if sys.platform == "win32":
481 def _get_win_folder_with_jna(csidl_name):
482 import array
483 from com.sun import jna
484 from com.sun.jna.platform import win32
485
486 buf_size = win32.WinDef.MAX_PATH * 2
487 buf = array.zeros('c', buf_size)
488 shell = win32.Shell32.INSTANCE
489 shell.SHGetFolderPath(None, getattr(win32.ShlObj, csidl_name), None, win32.ShlObj.SHGFP_TYPE_CURRENT, buf)
490 dir = jna.Native.toString(buf.tostring()).rstrip("\0")
491
492 # Downgrade to short path name if have highbit chars. See
493 # <http://bugs.activestate.com/show_bug.cgi?id=85099>.
494 has_high_char = False
495 for c in dir:
496 if ord(c) > 255:
497 has_high_char = True
498 break
499 if has_high_char:
500 buf = array.zeros('c', buf_size)
501 kernel = win32.Kernel32.INSTANCE
502 if kernal.GetShortPathName(dir, buf, buf_size):
503 dir = jna.Native.toString(buf.tostring()).rstrip("\0")
504
505 return dir
506
507 if system == "win32":
451508 try:
452509 import win32com.shell
453510 _get_win_folder = _get_win_folder_with_pywin32
454511 except ImportError:
455512 try:
456 import ctypes
513 from ctypes import windll
457514 _get_win_folder = _get_win_folder_with_ctypes
458515 except ImportError:
459 _get_win_folder = _get_win_folder_from_registry
516 try:
517 import com.sun.jna
518 _get_win_folder = _get_win_folder_with_jna
519 except ImportError:
520 _get_win_folder = _get_win_folder_from_registry
460521
461522
462523 #---- self test code
483544 dirs = AppDirs(appname)
484545 for prop in props:
485546 print("%s: %s" % (prop, getattr(dirs, prop)))
547
548 print("\n-- app dirs (with disabled 'appauthor')")
549 dirs = AppDirs(appname, appauthor=False)
550 for prop in props:
551 print("%s: %s" % (prop, getattr(dirs, prop)))
0 [wheel]
1 universal = 1
2
03 [egg_info]
14 tag_build =
25 tag_date = 0
(New empty file)