Putting all the code from the current master branch of TWBlue

This commit is contained in:
2014-10-27 16:29:04 -06:00
parent 58c82e5486
commit 1af4a8b291
284 changed files with 58760 additions and 0 deletions

66
src/paths.py Normal file
View File

@@ -0,0 +1,66 @@
# -*- coding: utf-8 -*-
import platform
import os
import sys
from platform_utils import paths as paths_
from functools import wraps
mode = None
directory = None
def merge_paths(func):
@wraps(func)
def merge_paths_wrapper(*a):
return unicode(os.path.join(func(), *a))
return merge_paths_wrapper
@merge_paths
def app_path():
return paths_.app_path()
@merge_paths
def config_path():
global mode, directory
if mode == "portable":
if directory != None: path = os.path.join(directory, "config")
elif directory == None: path = app_path(u"config")
elif mode == "installed":
path = data_path("config")
if not os.path.exists(path):
os.mkdir(path)
return path
@merge_paths
def logs_path():
global mode, directory
if mode == "portable":
if directory != None: path = os.path.join(directory, "logs")
elif directory == None: path = app_path(u"logs")
elif mode == "installed":
path = data_path("logs")
if not os.path.exists(path):
os.mkdir(path)
return path
@merge_paths
def data_path(app_name='TW blue'):
# if platform.system() == "Windows":
# import shlobj
# data_path = os.path.join(shlobj.SHGetFolderPath(0, shlobj.CSIDL_APPDATA), app_name)
# else:
if platform.system() == "Windows":
data_path = os.path.join(os.getenv("AppData"), app_name)
else:
data_path = os.path.join(os.environ['HOME'], ".%s" % app_name)
if not os.path.exists(data_path):
os.mkdir(data_path)
return data_path
@merge_paths
def locale_path():
return app_path(u"locales")
@merge_paths
def sound_path():
return app_path(u"sounds")