# Path: lamvery/log.py
# def get_logger(name):
#     global logger
#     if logger is None:
#         logger = logging.getLogger(name)
#         logger.setLevel(logging.INFO)
#         handler = ColoredStreamHandler(stream=sys.stderr)
#         handler.setLevel(logging.INFO)
#         handler.setFormatter(
#             logging.Formatter('%(name)s: %(message)s'))
#         logger.removeHandler(handler)
#         logger.addHandler(handler)
#     return logger


import yaml
import os
import re
from collections import OrderedDict
from jinja2 import Environment, FileSystemLoader
from jinja2.exceptions import TemplateNotFound
from lamvery.log import get_logger
RUNTIME_NODE_JS_43 = 'nodejs4.3'
DEFAULT_RUNTIME_NODE_JS = RUNTIME_NODE_JS_43

RUNTIME_AND_EXTENSION = {
    RUNTIME_PY_27: 'py',
    RUNTIME_NODE_JS: 'js',
    RUNTIME_NODE_JS_43: 'js'
}


def represent_odict(dumper, instance):
    return dumper.represent_mapping(u'tag:yaml.org,2002:map', instance.items())

yaml.add_representer(OrderedDict, represent_odict)
yaml.add_constructor(
    yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
    lambda loader, node: OrderedDict(loader.construct_pairs(node)))


class Config:

    def __init__(self, conf_file):
        self._file = conf_file
        self._template_env = Environment(loader=FileSystemLoader('./', encoding='utf8'))

    def load(self, file, default={}):
        try:
            tmpl = self._template_env.get_template(file)
            return yaml.load(tmpl.render({'env': os.environ}))
        except TemplateNotFound:

# Path: lamvery/log.py
# def get_logger(name):
#     global logger
#     if logger is None:
#         logger = logging.getLogger(name)
#         logger.setLevel(logging.INFO)
#         handler = ColoredStreamHandler(stream=sys.stderr)
#         handler.setLevel(logging.INFO)
#         handler.setFormatter(
#             logging.Formatter('%(name)s: %(message)s'))
#         logger.removeHandler(handler)
#         logger.addHandler(handler)
#     return logger


# Path: lamvery/config.py
import yaml
import os
import re
from collections import OrderedDict
from jinja2 import Environment, FileSystemLoader
from jinja2.exceptions import TemplateNotFound
from lamvery.log import get_logger

RUNTIME_NODE_JS_43 = 'nodejs4.3'
DEFAULT_RUNTIME_NODE_JS = RUNTIME_NODE_JS_43

RUNTIME_AND_EXTENSION = {
    RUNTIME_PY_27: 'py',
    RUNTIME_NODE_JS: 'js',
    RUNTIME_NODE_JS_43: 'js'
}


def represent_odict(dumper, instance):
    return dumper.represent_mapping(u'tag:yaml.org,2002:map', instance.items())

yaml.add_representer(OrderedDict, represent_odict)
yaml.add_constructor(
    yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
    lambda loader, node: OrderedDict(loader.construct_pairs(node)))


class Config:

    def __init__(self, conf_file):
        self._file = conf_file
        self._template_env = Environment(loader=FileSystemLoader('./', encoding='utf8'))

    def load(self, file, default={}):
        try:
            tmpl = self._template_env.get_template(file)
            return yaml.load(tmpl.render({'env': os.environ}))
        except TemplateNotFound:

            get_logger(__name__).warn(