# Path: rash/utils/confutils.py
# def get_config_directory(appname):
#     """
#     Get OS-specific configuration directory.
# 
#     :type appname: str
#     :arg  appname: capitalized name of the application
# 
#     """
#     if platform.system().lower() == 'windows':
#         path = os.path.join(os.getenv('APPDATA') or '~', appname, appname)
#     elif platform.system().lower() == 'darwin':
#         path = os.path.join('~', 'Library', 'Application Support', appname)
#     else:
#         path = os.path.join(os.getenv('XDG_CONFIG_HOME') or '~/.config',
#                             appname.lower())
#     return os.path.expanduser(path)
# 
# Path: rash/utils/pathutils.py
# def mkdirp(path):
#     """
#     Make directory at `path` if it does not exist.
#     """
#     if not os.path.isdir(path):
#         os.makedirs(path)


import os
from .utils.confutils import get_config_directory
from .utils.pathutils import mkdirp
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.





class ConfigStore(object):

    """
    Configuration and data file store.

    RASH stores data in the following directory in Linux::

      * ~/.config/               # $XDG_CONFIG_HOME
      `--* rash/                 # base_path
         |--* daemon.pid         # PID of daemon process
         |--* daemon.log         # Log file for daemon
         `--* data/              # data_path
            |--* db.sqlite       # db_path ("indexed" record)
            `--* record/         # record_path ("raw" record)
               |--* command/     # command log
               `--* init/        # initialization log

    In Mac OS and Windows, :attr:`base_path` may be different but
    structure in the directory is the same.

    """

    def __init__(self, base_path=None):

# Path: rash/utils/confutils.py
# def get_config_directory(appname):
#     """
#     Get OS-specific configuration directory.
# 
#     :type appname: str
#     :arg  appname: capitalized name of the application
# 
#     """
#     if platform.system().lower() == 'windows':
#         path = os.path.join(os.getenv('APPDATA') or '~', appname, appname)
#     elif platform.system().lower() == 'darwin':
#         path = os.path.join('~', 'Library', 'Application Support', appname)
#     else:
#         path = os.path.join(os.getenv('XDG_CONFIG_HOME') or '~/.config',
#                             appname.lower())
#     return os.path.expanduser(path)
# 
# Path: rash/utils/pathutils.py
# def mkdirp(path):
#     """
#     Make directory at `path` if it does not exist.
#     """
#     if not os.path.isdir(path):
#         os.makedirs(path)


# Path: rash/config.py
import os
from .utils.confutils import get_config_directory
from .utils.pathutils import mkdirp

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.





class ConfigStore(object):

    """
    Configuration and data file store.

    RASH stores data in the following directory in Linux::

      * ~/.config/               # $XDG_CONFIG_HOME
      `--* rash/                 # base_path
         |--* daemon.pid         # PID of daemon process
         |--* daemon.log         # Log file for daemon
         `--* data/              # data_path
            |--* db.sqlite       # db_path ("indexed" record)
            `--* record/         # record_path ("raw" record)
               |--* command/     # command log
               `--* init/        # initialization log

    In Mac OS and Windows, :attr:`base_path` may be different but
    structure in the directory is the same.

    """

    def __init__(self, base_path=None):

        self.base_path = base_path or get_config_directory('RASH')