Created
November 26, 2017 13:30
-
-
Save SimonDanisch/6f1b7097fde57272ca96c2e01355c37e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function find_jl_files(dir, files = String[]) | |
for file in readdir(dir) | |
path = joinpath(dir, file) | |
if endswith(path, ".jl") | |
push!(files, path) | |
elseif isdir(path) | |
find_jl_files(path, files) | |
end | |
end | |
files | |
end | |
function count_lines(file) | |
str = readstring(file) | |
str = replace(str, r"#=.*=#"m, "") | |
str = replace(str, r"#.*\n", "") | |
lines = split(str, "\n") | |
lines = filter(x->!isempty(x), lines) | |
length(lines) | |
end | |
function recursive_loc(pkg, reclevel = typemax(Int), visited = Set(String[]); excludes = ()) | |
result = mapreduce(count_lines, +, find_jl_files(Pkg.dir(pkg, "src"))) | |
println(pkg, ": ", result) | |
require = readstring(Pkg.dir(pkg, "REQUIRE")) | |
deps = matchall(r"[a-zA-Z_]+", require) | |
if reclevel > 0 | |
for dep in deps | |
if isdir(Pkg.dir(dep)) && !(dep in excludes) && !(dep in visited) | |
push!(visited, dep) | |
depnum, visited = recursive_loc(dep, reclevel - 1, visited, excludes = excludes) | |
result += depnum | |
end | |
end | |
end | |
result, visited | |
end | |
excludes = ( | |
"Images", | |
"Interact", | |
"Hiccup", | |
"Media", | |
"Juno", | |
"BinDeps", | |
"AxisArrays", | |
"IndirectArrays", | |
"ImageAxes", | |
"DualNumbers", | |
"IterTools", | |
"Reexport", | |
"SpecialFunctions", | |
"JSON", | |
"ColorBrewer", | |
"Compat", | |
"DataStructures", | |
"StatsBase", | |
"Contour" | |
) | |
# recursive_loc("Mads") | |
recursive_loc("Makie", excludes = excludes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment