|
import os |
|
|
|
def replace_links_in_file(file_path): |
|
with open(file_path, 'r', encoding='utf-8') as file: |
|
content = file.read() |
|
|
|
content = content.replace('https://github.com/', 'https://ghp.ci/https://github.com/') |
|
content = content.replace('https://raw.githubusercontent.com/', 'https://ghp.ci/https://raw.githubusercontent.com/') |
|
content = content.replace('https://gist.github.com/', 'https://ghp.ci/https://gist.github.com/') |
|
content = content.replace('https://gist.githubusercontent.com/', 'https://ghp.ci/https://gist.githubusercontent.com/') |
|
|
|
with open(file_path, 'w', encoding='utf-8') as file: |
|
file.write(content) |
|
|
|
def find_and_replace_links(directory): |
|
for root, _, files in os.walk(directory): |
|
for file in files: |
|
if file.endswith('.py'): |
|
file_path = os.path.join(root, file) |
|
replace_links_in_file(file_path) |
|
print(f"Processed file: {file_path}") |
|
|
|
|
|
directory_path = './' |
|
find_and_replace_links(directory_path) |