-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmkcopying.py
More file actions
executable file
·62 lines (43 loc) · 1.14 KB
/
mkcopying.py
File metadata and controls
executable file
·62 lines (43 loc) · 1.14 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
#!/usr/bin/env python
# $Id: mkcopying.py,v 1.3 2000/10/04 20:35:25 paul Exp paul $
# Usage: give it the filenames of the LaTeX sheets.
import string
import re
import sys
NOTFOUND = -1
TitleMatcher = re.compile (r"^\\sheet{(.*?)}{(.*?)}")
CopyrightMatcher = re.compile (r"^\s*\\copyright{}\s*(.*)$")
def gettitle (infile):
while 1:
line = infile.readline ()
if line == "": break
m = TitleMatcher.match (line)
if m:
rawtitle = m.groups ()
title = string.join (rawtitle, ": ")
return title
def getcopyrights (infile):
rights = []
while 1:
line = infile.readline ()
if line == "": break
m = CopyrightMatcher.match (line)
if m:
rights.append(m.group (1))
return rights
if __name__ == '__main__':
copyrights={}
for fname in sys.argv [1:]:
file = open (fname, "r")
title = gettitle (file)
copyrights [title] = getcopyrights (file)
file.close ()
print "The copyright notices for each document in this distribution"
print "are as follows:\n"
keylist=copyrights.keys()
keylist.sort ()
for title in keylist:
print title
for copy in copyrights [title]:
print " Copyright " + copy
print ""