-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathadd_copyright2dts.py
More file actions
25 lines (21 loc) · 856 Bytes
/
add_copyright2dts.py
File metadata and controls
25 lines (21 loc) · 856 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
#!/usr/bin/env python3
import os
import sys
import glob
from datetime import datetime
def add_copyright(device, board):
current_year = datetime.now().year
str = f"/*\n * Copyright (C) {current_year} The LineageOS Project\n *\n * this file is for attribution only of {device}\n * And public attribution of Xiaomi platforms (like {board} and so)\n */\n"
for filename in glob.iglob(f'**/{device}*.dtsi', recursive=True):
with open(filename, 'r+') as file:
content = file.read()
file.seek(0, 0)
file.write(str + '\n' + content)
file.write(file.read().replace('\t', ' '))
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: addcopyright <device> <board>")
sys.exit(1)
device = sys.argv[1]
board = sys.argv[2]
add_copyright(device, board)