diff --git a/twander.py b/twander.py index 8c8c18b..a372879 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 3.182 2005/01/28 22:26:21 tundra Exp $" +RCSID = "$Id: twander.py,v 3.183 2005/01/28 23:18:35 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -494,8 +494,13 @@ UNAVAILABLE = "Unavailable" WIN32GROUP = "win32" + FILEGROUP WIN32OWNER = "win32" + FILEOWNER -WIN32FREE = " free" -WIN32TOTAL = " total " # Leave trailing space - drive letter follows +WIN32FREE = "free" +WIN32TOTAL = "total " # Leave trailing space - drive letter follows + +MAX_SZ_CHARS = 17 # Number of digits needed to display max drive/file size - including commas +SZ_TRAILING_SPACE = 2 # Number of trailing spaces to add after a drive/file size field. + +MAX_SZ_FIELD = MAX_SZ_CHARS + SZ_TRAILING_SPACE # Biggest a drive/file size string can be if WIN32ALL: @@ -523,8 +528,8 @@ SZ_DRIVE_SHARE = 24 # Can be label or share string - leave plenty of room SZ_DRIVE_TYPE = 20 - SZ_DRIVE_FREE = 13 # The trailing text string has as leading blank for separation - SZ_DRIVE_TTL = 13 # The trailing text string has leading and trailing blanks for separation + SZ_DRIVE_FREE = MAX_SZ_FIELD + SZ_DRIVE_TTL = MAX_SZ_FIELD SZ_DRIVE_TOTAL = SZ_DRIVE_SHARE + SZ_DRIVE_TYPE + SZ_DRIVE_FREE + len(WIN32FREE) + \ SZ_DRIVE_TTL + len(WIN32TOTAL) @@ -549,7 +554,7 @@ ST_SZNLINK = 5 ST_SZUNAME = 18 ST_SZGNAME = 18 -ST_SZLEN = 15 +ST_SZLEN = MAX_SZ_FIELD ST_SZMTIME = 18 ST_SZTOTAL = ST_SZMODE + ST_SZNLINK + ST_SZUNAME + ST_SZGNAME + \ @@ -987,11 +992,13 @@ ##### -# Pad A String With Trailing Spaces To Specified Width +# Pad A String With Spaces To Specified Width. # Return either that padded string or, if the passed -# string is too large, truncate it and return a string -# of exactly the specified width whose last character is -# a space. +# string is too large, truncate it to specified length. +# Defaults to left-justification, but can be overriden. +# Optionally can rotate a specified number of leading +# spaces to become trailing spaces after justification +# is complete. ##### def PadString(string, width, Rjust=False, Trailing=0): @@ -3919,8 +3926,8 @@ freespace, totalspace = ('0', '0') - freespace = PadString(freespace, SZ_DRIVE_FREE, Rjust=True) - totalspace = PadString(totalspace, SZ_DRIVE_TTL, Rjust=True) + freespace = PadString(freespace, SZ_DRIVE_FREE, Rjust=True, Trailing=SZ_TRAILING_SPACE) + totalspace = PadString(totalspace, SZ_DRIVE_TTL, Rjust=True, Trailing=SZ_TRAILING_SPACE) entry += "%s%s%s%s" % (freespace, WIN32FREE, totalspace, WIN32TOTAL) fields.append(fspace) @@ -4170,7 +4177,7 @@ rlen = stinfo[ST_SIZE] flen = FileLength(rlen) - details += PadString(flen, ST_SZLEN, Rjust=True, Trailing=4) + details += PadString(flen, ST_SZLEN, Rjust=True, Trailing=SZ_TRAILING_SPACE) fields.append(rlen) # mtime