def set_completer_options(self, cons=True, runs=True, imgs=True, vols=True):
        """
        Set image and container names in Completer.
        Re-read if needed after a command.
        :param cons: boolean: need to refresh containers
        :param runs: boolean: need to refresh running containers
        :param imgs: boolean: need to refresh images
        :param vols: boolean: need to refresh volumes
        """

        if cons:
            cs = self.handler.containers(all=True)
            if cs and len(cs) > 0 and isinstance(cs[0], dict):
                containers = [name for c in cs for name in c['Names']]
                self.completer.set_containers(containers)

        if runs:
            cs = self.handler.containers()
            if cs and len(cs) > 0 and isinstance(cs[0], dict):
                running = [name for c in cs for name in c['Names']]
                self.completer.set_running(running)

        if imgs:
            def format_tagged(tagname, img_id):
                if tagname == '<none>:<none>':
                    return img_id[:11]
                return tagname

            def parse_image_name(tag, img_id):
                if ':' in tag:
                    result = tag.split(':', 2)[0]
                else:
                    result = tag
                if result == '<none>':
                    result = img_id[:11]
                return result

            ims = self.handler.images()
            if ims and len(ims) > 0 and isinstance(ims[0], dict):
                images = set([])
                tagged = set([])
                for im in ims:
                    repo_tag = '{0}:{1}'.format(im['Repository'], im['Tag'])
                    images.add(parse_image_name(repo_tag, im['Id']))
                    tagged.add(format_tagged(repo_tag, im['Id']))
                self.completer.set_images(images)
                self.completer.set_tagged(tagged)

        if vols:
            vs = self.handler.volume_ls(quiet=True)
            self.completer.set_volumes(vs)
dataset/ETHPy150Open j-bennet/wharfee/wharfee/main.py/WharfeeCli.set_completer_options/original