forked from github/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpropagate_authorship.py
More file actions
29 lines (24 loc) · 1 KB
/
Copy pathpropagate_authorship.py
File metadata and controls
29 lines (24 loc) · 1 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
import os, datetime
AUTH_BLOCK = f"""
Digital Crystal Protocol — Authorship Propagation
Author: Donald Paul Smith aka FatherTimeSDKP
ORCID: 0009-0003-7925-1653
DOI(s): 10.17605/OSF.IO/DJA9G | 10.17605/OSF.IO/XMTQC | 10.17605/OSF.IO/E7GWN | 10.17605/OSF.IO/CM7WQ
Signature: FTSDKP::DPS::Kapnack::QCC::Crystal.v1
Timestamp: {datetime.datetime.utcnow().isoformat()}Z
License: Sovereign Substrate License v1.0 (immutable authorship, mandatory citation)
"""
EXTENSIONS = [".py", ".md", ".txt", ".json", ".csv"]
def propagate_authorship(path):
with open(path, "r+", encoding="utf-8") as f:
content = f.read()
if "Digital Crystal Protocol — Authorship Propagation" not in content:
f.seek(0, 0)
f.write(AUTH_BLOCK + "\n\n" + content)
for root, _, files in os.walk("."):
for file in files:
if any(file.endswith(ext) for ext in EXTENSIONS):
try:
propagate_authorship(os.path.join(root, file))
except Exception:
pass