mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-22 19:39:22 +00:00
feat: add copyright generating script
This commit is contained in:
parent
71a570d286
commit
29e19e3d46
1 changed files with 51 additions and 0 deletions
51
scripts/doc/copyright.py
Normal file
51
scripts/doc/copyright.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
import os
|
||||
|
||||
path = "../../lib"
|
||||
|
||||
ignore = [".g.dart", "LICENSE", "external_api_keys.dart"]
|
||||
|
||||
# To update the header, only change the variable below
|
||||
|
||||
header = """
|
||||
/*
|
||||
* This file is part of Stack Wallet.
|
||||
*
|
||||
* Copyright (c) 2023 Cypher Stack
|
||||
* All Rights Reserved.
|
||||
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
||||
* Generated by Cypher Stack on 2023-05-26
|
||||
*
|
||||
*/
|
||||
"""
|
||||
|
||||
def add_text_to_files(folder_path, text, ignored_extensions=[]):
|
||||
should_ignore = False
|
||||
for root, dirs, files in os.walk(folder_path):
|
||||
for filename in files:
|
||||
file_path = os.path.join(root, filename)
|
||||
should_ignore = False
|
||||
for ignored_extension in ignored_extensions:
|
||||
if file_path.endswith(ignored_extension):
|
||||
should_ignore = True
|
||||
break
|
||||
if not should_ignore:
|
||||
with open(file_path, 'r') as file:
|
||||
lines = file.readlines()
|
||||
if len(lines) >= 4:
|
||||
second_line = lines[1]
|
||||
third_line = lines[2]
|
||||
fourth_line = lines[3]
|
||||
if second_line.startswith("/*") and third_line.startswith(" *") and fourth_line.startswith(" *"):
|
||||
with open(file_path, 'w') as file:
|
||||
file.seek(0, 0)
|
||||
file.write(text + ''.join(lines[10:]))
|
||||
else:
|
||||
with open(file_path, 'w') as file:
|
||||
file.seek(0, 0)
|
||||
file.write(text + '\n' + ''.join(lines))
|
||||
else:
|
||||
with open(file_path, 'w') as file:
|
||||
file.seek(0, 0) # Move the file cursor to the start
|
||||
file.write(text + '\n' + ''.join(lines))
|
||||
|
||||
add_text_to_files(path, header, ignore)
|
Loading…
Reference in a new issue