Skip to content

Commit 635f868

Browse files
committed
Update copyright headers.
1 parent e8b32a3 commit 635f868

File tree

6 files changed

+70
-0
lines changed

6 files changed

+70
-0
lines changed

.scripts/copyright_text.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Kiebitz - Privacy-Friendly Appointments
2+
Copyright (C) 2021-{year} The Kiebitz Authors
3+
README.md contains license information.

.scripts/make_copyright_headers.py

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import datetime
2+
import os
3+
4+
script_dir = os.path.dirname(os.path.abspath(__file__))
5+
source_dirs = [os.path.join(os.path.dirname(script_dir), 'src')]
6+
context = {}
7+
8+
def read_copyright():
9+
with open(os.path.join(script_dir,'copyright_text.txt')) as input_file:
10+
return input_file.read().strip()
11+
12+
def format_copyright(text):
13+
c = context.copy()
14+
c['year'] = datetime.datetime.now().year
15+
return "\n".join([("// "+ t).strip() for t in text.format(**c).split("\n")])
16+
17+
def process_file(path, copyright_notice):
18+
with open(path) as input:
19+
content = input.read()
20+
lines = content.split("\n")
21+
for line in lines:
22+
if line.strip() == "// no-copyright-header":
23+
return
24+
for i, line in enumerate(lines):
25+
if not line.startswith('//'):
26+
break
27+
if lines[i].strip() == '':
28+
i+=1
29+
lines = lines[i:]
30+
new_content = copyright_notice+"\n\n"+"\n".join(lines)
31+
print("Writing {}".format(path))
32+
with open(path, 'w') as output:
33+
output.write(new_content)
34+
35+
36+
def enumerate_files(dir, extensions=['.go', '.js', '.jsx', '.ts', '.tsx'], exclude=set(['node_modules'])):
37+
for file in os.listdir(dir):
38+
path = os.path.join(dir, file)
39+
if file.startswith('.'):
40+
continue
41+
if os.path.isdir(path) and file not in exclude:
42+
for path in enumerate_files(path):
43+
yield path
44+
else:
45+
for extension in extensions:
46+
if file.endswith(extension):
47+
yield path
48+
if __name__ == '__main__':
49+
copyright_notice = format_copyright(read_copyright())
50+
for source_dir in source_dirs:
51+
for path in enumerate_files(source_dir):
52+
process_file(path, copyright_notice)

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
copyright:
2+
python .scripts/make_copyright_headers.py
3+
14
prettier:
25
npx prettier --write .
36

src/crypto/derive.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Kiebitz - Privacy-Friendly Appointments
2+
// Copyright (C) 2021-2021 The Kiebitz Authors
3+
// README.md contains license information.
4+
15
import { equal } from "assert"
26
import { randomBytes, deriveSecrets } from "./"
37
import { b642buf } from "../helpers/conversion"

src/crypto/interfaces.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Kiebitz - Privacy-Friendly Appointments
2+
// Copyright (C) 2021-2021 The Kiebitz Authors
3+
// README.md contains license information.
4+
15
export interface KeyPair {
26
publicKey: string
37
privateKey: JsonWebKey

src/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
// Kiebitz - Privacy-Friendly Appointments
2+
// Copyright (C) 2021-2021 The Kiebitz Authors
3+
// README.md contains license information.
4+
15
export { b642buf } from "./helpers/conversion"
26
export { deriveSecrets, randomBytes } from "./crypto"

0 commit comments

Comments
 (0)