# Path: elevator/config.py
# class Config(dict):
#     """
#     Unix shells like environment class. Implements add,
#     get, load, flush methods. Handles lists of values too.
#     Basically Acts like a basic key/value store.
#     """
#     def __init__(self, f=None, *args, **kwargs):
#         if f:
#             self.update_with_file(f)  # Has to be called last!
# 
#         self.update(kwargs)
#         dict.__init__(self, *args, **kwargs)
# 
#     def update_with_file(self, f):
#         """
#         Updates the environment using an ini file containing
#         key/value descriptions.
#         """
#         config = ConfigParser()
# 
#         with open(f, 'r') as f:
#             config.readfp(f)
# 
#             for section in config.sections():
#                 self.update(items_to_dict(config.items(section)))
# 
#     def reload_from_file(self, f=''):
#         self.flush(f)
#         self.load(f)
# 
#     def update_with_args(self, args):
#         """Loads argparse kwargs into environment, as `section`"""
#         for (arg, value) in args:
#             if value is not None:
#                 self[arg] = value
# 
#     def flush(self):
#         """
#         Flushes the environment from it's manually
#         set attributes.
#         """
#         for attr in self.attributes:
#             delattr(self, attr)


import os
import shutil
import subprocess
import tempfile
import ConfigParser
import random
from elevator.config import Config
# -*- coding: utf-8 -*-

# Copyright (c) 2012 theo crevon
#
# See the file LICENSE for copying permission.



mkdtemp = lambda _dir: tempfile.mkdtemp(suffix='-test',
                                        prefix='elevator-',
                                        dir=_dir)
mkstemp = lambda suffix, _dir: tempfile.mkstemp(suffix="-test" + suffix,
                                                prefix='elevator-',
                                                dir=_dir)[1]


def gen_test_config():
    tmp = mkdtemp('/tmp')
    return Config(**{
        'daemonize': 'no',
        'pidfile': os.path.join(tmp, 'elevator_test.pid'),
        'databases_storage_path': os.path.join(tmp, 'elevator_test'),
        'database_store': os.path.join(tmp, 'elevator_test/store.json'),
        'default_db': 'default',
        'port': 4141,

# Path: elevator/config.py
# class Config(dict):
#     """
#     Unix shells like environment class. Implements add,
#     get, load, flush methods. Handles lists of values too.
#     Basically Acts like a basic key/value store.
#     """
#     def __init__(self, f=None, *args, **kwargs):
#         if f:
#             self.update_with_file(f)  # Has to be called last!
# 
#         self.update(kwargs)
#         dict.__init__(self, *args, **kwargs)
# 
#     def update_with_file(self, f):
#         """
#         Updates the environment using an ini file containing
#         key/value descriptions.
#         """
#         config = ConfigParser()
# 
#         with open(f, 'r') as f:
#             config.readfp(f)
# 
#             for section in config.sections():
#                 self.update(items_to_dict(config.items(section)))
# 
#     def reload_from_file(self, f=''):
#         self.flush(f)
#         self.load(f)
# 
#     def update_with_args(self, args):
#         """Loads argparse kwargs into environment, as `section`"""
#         for (arg, value) in args:
#             if value is not None:
#                 self[arg] = value
# 
#     def flush(self):
#         """
#         Flushes the environment from it's manually
#         set attributes.
#         """
#         for attr in self.attributes:
#             delattr(self, attr)


# Path: tests/core/fakers.py
import os
import shutil
import subprocess
import tempfile
import ConfigParser
import random
from elevator.config import Config

# -*- coding: utf-8 -*-

# Copyright (c) 2012 theo crevon
#
# See the file LICENSE for copying permission.



mkdtemp = lambda _dir: tempfile.mkdtemp(suffix='-test',
                                        prefix='elevator-',
                                        dir=_dir)
mkstemp = lambda suffix, _dir: tempfile.mkstemp(suffix="-test" + suffix,
                                                prefix='elevator-',
                                                dir=_dir)[1]


def gen_test_config():
    tmp = mkdtemp('/tmp')
    return Config(**{
        'daemonize': 'no',
        'pidfile': os.path.join(tmp, 'elevator_test.pid'),
        'databases_storage_path': os.path.join(tmp, 'elevator_test'),
        'database_store': os.path.join(tmp, 'elevator_test/store.json'),
        'default_db': 'default',
        'port': 4141,

        'bind': '127.0.0.1',