-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path00 Retrieve metadata headers.applescript
More file actions
103 lines (84 loc) · 2.53 KB
/
00 Retrieve metadata headers.applescript
File metadata and controls
103 lines (84 loc) · 2.53 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
-- @description Import scripts to cues
-- @author Ben Smith
-- @link bensmithsound.uk
-- @version 1.2
-- @about Module to retrieve metadata headers
property util : script "Applescript Utilities"
global headerOptions, lineUndefined
set headerOptions to {¬
"Description", ¬
"Author", ¬
"Link", ¬
"Version", ¬
"Changelog", ¬
"About", ¬
"Tested MacOS", ¬
"Tested Qlab", ¬
"Separate Process"}
on retrieveHeaders(theScript)
set theScriptContents to paragraphs of (read theScript)
set indentLevel to 0
set scriptContents to ""
log "--------"
repeat with eachLine in theScriptContents
-- get tags
repeat with eachOption in headerOptions
set eachOptionNoSpace to util's splitString(eachOption, " ")
if eachOption is in eachLine then
try
log eachOption & ": " & item 2 of util's splitString(eachLine, eachOption & " ")
on error
multilineHeader(theScript, eachOption)
end try
else if (eachOptionNoSpace as string) is in eachLine then
try
log eachOption & ": " & item 2 of util's splitString(eachLine, (eachOptionNoSpace as string) & " ")
on error
multilineHeader(theScript, eachOptionNoSpace)
end try
end if
end repeat
end repeat
end retrieveHeaders
on multilineHeader(theScript, theHeader)
set theScriptContents to paragraphs of (read theScript)
set inTheHeader to false
set theHeaderContents to ""
global testVar
repeat with eachLine in theScriptContents
if eachLine is "" then
set inTheHeader to false
log "2 " & eachLine
else if theHeader is in eachLine then
set inTheHeader to true
log "1 " & eachLine
else if inTheHeader is true then
set theHeaderContents to theHeaderContents & util's trimLine(eachLine, "-- ", 0) & "
"
log "3 " & eachLine
set testVar to eachLine
end if
(*repeat with eachOption in headerOptions
if theHeader is in eachLine then
set inTheHeader to true
else if eachOption is in eachLine then
set inTheHeader to false
else if (util's splitString(eachOption, " ") as string) is in eachLine then
set inTheHeader to false
else if eachLine is "" then
set inTheHeader to false
else if inTheHeader is true then
set theHeaderContents to theHeaderContents & "
" & util's trimLine(eachLine, "-- ", 0)
end if
end repeat*)
end repeat
global aGlobalVar
set aGlobalVar to theHeaderContents
end multilineHeader
-- BUG HERE currently doesn't stop at blank lines, can't stop it.
on findHeaders(theScript)
end findHeaders
log headerOptions
set scriptFile to choose file
retrieveHeaders(scriptFile)