|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- This file:
-- http://anggtwu.net/LUA/LsQuadros1.lua.html
-- http://anggtwu.net/LUA/LsQuadros1.lua
-- (find-angg "LUA/LsQuadros1.lua")
-- Author: Eduardo Ochs <eduardoochs@gmail.com>
--
-- (defun e () (interactive) (find-angg "LUA/LsQuadros1.lua"))
-- Supersedes:
-- (find-angg "LUA/Caepro1.lua" "Quadros")
-- (find-angg "LUA/Caepro1.lua" "Semestre")
-- (find-angg "LUA/Caepro1.lua" "Sems-tests")
-- «.VList» (to "VList")
-- «.VList-tests» (to "VList-tests")
-- «.LsQuadros» (to "LsQuadros")
-- «.LsQuadros-tests» (to "LsQuadros-tests")
-- «.AllQuadros» (to "AllQuadros")
-- «.AllQuadros-tests» (to "AllQuadros-tests")
-- «.LsQuadros1-cache.lua» (to "LsQuadros1-cache.lua")
-- Based on: (find-angg "LUA/lua50init.lua" "mytostring")
mytostringm = function (o)
local mt = getmetatable(o)
if mt and mt.__tostring then return tostring(o) end
return mytostring(o)
end
-- __ ___ _ _
-- \ \ / / | (_)___| |_
-- \ \ / /| | | / __| __|
-- \ V / | |___| \__ \ |_
-- \_/ |_____|_|___/\__|
--
-- «VList» (to ".VList")
-- Also here: (find-angg "LUA/lua50init.lua" "VList")
VList = Class {
type = "VList",
__tostring = function (vl) return vl:tostring() end,
__index = {
tostring0 = function (vl) return mapconcat(mytostringm, vl, ',\n ') end,
tostring = function (vl) return "VList{\n "..vl:tostring0().."\n}" end,
},
}
-- «VList-tests» (to ".VList-tests")
--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "LsQuadros1.lua"
v = VList {2, 3.45, "foo"}
= v
= v:tostring()
--]]
-- _ ___ _
-- | | ___ / _ \ _ _ __ _ __| |_ __ ___ ___
-- | | / __| | | | | | |/ _` |/ _` | '__/ _ \/ __|
-- | |___\__ \ |_| | |_| | (_| | (_| | | | (_) \__ \
-- |_____|___/\__\_\\__,_|\__,_|\__,_|_| \___/|___/
--
-- «LsQuadros» (to ".LsQuadros")
LsQuadros = Class {
type = "LsQuadros",
from = function (dir) return LsQuadros {dir=dir} end,
__tostring = function (lsq) return lsq:tostring() end,
__index = {
cmd = function (lsq) return format("cd ~/%s/; ls *.jpg", lsq.dir) end,
run0 = function (lsq) return getoutput(lsq:cmd()) end,
run = function (lsq) return VList(split((lsq:run0():gsub(".jpg", "")))) end,
read = function (lsq) lsq.stems = lsq:run(); return lsq end,
tostring = function (lsq)
local fmt = 'LsQuadros {dir="%s", stems=%s}'
return format(fmt, lsq.dir, tostring(lsq.stems))
end,
},
}
-- «LsQuadros-tests» (to ".LsQuadros-tests")
--[==[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "LsQuadros1.lua"
lsq = LsQuadros.from "2022.1-C2"
= lsq
= lsq:run()
= lsq:read()
= lsq
--]==]
-- _ _ _ ___ _
-- / \ | | |/ _ \ _ _ __ _ __| |_ __ ___ ___
-- / _ \ | | | | | | | | |/ _` |/ _` | '__/ _ \/ __|
-- / ___ \| | | |_| | |_| | (_| | (_| | | | (_) \__ \
-- /_/ \_\_|_|\__\_\\__,_|\__,_|\__,_|_| \___/|___/
--
-- «AllQuadros» (to ".AllQuadros")
AllQuadros = Class {
type = "AllQuadros",
__index = {
read = function (aq, dirs, verbose)
aq.list = VList {}
for _,dir in ipairs(dirs) do
if verbose then print(dir) end
table.insert(aq.list, LsQuadros.from(dir):read())
end
return aq
end,
writefile = function (aq, fname)
local prefix = "-- Generated by LsQuadros1.lua\nreturn "
ee_writefile(fname, prefix..tostring(aq.list))
end,
},
}
AllQuadros.dirs = VList(split [[
2019.1-C2 2019.1-C3
2019.2-C2 2019.2-C3
2022.1-C2 2022.1-C3
2022.2-C2 2022.2-C3
2022.2-C2 2022.2-C3
]])
-- «AllQuadros-tests» (to ".AllQuadros-tests")
-- «LsQuadros1-cache.lua» (to ".LsQuadros1-cache.lua")
--[==[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "LsQuadros1.lua"
aq = AllQuadros {}
= AllQuadros.dirs
aq:read(AllQuadros.dirs, "verbose")
= aq
= aq.list
* (find-sh0 "rm -fv LsQuadros1-cache.lua")
aq:writefile "LsQuadros1-cache.lua"
** (find-fline "LsQuadros1-cache.lua")
aq = AllQuadros {}
aq.list = require "LsQuadros1-cache"
aq.list = dofile "LsQuadros1-cache.lua"
= aq.list
--]==]
--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
require "LsQuadros1"
require "LsQuadros1-cache"
aq = AllQuadros {}
aq.list = require "LsQuadros1-cache"
= aq.list
--]]
-- Local Variables:
-- coding: utf-8-unix
-- End: