-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgen_course_struct.awk
More file actions
executable file
·39 lines (31 loc) · 966 Bytes
/
gen_course_struct.awk
File metadata and controls
executable file
·39 lines (31 loc) · 966 Bytes
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
#!/usr/bin/awk -f
# This program generates the ptml files for a new course.
# It reads stdin for the course section names.
BEGIN {
FS = "^"
TEMPLATE = "./utils/templates/template.ptml"
CREATE = "./utils/create_page.py"
}
/^$/ { } # blank lines allowed
/^\;/ { } # allows comments in the input
/^\t\t| / { # this is a bottom-level section
title = $1
print title
print $2
new_file = $2
new_file = sub(/html/, "ptml", new_file) # change the extension
print new_file
new_file = "html_src/" new_file
if (system( "[ -f " new_file " ] ") == 0)
print new_file " already exists."
else {
print "We are going to add " new_file
if (system(CREATE " <" TEMPLATE " >" new_file " " title) != 0) {
print "Could not create " new_file
}
}
}
/^\t[^\t]/ { # major section name: no file for now
}
/^[^\t ]/ { # major section name: no file for now
}