import os
import glob
# 특정 경로에서 .spec 파일을 찾는 함수
def find_spec_files(base_path):
spec_files = []
for root, dirs, files in os.walk(base_path):
for file in glob.glob(os.path.join(root, "*.spec")):
spec_files.append(file)
return spec_files
# 간단한 .spec 파일 파싱 함수 (헤더 정보만 추출)
def parse_spec_file(spec_file):
parsed_data = {}
with open(spec_file, 'r') as f:
lines = f.readlines()
for line in lines:
# 패키지의 기본 메타데이터 추출
if line.startswith('Name:'):
parsed_data['Name'] = line.split(':')[1].strip()
elif line.startswith('Version:'):
parsed_data['Version'] = line.split(':')[1].strip()
elif line.startswith('Release:'):
parsed_data['Release'] = line.split(':')[1].strip()
elif line.startswith('Summary:'):
parsed_data['Summary'] = line.split(':')[1].strip()
elif line.startswith('License:'):
parsed_data['License'] = line.split(':')[1].strip()
return parsed_data
# 예제 경로 설정 (사용자 환경에 맞게 경로 설정)
base_path = "/your/directory/path"
# spec 파일 찾기
spec_files = find_spec_files(base_path)
# spec 파일 파싱 및 결과 출력
for spec_file in spec_files:
parsed_data = parse_spec_file(spec_file)
print(f"Parsed data from {spec_file}:")
for key, value in parsed_data.items():
print(f"{key}: {value}")
print("\n")