def __getattr__(self, name):

        # For stealth authentication, the .onion is per-client. So in
        # that case, we really have no choice here -- we can't have
        # "a" hostname. So we just barf; it's an error to access to
        # hostname this way. Instead, use .clients.{hostname, cookie}

        if name == 'private_key':
            with open(os.path.join(self.dir, name)) as f:
                data = f.read().strip()
            self.__dict__[name] = data

        elif name == 'clients':
            clients = []
            try:
                with open(os.path.join(self.dir, 'hostname')) as f:
                    for line in f.readlines():
                        args = line.split()
                        # XXX should be a dict?
                        if len(args) > 1:
                            # tag, onion-uri?
                            clients.append((args[0], args[1]))
                        else:
                            clients.append(('default', args[0]))
            except IOError:
                pass
            self.__dict__[name] = clients

        elif name == 'hostname':
            with open(os.path.join(self.dir, name)) as f:
                data = f.read().strip()
            host = None
            for line in data.split('\n'):
                h = line.split(' ')[0]
                if host is None:
                    host = h
                elif h != host:
                    raise RuntimeError(
                        ".hostname accessed on stealth-auth'd hidden-service "
                        "with multiple onion addresses."
                    )
            self.__dict__[name] = h

        elif name == 'client_keys':
            fname = os.path.join(self.dir, name)
            keys = []
            if os.path.exists(fname):
                with open(fname) as f:
                    keys = parse_client_keys(f)
            self.__dict__[name] = keys
        return self.__dict__[name]
FIXME can't we just move this to @property decorated methods
dataset/ETHPy150Open meejah/txtorcon/txtorcon/torconfig.py/HiddenService.__getattr__