import xml.etree.ElementTree as ET import copy # 원본 XML 파일 경로 input_file = 'pon00061.xml' output_file = 'expanded_pathway43200.xml' # 파싱 tree = ET.parse(input_file) root = tree.getroot() # entry 태그만 추출 entries = [e for e in root.findall('entry')] # 원본 entry 수 확인 print(f'원본 entry 개수: {len(entries)}') # 복제 단계 수: 10000~90000 까지 (1~9단계) MULTIPLIERS = range(1, 120) # 새로운 entry 리스트 new_entries = [] for mult in MULTIPLIERS: id_offset = mult * 10000 xy_offset = mult * 2000 for entry in entries: new_entry = copy.deepcopy(entry) # id 업데이트 old_id = int(entry.attrib['id']) new_entry.attrib['id'] = str(old_id + id_offset) # graphics 내부 x, y 업데이트 graphics = new_entry.find('graphics') if graphics is not None: old_x = int(graphics.attrib['x']) old_y = int(graphics.attrib['y']) graphics.attrib['x'] = str(old_x + xy_offset) graphics.attrib['y'] = str(old_y + xy_offset) new_entries.append(new_entry) # 원본 root에 추가 for e in new_entries: root.append(e) # 출력 저장 tree.write(output_file, encoding='utf-8', xml_declaration=True) print(f'새로운 XML이 {output_file}에 저장되었습니다.')