# Path: turbulenz_local/tools.py
# def get_absolute_path(directory):
#     """
#     Return absolute path by working out path relative to games root
#     """
#     if isabs(directory):
#         return directory
# 
#     return realpath(normpath(join(config['games_root'], directory)))
# 
# def create_dir(directory):
#     """
#     Create the directory structure if necessary. return 'True' if it was created
#     successfully and can be written into, 'False' otherwise.
#     """
#     if directory.strip() == '':
#         return False
#     else:
#         absDir = get_absolute_path(directory)
#         try:
#             os.makedirs(absDir)
#         except OSError as e:
#             if e.errno != EEXIST:
#                 LOG.error('Failed creating meta dir: %s', str(e))
#                 return False
#         return os.access(absDir, os.W_OK)


import logging
import os
from pylons import config
from os.path import join as join_path
from turbulenz_local.tools import get_absolute_path, create_dir
# Copyright (c) 2011-2014 Turbulenz Limited


# pylint: disable=F0401
# pylint: enable=F0401



LOG = logging.getLogger(__name__)


class UserDataPathError(Exception):
    pass


class UserDataError(Exception):
    pass



# Path: turbulenz_local/tools.py
# def get_absolute_path(directory):
#     """
#     Return absolute path by working out path relative to games root
#     """
#     if isabs(directory):
#         return directory
# 
#     return realpath(normpath(join(config['games_root'], directory)))
# 
# def create_dir(directory):
#     """
#     Create the directory structure if necessary. return 'True' if it was created
#     successfully and can be written into, 'False' otherwise.
#     """
#     if directory.strip() == '':
#         return False
#     else:
#         absDir = get_absolute_path(directory)
#         try:
#             os.makedirs(absDir)
#         except OSError as e:
#             if e.errno != EEXIST:
#                 LOG.error('Failed creating meta dir: %s', str(e))
#                 return False
#         return os.access(absDir, os.W_OK)


# Path: turbulenz_local/models/apiv1/userdata.py
import logging
import os
from pylons import config
from os.path import join as join_path
from turbulenz_local.tools import get_absolute_path, create_dir

# Copyright (c) 2011-2014 Turbulenz Limited


# pylint: disable=F0401
# pylint: enable=F0401



LOG = logging.getLogger(__name__)


class UserDataPathError(Exception):
    pass


class UserDataError(Exception):
    pass



class UserDataKeyError(Exception):