def factory(*args, **kws): if six.PY2 and args and isinstance(args[0], dict): map = CommentedMap(args[0].items(), **kws) else: map = CommentedMap(*args, **kws) map.base_dir = baseDir if loadTemplate: map.loadTemplate = loadTemplate if _anchorCache is not None: map._anchorCache = _anchorCache if lc is not None: map.lc.line = lc.line map.lc.col = lc.col return map