-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_scopus.py
More file actions
79 lines (66 loc) · 2.75 KB
/
Copy pathrun_scopus.py
File metadata and controls
79 lines (66 loc) · 2.75 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
"""
run_scopus.py — Integrity-protected launcher for scopus_api.py
Author : Robin Tomar
GitHub : https://github.com/imrobintomar
LinkedIn: https://in.linkedin.com/in/robintomar
WARNING: This file contains an author-integrity check.
If the AUTHOR block below is modified, the script will refuse to run.
"""
import hashlib
import os
import subprocess
import sys
from dotenv import load_dotenv
# ---------------------------------------------------------------------------
# AUTHOR BLOCK — do NOT edit these lines
# ---------------------------------------------------------------------------
AUTHOR = {
"name" : "Robin Tomar",
"github" : "https://github.com/imrobintomar",
"linkedin": "https://in.linkedin.com/in/robintomar",
}
# SHA-256 of the canonical author string (name|github|linkedin)
# Recompute only if you are Robin Tomar updating your own details.
_AUTHOR_HASH = "29278c69e378bc8f2db789fd4a88f3df34fdc7e54b4a1e59b5d640e9d0a57a25"
# ---------------------------------------------------------------------------
# Integrity check
# ---------------------------------------------------------------------------
def _check_author():
canonical = "{name}|{github}|{linkedin}".format(**AUTHOR)
actual_hash = hashlib.sha256(canonical.encode()).hexdigest()
if actual_hash != _AUTHOR_HASH:
print("=" * 60)
print(" INTEGRITY CHECK FAILED")
print(" Author details have been modified.")
print(" This script may not be run without the correct")
print(" original author attribution.")
print()
print(" Original author: Robin Tomar")
print(" GitHub : https://github.com/imrobintomar")
print(" LinkedIn: https://in.linkedin.com/in/robintomar")
print("=" * 60)
sys.exit(1)
# ---------------------------------------------------------------------------
# Entry point
# ---------------------------------------------------------------------------
def _load_env():
env_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), ".env")
load_dotenv(dotenv_path=env_path)
api_key = os.getenv("SCOPUS_API_KEY")
if not api_key:
print("ERROR: SCOPUS_API_KEY not found.")
print(" Create a .env file with: SCOPUS_API_KEY=your_key_here")
sys.exit(1)
return api_key
if __name__ == "__main__":
_check_author()
print(f"Author verified: {AUTHOR['name']}")
print(f"GitHub : {AUTHOR['github']}")
print(f"LinkedIn: {AUTHOR['linkedin']}")
print("-" * 60)
api_key = _load_env()
print(f"API key loaded from .env ({api_key[:6]}...)")
print("-" * 60)
script = os.path.join(os.path.dirname(os.path.abspath(__file__)), "scopus_api.py")
result = subprocess.run([sys.executable, script])
sys.exit(result.returncode)