Files
2nd/10_Wiki/Topics/Programming & Language/ndf-parse 패키지.md
T
Antigravity Agent f8b21af4be Wiki cleanup: error-doc removal, dedup merge, link normalization
10_Wiki/Topics 대규모 정리:
- 오류 캡처/미완성 stub 문서 227개 제거
- 교차폴더 중복 43클러스터 병합 (63파일 → redirect)
- 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건
- 카테고리 MOC 6개 신규 생성
- Graph 섹션 미해결 related-keyword 링크 10,058건 제거

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 23:52:15 +09:00

4.6 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-ndf-parse-패키지 ndf-parse 패키지 10_Wiki/Topics verified self
ndf-parse
NDF parser
Eugen NDF
none B 0.85 applied
python
parser
modding
wargame
ndf
2026-05-10 pending
language framework
Python ndf-parse (PyPI)

ndf-parse 패키지

매 한 줄

"매 Eugen Systems 의 NDF (Niche Definition Files) format 의 Python parser/serializer". 매 Wargame: Red Dragon, Steel Division, WARNO 의 mod 작성에 사용. 매 lossless round-trip + AST manipulation 을 제공.

매 핵심

매 NDF format 이란

  • Eugen 의 game data 정의 언어 — 매 unit stats, weapon, sound, UI binding 의 declarative description.
  • Lua-like syntax + GUID reference + template instantiation. 매 plain text but very large (수만 lines).

매 ndf-parse 가 해주는 것

  • Parse: NDF text → Python AST (List / Object / Map / Reference / Template node).
  • Walk: tree traversal + by-name lookup.
  • Mutate: in-place edit, insert, delete.
  • Serialize: AST → NDF text, 매 formatting 의 보존 (whitespace, comments).

매 응용

  1. WARNO / Steel Division mod 의 unit balancing.
  2. Bulk find-replace (e.g. all small-arms 의 damage +10%).
  3. Mod merge tool — 매 multiple mod 의 conflict-free combination.
  4. CI validation — 매 NDF schema 의 lint.

💻 패턴

Install + 매 first parse

# pip install ndf-parse
import ndf_parse as ndf

with open("GameData/Generated/Gameplay/Gfx/UniteDescriptor.ndf", "r", encoding="utf-8") as f:
    source = ndf.load(f)  # returns ndf.model.List
print(type(source), len(source))

매 unit lookup by name

unit = source.by_name("Descriptor_Unit_M1A2_Abrams_US").value
# unit is an Object node

매 module 안의 specific value 변경

modules = unit.by_name("ModulesDescriptors").value
for module in modules:
    if module.value.type == "TBaseDamageModuleDescriptor":
        hp_row = module.value.by_name("MaxPhysicalDamages")
        hp_row.value = "12"  # was "10"
        break

매 weapon damage 의 bulk +10%

def bump_damage(node):
    for member in node:
        if member.member == "PhysicalDamages":
            try:
                old = float(member.value)
                member.value = f"{old * 1.10:.2f}"
            except ValueError:
                pass
        if hasattr(member.value, "__iter__"):
            bump_damage(member.value)

bump_damage(source)

매 serialize back

with open("Mod/UniteDescriptor.ndf", "w", encoding="utf-8") as f:
    ndf.write(source, f)
# 매 round-trip: comments / whitespace 의 가능한 한 보존

매 새 unit 의 clone + rename

import copy
template = source.by_name("Descriptor_Unit_M1A2_Abrams_US")
clone = copy.deepcopy(template)
clone.name = "Descriptor_Unit_M1A3_Abrams_Custom"
source.add(clone)

CLI mod build pipeline

# build_mod.py
from pathlib import Path
import ndf_parse as ndf

for src_path in Path("GameData").rglob("*.ndf"):
    with src_path.open(encoding="utf-8") as f:
        tree = ndf.load(f)
    apply_patches(tree, src_path.name)
    out = Path("Mod") / src_path.relative_to("GameData")
    out.parent.mkdir(parents=True, exist_ok=True)
    with out.open("w", encoding="utf-8") as f:
        ndf.write(tree, f)

매 결정 기준

상황 Approach
매 single field 변경 by_name + value 직접 assign
매 bulk pattern 변경 recursive walker function
매 새 unit 추가 deepcopy + rename + add
매 cross-file reference 매 파일별 parse + cross-link by GUID
매 schema validation custom walker + assertion

기본값: 매 ndf-parse + Python script + git for version control. 매 manual NDF text edit 의 X.

🔗 Graph

  • 응용: WARNO Modding

🤖 LLM 활용

언제: NDF mod 작성 + LLM 의 patch generation, schema 추론, balance tweak suggestion. 언제 X: 매 binary game asset (DDS, BANK) — 매 NDF X.

안티패턴

  • 매 raw regex 의 NDF edit: 매 nested template 의 corruption 위험.
  • encoding 누락: NDF 는 UTF-8 (BOM 가능) — 매 default open() 의 fail.
  • 매 reference name 의 typo: silent — 매 by_name() 의 None return.

🧪 검증 / 중복

  • Verified (ndf-parse PyPI docs, Eugen modding wiki 2024).
  • 신뢰도 B (community-maintained).

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — ndf-parse API + WARNO mod patterns