def _make_mergable_if_possible(data): if isinstance(data, dict): return ConfigDict(data=data) elif isiterable(data): return ConfigList([_make_mergable_if_possible(i) for i in data]) else: return data
def make_mergable_if_possible(cls, data, context): """ Makes an object mergable if possible. Returns the virgin object if cannot convert it to a mergable instance. :returns: :class:`.Mergable` or type(data) """ if isinstance(data, dict): return ConfigDict(data=data, context=context) elif isiterable(data): return ConfigList(data=[cls.make_mergable_if_possible(i, context) for i in data], context=context) else: return data
def make_mergable_if_possible(cls, data, context): """ Makes an object mergable if possible. Returns the virgin object if cannot convert it to a mergable instance. :returns: :class:`.Mergable` or type(data) """ if isinstance(data, dict): return ConfigDict(data=data, context=context) elif isiterable(data): return ConfigList( data=[cls.make_mergable_if_possible(i, context) for i in data], context=context) else: return data