1# This Source Code Form is subject to the terms of the Mozilla Public
2# License, v. 2.0. If a copy of the MPL was not distributed with this
3# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5from __future__ import absolute_import
6
7import os
8
9
10def get_state_dir():
11    """Obtain path to a directory to hold state.
12
13    Returns a tuple of the path and a bool indicating whether the
14    value came from an environment variable.
15    """
16    state_user_dir = os.path.expanduser('~/.mozbuild')
17    state_env_dir = os.environ.get('MOZBUILD_STATE_PATH')
18
19    if state_env_dir:
20        return state_env_dir, True
21    else:
22        return state_user_dir, False
23