File: format-license

package info (click to toggle)
stellarium 25.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,307,224 kB
  • sloc: ansic: 317,377; cpp: 214,435; xml: 48,592; javascript: 26,073; python: 2,113; perl: 734; sh: 247; makefile: 192; pascal: 169
file content (40 lines) | stat: -rwxr-xr-x 1,030 bytes parent folder | download | duplicates (8)
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
#!/usr/bin/env python
# this small utility takes 'README' file from stellarium
# and formats it properly for 'copyright' file in debian directory

from os.path import join, abspath, dirname
import sys

this = dirname(abspath(__file__))
readme = join(this, '..', 'README')

lines = open(readme, 'rb').readlines()

matches = [ (i, l) for i, l in enumerate(lines) if l.startswith('8. FULL REFERENCES') ]
assert len(matches) == 1

lineno, _ = matches[0]

license = []
for line in lines[lineno-1:]:
    line = line.rstrip()
    if line == '': # empty lines
        license.append(' .')
    else:
        license.append('    %s' % line.replace('\t', '    '))

# now find the proper place to inject this

copyright = open('copyright', 'rb').readlines()
copyright = [ l.rstrip() for l in copyright ]
matches = [ (i, l) for i, l in enumerate(copyright) if '8. FULL REFERENCES' in l ]
lineno, _ = matches[0]
copyright = copyright[:lineno-1]

final = copyright + license

open('copyright', 'wb').write('\n'.join(final))


# print copyright