digital literacy for everyone
[lit][generate-title]
[lit]
[fig]
# 2019 mn
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
proginf = "colourfind.fig 0.1, mar 2019 mn"
python
from datetime import datetime
from os import listdir, path
fig
function colortext(f, b ):
python
if f == None: f = 0
if b == None: b = 0
n = "0"
if f > 7: n = "1" ; f = f - 8
if f == 1: f = 4 ## switch ansi colours for qb colours
elif f == 4: f = 1 ## 1 = blue not red, 4 = red not blue, etc.
if f == 3: f = 6
elif f == 6: f = 3
if b > 7: b = b - 8
if b == 1: b = 4
elif b == 4: b = 1
if b == 3: b = 6
elif b == 6: b = 3
return "\x1b[" + n + ";" + str(30+f) + ";" + str(40+ b ) + "m"
fig
fig
function padright(p, s, c):
python
if type( c ) == int:
c = (c, 0)
else:
c = c.split()
return colortext(int(c[0]), int(c[1])) + (str(p) + " " * s)[:s] + colortext(7, 0)
fig
fig
function colourdc(c, f)
python
if type( c ) != int: c = c.lower()
if c in [0, "0"]:
return "9 0"
cb = "0"
if len(f.split()) > 1:
cb = "1"
if c in [2, ".bat", ".com", ".exe"]:
return "10 " + cb
if c in [1, ".lnk"]:
return "11 " + cb
if c in [".tgz", ".tar.gz", ".gz", ".zip", ".7z"]:
return "4 " + cb
if c in [".fig", ".alex", ".py", ".fig.py", ".rose"]:
return "2 " + cb
if c in [".ogg", ".mp4", ".mpeg", ".mpg", ".mp3", ".webm", ".odt", ".odp", ".pdf"]:
return "3 " + cb
if c in ["."]:
return "8 " + cb
if c in [".jpg", ".jpeg", ".gif", ".bmp", ".pbm", ".pgm", ".ppm", ".tga", ".xbm",
".xpm", ".tif", ".tiff", ".png", ".svg", ".svgz", ".mng", ".pcx", ".mov", ".mpg",
".mpeg", ".m2v", ".mkv", ".ogm", ".m4v", ".mp4v", ".vob", ".flc", ".avi", ".fli",
".flv", ".gl", ".dl", ".xcf", ".xwd", ".yuv", ".cgm", ".emf", ".ogv"]:
return "13 " + cb
if c in [".htm", ".html", ".txt", ".js", ".php"]:
return "14 " + cb
return "7 " + cb
fig
fig
each arrstdin
forin fp each
b arr mid 1 0
bfext = 0
python
fext = path.splitext(fp)[1]
fig
bfext = fp len
try
python
fs = int(os.path.getsize(fp))
fig
except
fs ""
resume
try
python
if os.access(fp, os.X_OK):
fext = 2
if os.path.isdir(fp):
fext = 0
if os.path.islink(fp):
fext = 1
fig
except
pass
resume
try
python
filetime = str(datetime.fromtimestamp(os.path.getmtime(fp)))[0:19]
fig
except
filetime = ""
resume
tab = 9 chr
pld = 1
flag command mid 1 1
ifequal flag "-d"
flag
else
filetime = ""
fig
now fs str plus " " plus tab prints
dc colourdc fext fp
now padright(fp, bfext, dc) prints
iftrue filetime
now tab prints prints
now filetime print
else
now "" print
fig
next
fig main page: [url]https://freesoftwareresistance.neocities.org/fig/index.html[url]
home: [lit]https://freesoftwareresistance.neocities.org[lit]