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.baseDir = baseDir if loadTemplate: map.loadTemplate = loadTemplate if _anchorCache is not None: map._anchorCache = _anchorCache return map