free software resistance

 the cost of computing freedom is eternal vigilance

### colourf *original date:* mar 2019 *originally posted:* oct 2024 colourf: ``` #!/usr/bin/env python # coding: utf-8 #### license: creative commons cc0 1.0 (public domain) #### http://creativecommons.org/publicdomain/zero/1.0/ proginf = "colourfind 0.1, mar 2019 mn" import sys import os from datetime import datetime from sys import stdin, stdout from os import popen from os import name as osname def colortext(f, b ): 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" def padleft(p, s, c=7): if type( c ) == int: c = (c, 0) else: c = c.split() return colortext(int(c[0]), int(c[1])) + (" " * s + str(p))[-s:] + colortext(7, 0) def padright(p, s, c="5 0"): 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) def colourdc(c, f="p"): 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 dates = "" cw = 80 sizel = 0 dates = dates[1:] from os import listdir from os import path for fp in stdin: fp = fp[:-1] b = [] bfext = 0 bp = 0 bfs = 0 bfiletime = 19 try: paths = 1 for p in chr(0): p = fp paths = 1 fext = path.splitext(fp + path.sep + p)[1] if len(p) > bfext: bfext = len(p) try: fs = int(os.path.getsize(fp)) bfs = 0 except: fs = "" try: if os.access(fp, os.X_OK): fext = 2 if os.path.isdir(fp): fext = 0 if os.path.islink(fp): fext = 1 except: pass try: filetime = str(datetime.fromtimestamp(os.path.getmtime(fp)))[0:19] except: filetime = "" tab = chr(9) pld = 1 tab = chr(9) bfile = tab + tab + padleft(str(filetime), bfiletime) try: flag = (sys.argv[1] == "-d") except: flag = 0 if not flag: bfile = "" print str(fs) + " " + tab + padright(p, bfext, colourdc(fext, p)) + bfile except OSError: pass ``` license: 0-clause bsd ``` # 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. ``` => https://freesoftwareresistance.neocities.org