def lookupName(self, root, name):
        theId = self.nameCache.get(name, None)
        if theId is not None:
            return theId

        # if not root, cannot chroot and so fall back to system ids
        getChrootIds = root and root != '/' and not os.getuid()

        if getChrootIds:
            if root[0] != '/':
                root = os.sep.join((os.getcwd(), root))
            curDir = os.open(".", os.O_RDONLY)
            # chdir to the current root to allow us to chroot
            # back out again
            os.chdir('/')
            os.chroot(root)

        if name and name[0] == '+':
            # An id mapped as a string
            try:
                theId = int(name)
            except __HOLE__:
                log.warning('%s %s does not exist - using root', self.name,
                            name)
        else:
            try:
                theId = self.nameLookupFn(name)[2]
            except KeyError:
                log.warning('%s %s does not exist - using root', self.name, name)
                theId = 0

        if getChrootIds:
            os.chroot(".")
            os.fchdir(curDir)
            os.close(curDir)

        self.nameCache[name] = theId
        self.idCache[theId] = name
        return theId
dataset/ETHPy150Open sassoftware/conary/conary/files.py/UserGroupIdCache.lookupName