Skip to content

Instantly share code, notes, and snippets.

@jrabbit
Created April 6, 2012 14:52
Show Gist options
  • Save jrabbit/2320541 to your computer and use it in GitHub Desktop.
Save jrabbit/2320541 to your computer and use it in GitHub Desktop.
Make an app folder/ get app folder
def directory(app_name):
"""Construct app_dir from os name"""
home = os.path.expanduser('~')
if platform.system() == 'Linux':
app_dir = os.path.join(home, '.' + app_name)
elif platform.system() == 'Darwin':
app_dir = os.path.join(home, 'Library', 'Application Support',
app_name)
elif platform.system() == 'Windows':
app_dir = os.path.join(os.environ['appdata'], app_name)
else:
app_dir = os.path.join(home, '.' + app_name)
if not os.path.isdir(app_dir):
os.mkdir(app_dir)
return app_dir
@jrabbit
Copy link
Author

jrabbit commented Apr 7, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment