-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpretty_print.jl
51 lines (42 loc) · 1.38 KB
/
pretty_print.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Pretty print. We just use CrystalInfoFramework's facilities
using CrystalInfoFramework,FilePaths, ArgParse
pretty(infile,outfile;refdic=nothing, expand=false) = begin
ignore = expand ? :Full : :All
i = DDLm_Dictionary(Cif(infile,native=true),ignore_imports=ignore)
o = open(outfile,"w")
# Capitalise
make_cats_uppercase!(i)
# Match capitalisation
if refdic != nothing
rr = DDLm_Dictionary(refdic)
conform_capitals!(i,rr)
end
show(o,MIME("text/cif"),i)
close(o)
end
parse_cmdline(d) = begin
s = ArgParseSettings(d)
@add_arg_table! s begin
"before"
help = "Input dictionary"
required = true
"after"
help = "File to write pretty-printed dictionary to"
required = true
"-r","--refdic"
help = "DDL reference dictionary. If absent, capitalisation will not be harmonised"
required = false
default = [nothing]
nargs = 1
"-e","--expand"
help = "Expand import templates"
nargs = 0
required = false
default = false
end
parse_args(s)
end
if abspath(PROGRAM_FILE) == @__FILE__
parsed_args = parse_cmdline("Pretty print DDLm dictionary to match DDLm style guide.")
pretty(Path(parsed_args["before"]), Path(parsed_args["after"]), refdic=parsed_args["refdic"][], expand = parsed_args["expand"])
end