comparison configmix/config.py @ 416:2abde0d3c735

FIX: Handle .jailed() with an empty "root" properly
author Franz Glasner <fzglas.hg@dom66.de>
date Wed, 01 Dec 2021 23:09:00 +0100
parents 816327e178b0
children 83d537f1dfbb
comparison
equal deleted inserted replaced
415:606feee43e71 416:2abde0d3c735
687 """ 687 """
688 if rootpath is not None and root is not None: 688 if rootpath is not None and root is not None:
689 raise ValueError("only one of `rootpath' or `root' can be given") 689 raise ValueError("only one of `rootpath' or `root' can be given")
690 if rootpath is None and root is None: 690 if rootpath is None and root is None:
691 raise ValueError("one of `rootpath' or `root' must be given") 691 raise ValueError("one of `rootpath' or `root' must be given")
692 if rootpath is not None and not isinstance(rootpath, (list, tuple)):
693 raise TypeError("`rootpath' must be a list or a tuple")
692 if root is not None: 694 if root is not None:
693 # convert to path 695 # convert to path
694 varns, varname = self._split_ns(root) 696 varns, varname = self._split_ns(root)
695 if varns: 697 if varns:
696 raise ValueError( 698 raise ValueError(
697 "jailed configurations do not support namespaces") 699 "jailed configurations do not support namespaces")
698 rootpath = [ 700 if varname:
699 self.unquote(p) for p in root.split( 701 rootpath = [
700 self._HIER_SEPARATOR) 702 self.unquote(p) for p in root.split(
701 ] 703 self._HIER_SEPARATOR)
704 ]
705 else:
706 rootpath = tuple()
702 jc = _JailedConfiguration(*rootpath) 707 jc = _JailedConfiguration(*rootpath)
703 if bind_root: 708 if bind_root:
704 jc.rebind(self) 709 jc.rebind(self)
705 return jc 710 return jc
706 711