# Path: configman/converters.py
# def str_dict_keys(a_dict):
#     """return a modified dict where all the keys that are anything but str get
#     converted to str.
#     E.g.
# 
#       >>> result = str_dict_keys({u'name': u'Peter', u'age': 99, 1: 2})
#       >>> # can't compare whole dicts in doctests
#       >>> result['name']
#       u'Peter'
#       >>> result['age']
#       99
#       >>> result[1]
#       2
# 
#     The reason for this is that in Python <= 2.6.4 doing
#     ``MyClass(**{u'name': u'Peter'})`` would raise a TypeError
# 
#     Note that only unicode types are converted to str types.
#     The reason for that is you might have a class that looks like this::
# 
#         class Option(object):
#             def __init__(self, foo=None, bar=None, **kwargs):
#                 ...
# 
#     And it's being used like this::
# 
#         Option(**{u'foo':1, u'bar':2, 3:4})
# 
#     Then you don't want to change that {3:4} part which becomes part of
#     `**kwargs` inside the __init__ method.
#     Using integers as parameter keys is a silly example but the point is that
#     due to the python 2.6.4 bug only unicode keys are converted to str.
#     """
#     new_dict = {}
#     for key in a_dict:
#         if six.PY2 and isinstance(key, six.text_type):
#             new_dict[str(key)] = a_dict[key]
#         else:
#             new_dict[key] = a_dict[key]
#     return new_dict


import collections
from configman.converters import str_dict_keys
from configman.namespace import Namespace
from configman.option import (
    Option,
    Aggregation,
)
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, division, print_function




#------------------------------------------------------------------------------
def setup_definitions(source, destination):
    for key, val in source.items():
        if key.startswith('__'):
            continue  # ignore these
        if isinstance(val, Option):
            destination[key] = val
            if not val.name:
                val.name = key
            val.set_value(val.default)
        elif isinstance(val, Aggregation):
            destination[key] = val
        elif isinstance(val, collections.Mapping):
            if 'name' in val and 'default' in val:
                # this is an Option in the form of a dict, not a Namespace
                if key == 'not_for_definition' and val is True:
                    continue  # ignore this element

# Path: configman/converters.py
# def str_dict_keys(a_dict):
#     """return a modified dict where all the keys that are anything but str get
#     converted to str.
#     E.g.
# 
#       >>> result = str_dict_keys({u'name': u'Peter', u'age': 99, 1: 2})
#       >>> # can't compare whole dicts in doctests
#       >>> result['name']
#       u'Peter'
#       >>> result['age']
#       99
#       >>> result[1]
#       2
# 
#     The reason for this is that in Python <= 2.6.4 doing
#     ``MyClass(**{u'name': u'Peter'})`` would raise a TypeError
# 
#     Note that only unicode types are converted to str types.
#     The reason for that is you might have a class that looks like this::
# 
#         class Option(object):
#             def __init__(self, foo=None, bar=None, **kwargs):
#                 ...
# 
#     And it's being used like this::
# 
#         Option(**{u'foo':1, u'bar':2, 3:4})
# 
#     Then you don't want to change that {3:4} part which becomes part of
#     `**kwargs` inside the __init__ method.
#     Using integers as parameter keys is a silly example but the point is that
#     due to the python 2.6.4 bug only unicode keys are converted to str.
#     """
#     new_dict = {}
#     for key in a_dict:
#         if six.PY2 and isinstance(key, six.text_type):
#             new_dict[str(key)] = a_dict[key]
#         else:
#             new_dict[key] = a_dict[key]
#     return new_dict


# Path: configman/def_sources/for_mappings.py
import collections
from configman.converters import str_dict_keys
from configman.namespace import Namespace
from configman.option import (
    Option,
    Aggregation,
)

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, division, print_function




#------------------------------------------------------------------------------
def setup_definitions(source, destination):
    for key, val in source.items():
        if key.startswith('__'):
            continue  # ignore these
        if isinstance(val, Option):
            destination[key] = val
            if not val.name:
                val.name = key
            val.set_value(val.default)
        elif isinstance(val, Aggregation):
            destination[key] = val
        elif isinstance(val, collections.Mapping):
            if 'name' in val and 'default' in val:
                # this is an Option in the form of a dict, not a Namespace
                if key == 'not_for_definition' and val is True:
                    continue  # ignore this element

                params = str_dict_keys(val)