From 893d03aabd0e674b40fbc4b8d44568cfee2bd31d Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Wed, 1 Jun 2016 00:10:12 +0300 Subject: [PATCH] upysh: ls: Print file size/directory type. --- upysh/upysh.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/upysh/upysh.py b/upysh/upysh.py index 20e9d573..517047a4 100644 --- a/upysh/upysh.py +++ b/upysh/upysh.py @@ -4,15 +4,18 @@ import os class LS: def __repr__(self): - l = os.listdir() - l.sort() - return "\n".join(l) + self.__call__() + return "" def __call__(self, path="."): l = os.listdir(path) l.sort() for f in l: - print(f) + st = os.stat("%s/%s" % (path, f)) + if st[0] & 0x4000: # stat.S_IFDIR + print(" %s" % f) + else: + print("% 8d %s" % (st[6], f)) class PWD: