def print_target_info(self, client, target, decorate, maxlines=10, fail_if_not_exist=False):
        info = client.get_target_info(target, 1)
        info_type = info.get('type') if info is not None else None

        if info_type is None:
            if fail_if_not_exist:
                raise UsageError('Target doesn\'t exist: %s/%s' % target)
            else:
                print >>self.stdout, formatting.verbose_contents_str(None)

        if info_type == 'file':
            if decorate:
                import base64
                for line in client.head_target(target, maxlines):
                    print >>self.stdout, formatting.verbose_contents_str(base64.b64decode(line)),
            else:
                client.cat_target(target, self.stdout)

        def size(x):
            t = x.get('type', '???')
            if t == 'file':
                return formatting.size_str(x['size'])
            elif t == 'directory':
                return 'dir'
            else:
                return t

        if info_type == 'directory':
            contents = [
                {
                    'name': x['name'] + (' -> ' + x['link'] if 'link' in x else ''),
                    'size': size(x),
                    'perm': oct(x['perm']) if 'perm' in x else ''
                }
                for x in info['contents']
            ]
            contents = sorted(contents, key=lambda r: r['name'])
            self.print_table(('name', 'perm', 'size'), contents, justify={'size': 1}, indent='')

        if info_type == 'link':
            print >>self.stdout, ' -> ' + info['link']
            

        return info
dataset/ETHPy150Open codalab/codalab-cli/codalab/lib/bundle_cli.py/BundleCLI.print_target_info/original