-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomAnalyzers.jl
35 lines (27 loc) · 1.07 KB
/
CustomAnalyzers.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import ..FileSorterData: FileSort, DirSort, Analyzer, Analyzation, pre, pos, analyze, fullpath
import Base.Filesystem: StatStruct
struct DepthAnalyzer <: Analyzer
currentDepth::Vector{Int}
end
struct DepthAnalyzation <: Analyzation
depth::Int
end
analyze(analyzer::DepthAnalyzer, file::FileSort) = push!(file.analyzations, DepthAnalyzation(analyzer.currentDepth[end]))
pre(analyzer::DepthAnalyzer, ::DirSort) = push!(analyzer.currentDepth, analyzer.currentDepth[end] + 1)
pos(analyzer::DepthAnalyzer, ::DirSort) = pop!(analyzer.currentDepth)
struct TypeAnalyzer <: Analyzer end
struct TypeAnalyzation <: Analyzation
type::String
end
function analyze(::TypeAnalyzer, file::FileSort)
if !occursin(".", file.name)
push!(file.analyzations, TypeAnalyzation("none"))
return
end
push!(file.analyzations, TypeAnalyzation(split(file.name, ".")[end]))
end
struct StatAnalyzer <: Analyzer end
struct StatAnalyzation <: Analyzation
stats::StatStruct
end
analyze(::StatAnalyzer, file::FileSort) = push!(file.analyzations, StatAnalyzation(stat(fullpath(file))))