Skip to content

Commit

Permalink
WIP: show(::Bloberias)
Browse files Browse the repository at this point in the history
  • Loading branch information
josePereiro committed Dec 17, 2024
1 parent b222d0c commit 540994a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
6 changes: 2 additions & 4 deletions src/0.Base/0_types.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#TODO: check https://docs.julialang.org/en/v1/base/collections/#Dictionaries for cool Dictlike datatypes

## .-- . -. - .--..- -- .- - --..-.-.- .- -.--
# The base object
abstract type BlobyObj end
Expand All @@ -6,10 +8,6 @@ abstract type BlobyObj end
# - It can run on top of a Bloberia

## .-- . -. - .--..- -- .- - --..-.-.- .- -.--
# Data types
# const BLOB_BFRAMES_TYPE = OrderedDict{String, FRAME_TYPE}
# const BB_DFRAMES_TYPE = OrderedDict{String, FRAME_TYPE}

const TEMP_DEPOT_TYPE = OrderedDict{String, Any}

const bUUIDS_DEPOT_TYPE = OrderedSet{UInt128}
Expand Down
19 changes: 13 additions & 6 deletions src/4.BloberiaBase/show.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
## --.--. - .-. .- .--.-.- .- .---- ... . .-.-.-.-
function _prefix_0x(dir)
_prefset = Dict{String, Int}()
function _prefix_0x_summary(dir)
_prefset = Dict{String, Dict}()
for name in readdir(dir)
pref = first(split(name, ".0x"))
get!(_prefset, pref, 0)
_prefset[pref] += 1
_dat = get!(_prefset, pref, Dict())
get!(_dat, "count", 0)
_dat["count"] += 1
get!(_dat, "disk", 0.0)
_dat["disk"] += _recursive_filesize(joinpath(dir, name))
end
_prefset
end
Expand Down Expand Up @@ -35,15 +38,19 @@ function Base.show(io::IO, B::Bloberia)
)

if _isdir
_prefixhist = _prefix_0x(B.root)
_prefixhist = _prefix_0x_summary(B.root)
_prefixs = collect(keys(_prefixhist)) |> sort!
print(io, "\n x0 prefixes: \n")
for prex in _prefixs
meta = _prefixhist[prex]
print(io, " ")
printstyled(io, prex; color = :normal)
printstyled(io, " ["; color = :normal)
printstyled(io, _prefixhist[prex]; color = :blue)
printstyled(io, meta["count"]; color = :blue)
printstyled(io, " folder(s)"; color = :blue)
printstyled(io, " "; color = :blue)
val, unit = _canonical_bytes(meta["disk"])
printstyled(io, string(round(val; digits = 3), " ", unit); color = :blue)
printstyled(io, "]"; color = :normal)
println(io)
end
Expand Down

0 comments on commit 540994a

Please sign in to comment.