def display_info(name, item, resolved_item, display_name=None): global opt # link should be based on fully resolved type to avoid extra # HTTP redirect. link = tornado.escape.url_escape(name, plus=False) if stat.S_ISDIR(vfs.item_mode(resolved_item)): link += '/' link = link.encode('ascii') size = vfs.item_size(repo, item) if opt.human_readable: display_size = format_filesize(size) else: display_size = size if not display_name: mode = vfs.item_mode(item) if stat.S_ISDIR(mode): display_name = name + b'/' elif stat.S_ISLNK(mode): display_name = name + b'@' else: display_name = name return display_name, link + url_query, display_size
def summary_bytes(meta, numeric_ids=False, classification=None, human_readable=False): """Return bytes containing the "ls -l" style listing for meta. Classification may be "all", "type", or None.""" user_str = group_str = size_or_dev_str = b'?' symlink_target = None if meta: name = meta.path mode_str = xstat.mode_str(meta.mode).encode('ascii') symlink_target = meta.symlink_target mtime_secs = xstat.fstime_floor_secs(meta.mtime) mtime_str = strftime('%Y-%m-%d %H:%M', time.localtime(mtime_secs)).encode('ascii') if meta.user and not numeric_ids: user_str = meta.user elif meta.uid != None: user_str = str(meta.uid).encode() if meta.group and not numeric_ids: group_str = meta.group elif meta.gid != None: group_str = str(meta.gid).encode() if stat.S_ISCHR(meta.mode) or stat.S_ISBLK(meta.mode): if meta.rdev: size_or_dev_str = ( '%d,%d' % (os.major(meta.rdev), os.minor(meta.rdev))).encode() elif meta.size != None: if human_readable: size_or_dev_str = format_filesize(meta.size).encode() else: size_or_dev_str = str(meta.size).encode() else: size_or_dev_str = b'-' if classification: classification_str = \ xstat.classification_str(meta.mode, classification == 'all').encode() else: mode_str = b'?' * 10 mtime_str = b'????-??-?? ??:??' classification_str = b'?' name = name or b'' if classification: name += classification_str if symlink_target: name += b' -> ' + meta.symlink_target return b'%-10s %-11s %11s %16s %s' % (mode_str, user_str + b'/' + group_str, size_or_dev_str, mtime_str, name)
def summary_str(meta, numeric_ids = False, classification = None, human_readable = False): """Return a string containing the "ls -l" style listing for meta. Classification may be "all", "type", or None.""" user_str = group_str = size_or_dev_str = '?' symlink_target = None if meta: name = meta.path mode_str = xstat.mode_str(meta.mode) symlink_target = meta.symlink_target mtime_secs = xstat.fstime_floor_secs(meta.mtime) mtime_str = time.strftime('%Y-%m-%d %H:%M', time.localtime(mtime_secs)) if meta.user and not numeric_ids: user_str = meta.user elif meta.uid != None: user_str = str(meta.uid) if meta.group and not numeric_ids: group_str = meta.group elif meta.gid != None: group_str = str(meta.gid) if stat.S_ISCHR(meta.mode) or stat.S_ISBLK(meta.mode): if meta.rdev: size_or_dev_str = '%d,%d' % (os.major(meta.rdev), os.minor(meta.rdev)) elif meta.size != None: if human_readable: size_or_dev_str = format_filesize(meta.size) else: size_or_dev_str = str(meta.size) else: size_or_dev_str = '-' if classification: classification_str = \ xstat.classification_str(meta.mode, classification == 'all') else: mode_str = '?' * 10 mtime_str = '????-??-?? ??:??' classification_str = '?' name = name or '' if classification: name += classification_str if symlink_target: name += ' -> ' + meta.symlink_target return '%-10s %-11s %11s %16s %s' % (mode_str, user_str + "/" + group_str, size_or_dev_str, mtime_str, name)
def display_info(name, item, resolved_item, display_name=None, omitsize=False): global opt # link should be based on fully resolved type to avoid extra # HTTP redirect. link = tornado.escape.url_escape(name, plus=False) if stat.S_ISDIR(vfs.item_mode(resolved_item)): link += '/' link = link.encode('ascii') if not omitsize: size = vfs.item_size(repo, item) if args.hsizes: display_size = format_filesize(size) else: display_size = size else: display_size = None if not display_name: mode = vfs.item_mode(item) if stat.S_ISDIR(mode): display_name = name + b'/' display_size = None elif stat.S_ISLNK(mode): display_name = name + b'@' display_size = None else: display_name = name meta = resolved_item.meta if not isinstance(meta, Metadata): meta = None try: oidx = hexlify(resolved_item.oid) except AttributeError: oidx = '' return display_name, link + args, display_size, meta, oidx
def summary_str(meta, numeric_ids=False, human_readable=False): mode_val = xstat.mode_str(meta.mode) user_val = meta.user if numeric_ids or not user_val: user_val = str(meta.uid) group_val = meta.group if numeric_ids or not group_val: group_val = str(meta.gid) size_or_dev_val = "-" if stat.S_ISCHR(meta.mode) or stat.S_ISBLK(meta.mode): size_or_dev_val = "%d,%d" % (os.major(meta.rdev), os.minor(meta.rdev)) elif meta.size != None: size_or_dev_val = meta.size if human_readable: size_or_dev_val = format_filesize(meta.size) mtime_secs = xstat.fstime_floor_secs(meta.mtime) time_val = time.strftime("%Y-%m-%d %H:%M", time.localtime(mtime_secs)) path_val = meta.path or "" if stat.S_ISLNK(meta.mode): path_val += " -> " + meta.symlink_target return "%-10s %-11s %11s %16s %s" % (mode_val, user_val + "/" + group_val, size_or_dev_val, time_val, path_val)
def display_info(name, item, resolved_item, display_name=None): # link should be based on fully resolved type to avoid extra # HTTP redirect. if stat.S_ISDIR(vfs.item_mode(resolved_item)): link = urllib.quote(name) + '/' else: link = urllib.quote(name) size = vfs.item_size(repo, item) if opt.human_readable: display_size = format_filesize(size) else: display_size = size if not display_name: mode = vfs.item_mode(item) if stat.S_ISDIR(mode): display_name = name + '/' elif stat.S_ISLNK(mode): display_name = name + '@' else: display_name = name return display_name, link + url_query, display_size