Metadata-Version: 2.4
Name: mspdi
Version: 0.1.0
Summary: Read and write Microsoft Project XML (MSPDI) with the standard library only, with the element-order and unit gotchas documented.
Author: Mario (Kind of Lost)
License: MIT
Project-URL: Homepage, https://gantt.kindoflost.com
Keywords: microsoft project,mspdi,msproject,xml,scheduling,gantt
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Topic :: Office/Business :: Scheduling
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Dynamic: license-file

# mspdi

Read and write Microsoft Project XML (MSPDI) in pure Python, standard library only.
Plans load into plain dataclasses (project, tasks, links, resources, assignments,
calendars) and write back with the element order Microsoft Project requires.

Used by the free resource-leveling scheduler at https://gantt.kindoflost.com

## Install

    pip install mspdi

Python 3.9+. No dependencies.

## Example

```python
import mspdi

project = mspdi.read("plan.xml")            # File > Save As > XML Format in MS Project
for t in project.tasks:
    if not t.summary:
        print(t.uid, t.name, t.start, t.duration_minutes / project.minutes_per_day, "days")
        for link in t.links:                 # stored on the successor
            print("   after", link.pred_uid, link.type, link.lag_minutes, "min lag")

task = project.task(5)
task.constraint_type = mspdi.SNET           # Start no earlier than...
task.constraint_date = task.start
mspdi.write(project, "out.xml")             # summaries, FinishDate, IDs repaired for you

# edit a real export WITHOUT losing anything the model does not carry:
patched = mspdi.patch.patch_schedule(open("plan.xml", "rb").read(), {5: (start, finish)}, snet=[5])
```

## What the gotchas are (and where they live in the code)

* MSPDI is an ordered `xsd:sequence`. Project silently drops an out-of-order element and
  still opens cleanly. `ConstraintDate` follows `CalendarUID`; `PredecessorLink` is last.
* Link `Type`: 0=FF, 1=FS, 2=SF, 3=SS. `LinkLag` and `LevelingDelay` are tenths of a minute;
  `LevelingDelay` is elapsed time and needs `LevelingDelayFormat` present.
* `UID` is identity, `ID` is row position. Milestones are 17:00 on both ends. Summary durations
  are the working-day span of their children.
* Project recomputes the schedule on open: a date only sticks if you write a constraint.

See the docstrings in `mspdi/writer.py` and `mspdi/patch.py`.

## Limitations

* Pure parser/writer: no scheduling engine. It does not compute dates, critical paths or leveling.
* `write()` builds a fresh file from the model: custom fields, baselines, notes on tasks beyond
  `Notes`, extended attributes, and unmodelled elements are NOT kept. Use `mspdi.patch` to edit a
  real export in place.
* Calendars: base-calendar weekdays/working times and dated exceptions are read. Exception writing
  follows the published schema but has not been verified in real Microsoft Project. Resource and
  task calendars are read as UIDs only and not interpreted.
* Not written: percent complete beyond `PercentComplete`, baselines, costs, splits, recurring tasks,
  effort-driven scheduling, material/cost resources' rates.
* Element order and unit behaviour were measured against Microsoft Project 2010-era exports and
  one hands-on session in a current Project; other versions are untested. Not affiliated with
  Microsoft. `.mpp` and `.xer` are not supported (save as XML first).
* Dates are naive local times, exactly as MSPDI stores them.

## License

MIT. Copyright (c) 2026 Mario (Kind of Lost).
