32 lines
872 B
Python
32 lines
872 B
Python
|
|
import sys
|
||
|
|
import re
|
||
|
|
|
||
|
|
if len(sys.argv) < 2:
|
||
|
|
print("Usage: sanitize_lockfile.py <path_to_lockfile>")
|
||
|
|
sys.exit(1)
|
||
|
|
|
||
|
|
path = sys.argv[1]
|
||
|
|
|
||
|
|
try:
|
||
|
|
with open(path, 'r') as f:
|
||
|
|
content = f.read()
|
||
|
|
|
||
|
|
# Remove platform_release checks (e.g. platform_release >= '25.0' and ...)
|
||
|
|
# Matches: platform_release <op> 'version' [and]
|
||
|
|
content = re.sub(r"platform_release\s*[<>=!]+\s*'[^']*'\s*(and\s*)?", "", content)
|
||
|
|
|
||
|
|
# Remove python_full_version checks
|
||
|
|
content = re.sub(r"python_full_version\s*[<>=!]+\s*'[^']*'\s*(and\s*)?", "", content)
|
||
|
|
|
||
|
|
# Fix colorama complex marker
|
||
|
|
content = re.sub(r"colorama==0.4.6 ; .*", "colorama==0.4.6 ; sys_platform == 'win32'", content)
|
||
|
|
|
||
|
|
with open(path, 'w') as f:
|
||
|
|
f.write(content)
|
||
|
|
|
||
|
|
print(f"Sanitized {path}")
|
||
|
|
|
||
|
|
except Exception as e:
|
||
|
|
print(f"Error sanitizing lockfile: {e}")
|
||
|
|
sys.exit(1)
|