29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
import re
|
|
|
|
input_file = 'external_repositories.txt'
|
|
output_file = 'filtered_repositories.txt'
|
|
|
|
# Регулярное выражение для определения ссылок на репозитории
|
|
repo_patterns = [
|
|
re.compile(r'https?://[^/]+/[^/]+/[^/]+\.git'), # Например, https://github.com/user/repo.git
|
|
re.compile(r'https?://[^/]+/[^/]+/[^/]+/[^/]+') # Например, https://gitlab.com/group/project/repo
|
|
]
|
|
|
|
# Функция для проверки, является ли ссылка ссылкой на репозиторий
|
|
def is_repo_url(url):
|
|
return any(pattern.match(url) for pattern in repo_patterns)
|
|
|
|
# Чтение и обработка файла
|
|
with open(input_file, 'r') as file:
|
|
lines = file.readlines()
|
|
|
|
# Фильтрация ссылок
|
|
filtered_urls = [line for line in lines if is_repo_url(line) and 'lmru.adeo' not in line and 'lmru.tech' not in line and 'LICENSE' not in line and 'adeo.com' not in line and 'adeo.cloud' not in line]
|
|
|
|
# Запись отфильтрованных ссылок в новый файл
|
|
with open(output_file, 'w') as file:
|
|
file.writelines(filtered_urls)
|
|
|
|
print(f'Filtered URLs have been written to {output_file}')
|
|
|