using Dates APFS = "155" # WBCount:APFS version = APFS include("../WBInclusions") global D = "D = Dict{String, Array{String}}(\n" pre = "\n\n\n\nImage inventory\n\n\n\n
\n" post = "\n

XXXX

\n

XYXY

\n

[ Ω W3C HTML validator ]

\n" global unhex = Dict( "0" => 0, "1" => 1, "2" => 2, "3" => 3, "4" => 4, "5" => 5, "6" => 6, "7" => 7, "8" => 8, "9" => 9, "a" => 10, "b" => 11, "c" => 12, "d" => 13, "e" => 14, "f" => 15 ) global ignoreds = [ "JUNK.html", "JUNK2.html" ] global DISTR = Dict(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0, 10 => 0, 11 => 0, 12 => 0, 13 => 0, 14 => 0, 15 => 0 ) global distr = [] for i = 1:256 push!(distr,0) end global tbl = Dict() global maxLen = -1 global ct = 0 global rejects = [] global dshit = [] global FirstImage = true global REPO = length(ARGS) > 0 && lowercase(ARGS[1]) == "repo" global TrivialImages = ["Next2a.gif", "Prev2a.gif", "Spacer.gif"] global trivials = 0 global Qsum = 0 global Q = "" global Biggies = [] function qwrite(txt) global Qsum += length(txt) #write(q, txt) global Q *= txt end for (root, dirs, files) in walkdir(".") #println("Directories in $root") #for dir in dirs # println(joinpath(root, dir)) # path to directories #end #println("Files in $root") for file in files x = joinpath(root, file) # path to files #if !contains(x, "images") if findfirst(r"^\.\\images\\([0-9a-f])\\\1[0-9a-f][\\]", x) == nothing if findfirst(r"^\.\\(css\\|txts\\|pdfs\\)", x) == nothing push!(rejects, x) end continue end # Create a directory with copies of all the image files if REPO tgt = "\\Robbie\\REPO\\" * x[15 : length(x)] try r = open(x,"r") rs = open(tgt, "w") write(rs, read(r)) close(r) close(rs) catch ex s = string(ex) if length(s) > 200 s = s[1:200] * "..." end println("\n REPO: ", tgt , ": ", typeof(ex), ".\n", s); end end y = length(x) z = x[15:y] zLen = length(z) if zLen > maxLen global maxLen = zLen end global tbl[z] = replace(x[1:14], r"[\\]" => "/") global ct += 1 if !(tbl[z] in dshit) push!(dshit, tbl[z]) end end end dt = string(Dates.now()) dtx = findfirst('T', dt) dtx = replace(dt[1: dtx - 1] * " " * dt[dtx + 1: length(dt)], r"\.[0-9]+" => "", count=1) global stuff = "

[WBCount v" * version * "]  " * pwd() * "   (--IMAGES--)  --S,Z--.
maxLen: " * string(maxLen) * ", count: " * string(ct) * ".  " * dtx * ".      Links   Dashboard\"Next2a.gif\"

" kk = keys(tbl) fuck = [] for k in kk # keys(tbl) push!(fuck, k) end fuck = sort(fuck, by=lowercase) global stuff *= "
" * "" for ks in fuck ww = tbl[ks] w = unhex[ww[12:12]] * 16 + unhex[ww[13:13]] + 1 distr[w] += 1 # # global stuff *= "" * tbl[ks][10:13] * "\n" global FirstImage = false # println(tbl[ks], " ",ks) global D *= " \"" * ks * "\" => [\"" * tbl[ks][10:10] * "\", \"" * tbl[ks][12:13] * "\"],\n" end for r in rejects if r in [".\\WBCount", ".\\WBCount1", ".\\WBKountOut.html", ".\\WBcompare", ".\\WBcompare1"] continue end println(" ", r) end println("\n-------") global ImageCache = Dict{String, Int32}() global ict = 0 global failures = [] cd("../") # This shit makes no sense to me, so I cheated. GODDAMNED RIGHT! try for (root, dirs, files) in walkdir("./w/") for file in files x = joinpath(root, file) # path to files if !contains(x, "images") continue end z = replace(x, "\\" => "/") global ImageCache[z[3 : length(z)]] = 0 sz = " " * string(stat("/Robbie/BO/" * z).size) sizesz = length(sz) push!(Biggies, sz[sizesz - 7:sizesz] * " " * z[17:length(z)]) global ict += 1 end end global errId = 1 a = readdir() global errId = 2 for itm in a if findfirst(".html", itm) == nothing || itm in ignoreds continue end global item = itm f = open(item) global errId = 4 src = read(f) global errId = 5 close(f) txt = String(src) images = findall(r" (src|href)=\"[^\"]+", txt) for i = 1 : length(images) str0 = txt[images[i]] if !contains(str0, "/w/images/") if length(str0) >= 10 && str0[1:10] == " href=\"w/i" str0 = replace(str0, " href=\"" => " href=\"./", count = 1) elseif length(str0) >= 9 && str0[1:9] == " src=\"w/i" str0 = replace(str0, " src=\"" => " src=\"./", count = 1) else continue end end str1 = replace(str0, "%27" => "'") off = findfirst("\"", str0) str = str1[(off[1] + 3):length(str1)] if haskey(ImageCache, str) global ImageCache[str] += 1 elseif !isfile(str) strd = "./" * str[1:13] if !isdir(strd) mkdir(strd) println(" ", strd) end println("?MISSING: ", str) else println("?GODKNOWSWHAT: ", str) end end end catch ex s = string(ex) if length(s) > 200 s = s[1:200] * "..." end println("\n Failure: ", typeof(ex), ".\n", s); #exit(16) push!(failures, item) return 0 end global unused = "" global unusedPfx = "" global Uct = 0 ks = keys(ImageCache) global ReverseImages = Dict{Int32, Array{String}}() global bigsum = 0 global ones = 0 for k in ks if ImageCache[k] == 0 global unused *= unusedPfx * "\"" * k * "\"" global unusedPfx = ", " global Uct += 1 else kn = ImageCache[k] kkX = k[15:length(k)] if k[15:length(k)] in TrivialImages global trivials += ImageCache[k] end global stuff = replace(stuff, "--" * kkX * "--" => string(kn), count=1) global bigsum += kn if kn == 1 global ones += 1 end if !(kkX in ["Prev2a.gif", "Next2a.gif", "Spacer.gif", "HTML5V.png", "GarbageCan.gif", "K2.gif", "Buttocks.jpg", "United_states.gif", "WDSG.gif"]) if haskey(ReverseImages, kn) push!(ReverseImages[kn], kkX) # ReverseImages[kn] *= ", " * "\"" * kkX * "\"" else global ReverseImages[kn] = [kkX] # "\"" * kkX * "\"" end end end end print("Going to save ./WBKountOut.html : (" * pwd() * ")\n") global q = open("w/WBKountOut.html", "w") qwrite(pre) sbs = formatNumber(bigsum) consequentials = formatNumber(bigsum - trivials) stuff = replace(stuff, "--IMAGES--" => "Celibates: " * string(ones), count=1) stuff = replace(stuff, r"" => "") qt = stuff * "
" * "" * "QQsbsQQ" * "
" * ks * "--" * ks * "--
--[^>]+**
" * "" * formatNumber(length(ImageCache)) * "  Σ+ " * sbs * "
" fuckedup = replace(qt, "QQsbsQQ" => formatNumber(length(ImageCache) - length(TrivialImages)) * "  Σ- " * consequentials, count = 1) qwrite(fuckedup) global shit = [] for x in keys(ReverseImages) push!(shit, x) end shitx = sort(shit, rev=true) global nuthin = "[nuthin]" println(" ") for i = 1 : length(shitx) sq = shitx[i] if sq < 8 continue end z = "" zzz = sort(ReverseImages[sq]) for zz in zzz # ReverseImages[sq] if length(z) > 0 z *= ", " end z *= "\"" * zz * "\"" end s = string(sq) u = "(" * string(length(ReverseImages[sq])) * ") " println(" " ^ (6 - length(s)) * s, " ", u[1:6], z) global nuthin = "" end if length(unused) > 0 print("\n Unused: " * unused * " (" * string(Uct) * ")\n\n") qwrite("

" * replace(replace(unused, "w/images/" => ""), " " => "  ") * "

") end qwrite(post) global q = open("w/WBKountOut.html", "w") Q = replace(Q, "NancyTheBitch.jpg" => "NancyTheBitch.jpg (~Melva)", count=1) Q = replace(Q, "FirstSteps.jpg" => "FirstSteps.jpg (Modified)", count=1) Q = replace(Q, "Giphy.gif" => "Giphy.gif (Animated)", count=1) sQsum = string(Qsum) sQsum = sQsum[1:3] * "," * sQsum[4:6] #write(q, replace(Q, "--S,Z--" => "" * sQsum * "", count = 1)) #close(q) println("./WBKountOut.html saved: " * sQsum * " " * APtS_ET) if nuthin != "" println(" " * nuthin) end global shi = [] for s = 1:20 append!(shi,0) end global crap = "" global crap_HTML = "" for i = 1 : length(distr) if i % 64 == 1 global crap *= "\n " global crap_HTML *= "
" end distri = distr[i] global shi[distri + 1] += 1 global crap *= HILITE_TOHEX[distri] DISTR[distri] += 1 if distri == 0 global crap_HTML *= "." elseif distri < 10 global crap_HTML *= string(distri) else global crap_HTML *= "" * "ABCDEF"[distri-9:distri-9] * "" end end global mulch = 0 for i = 1: length(shi) global mulch += (i - 1) * shi[i] if shi[i] != 0 global shi[i] = [i - 1, shi[i], mulch] end end for i = 1 : length(shi) if shi[length(shi)] != 0 break end global shi = copy(shi)[1:length(shi) - 1] end global shidt = 0 global shid = [] for i = 2 : length(shi) if shi[i] == 0 append!(shid, 0) continue end sh = shi[i][2] # * (i - 1) append!(shid, sh) # - shi[i - 1][3]) global shidt += sh end tots = [] for itm in shi push!(tots, itm[3]) end #SHID = open("w/SHID", "w") #write(SHID, "global SHID = " * string(tots)) #close(SHID) global shidd = [] global dnom = shi[length(shi)][3] for i = 1 : length(shi) push!(shidd, replace(string((shi[i][3]/dnom) * 100 + 0.005) * "0000", r"\.([0-9]{2})[0-9]+" => s".\1") * "%") end println(crap, "\n\n", shi, " ", shidt, "\n\n", replace(string(shidd), "\"" => ""), " " * string(length(shidd) - 1)) global distrBars = "" for i = 0 : 11 si = " " * string(i) lensi = length(si) si = replace(si[lensi - 2 : lensi], " " => " ") global distrBars *= si * " " * ("*" ^ DISTR[i]) * "
" end Q = replace(Q, "XXXX" => crap_HTML) Q = replace(Q, "XYXY" => distrBars) write(q, replace(Q, "--S,Z--" => "" * sQsum * "", count = 1)) close(q) global D *= ")\n\nglobal DICT_VERSION = \"WBCount v" * version * " (D:001).\"\n\n" global D *= "global MISSING = [\"MISSING_1\", \"MISSING_2\"]\n\n" global D *= "function pushD(ky, itm)\n" global D *= " r = get!(D, ky, MISSING)\n" global D *= " if r == MISSING\n" global D *= " return(r)\n" global D *= " end\n" global D *= " return(push!(r, itm))\n" global D *= "end\n\n" global D *= "function appendD(ky, itm...)\n" global D *= " r = get!(D, ky, MISSING)\n" global D *= " if r == MISSING\n" global D *= " return(r)\n" global D *= " end\n" global D *= " return(append!(r, itm...))\n" global D *= "end\n\n" global D *= "function getD(ky, ksub)\n" global D *= " a = get!(D, ky, MISSING)\n" global D *= " if a == MISSING\n" global D *= " return(MISSING)\n" global D *= " end\n" global D *= " if ksub > length(a) || ksub < 1\n" global D *= " return(MISSING)\n" global D *= " end\n" global D *= " return a[ksub]\n" global D *= "end\n\n" global D *= "function getD(ky)\n" global D *= " return(get!(D, ky, MISSING))\n" global D *= "end\n\n" global D *= "global DCOLOR1 = HI_RED * \"****** \"\n" global D *= "global DCOLOR2 = HI_END\n" global D *= "function addD(ky, val)\n" global D *= " if typeof(val) != Vector{String} || length(val) != 2 || typeof(val[1]) != String ||\n" global D *= " typeof(val[2]) != String\n" global D *= " throw(ArgumentError(DCOLOR1 * \"Bad argument: \" * string(val) * DCOLOR2))\n" global D *= " end\n" global D *= " if typeof(ky) != String\n" global D *= " throw(ArgumentError(DCOLOR1 * \"Bad key: \" * string(ky) * DCOLOR2))\n" global D *= " end\n" global D *= " if getD(ky) != MISSING\n" global D *= " throw(ArgumentError(DCOLOR1 * \"Exists: \" * string(ky) * DCOLOR2))\n" global D *= " end\n" global D *= " D[ky] = val\n" global D *= " return(D[ky])\n" global D *= "end\n" d = pwd() * "\\w\\DICT" a = open(d, "w") write(a, D) close(a) a = open("w/BIG", "w") b = sort(Biggies, rev=true)[1:24] for c in b write(a, c * "\n") end close(a)