Spaces:
Sleeping
Sleeping
Download patch_backend.py from yabeskn/briga-content-kitchen: direct link, hf CLI and curl.
- Browser
- Download file 1.8 kB
-
https://huggingface.co/spaces/yabeskn/briga-content-kitchen/resolve/main/patch_backend.py
- Command line
-
hf download hf://spaces/yabeskn/briga-content-kitchen/patch_backend.py
-
curl -L -o patch_backend.py https://huggingface.co/spaces/yabeskn/briga-content-kitchen/resolve/main/patch_backend.py
1.8 kB
| import os | |
| print("🔧 [Patch Backend] Safely patching LinkedIn scopes list...") | |
| count = 0 | |
| for root, dirs, files in os.walk("/app"): | |
| if ".next" in root or "node_modules/.cache" in root: | |
| continue | |
| for f in files: | |
| if f.endswith(".js"): | |
| path = os.path.join(root, f) | |
| try: | |
| with open(path, "r", encoding="utf-8", errors="ignore") as file: | |
| content = file.read() | |
| modified = False | |
| # Remove prompt=none | |
| if "prompt=none" in content: | |
| content = content.replace("&prompt=none", "").replace("prompt=none&", "").replace("prompt=none", "") | |
| modified = True | |
| # Safely clean out organization and deprecated scopes from scope lists | |
| for scope in [ | |
| '"r_basicprofile",', '"rw_organization_admin",', '"w_organization_social",', '"r_organization_social",', ',"r_organization_social"', | |
| "'r_basicprofile',", "'rw_organization_admin',", "'w_organization_social',", "'r_organization_social',", ",'r_organization_social'", | |
| 'r_basicprofile ', 'rw_organization_admin ', 'w_organization_social ', 'r_organization_social' | |
| ]: | |
| if scope in content: | |
| content = content.replace(scope, "") | |
| modified = True | |
| if modified: | |
| with open(path, "w", encoding="utf-8") as file: | |
| file.write(content) | |
| count += 1 | |
| print(f" ✅ Safely Patched: {path}") | |
| except Exception: | |
| pass | |
| print(f"🔧 [Patch Backend] Successfully patched {count} files.") | |