ppms.customizer.module_reader
This page documents the ppms.customizer.module_reader package for consuming module data and converting that to JSON.
Classes
ModuleReader
The ModuleReader class reads a module’s visible data and can return either concrete JSON data or a structural JSON Schema. It respects customizing (visibility, headings, datafield configs) and filters special dataitems.
Reads top-level dataareas and recursively includes child dataareas (including self for recursive relations).
Filters out Background and Button dataitems in both data and schema outputs.
Supports two output formats: JSON (content) and JSON Schema (Draft 2020-12).
Methods
Function | Parameters | Return Value | Description |
|---|---|---|---|
ModuleReader.__init__ | module: PPMS module instance query_parameters: skip_hidden_fields: |
| Initialize a reader for a specific module.
|
ModuleReader.read_module_data_as_dictionary |
|
| Produces data JSON: each top-level DA (by Python ID) maps to an array of records; each record contains visible datafields and nested arrays for child DAs (including self for recursive DAs). |
ModuleReader.get_json_schema_definition |
|
| Produces a schema for the data JSON above. |
Note: All keys are based on the python IDs of the DA / DF. If your top level DA has no python id no data will be returned.
Configuring Field Keys and Values (DatafieldConfig)
Two per-field options influence how keys and values are emitted (applies to data JSON and to type inference in JSON Schema).
To use them set the relevant "Option" in the datafield configuration of the field you want to be exported differently
Option | Meaning | Affects Key | Affects Value | Notes |
|---|---|---|---|---|
| Use datafield heading instead of Python ID | ✅ key = | — | If not set, key = customizing name (Python ID). |
| Use technical/raw value instead of text | — | ✅ value = | If not set, value = In Schema, enables type inference. Without |
Examples
Read schema and data
from ppms import ppms
from ppms.customizer.module_reader import ModuleReader
macro = ppms.get_macro_module()
with macro.open_module('002858') as replanning_module:
reader = ModuleReader(module=replanning_module)
schema = reader.get_json_schema_definition()
data = reader.read_module_data_as_dictionary()
ppms.ui_message_box('schema', schema)
ppms.ui_message_box('data', data)
Example Schema (abridged)
{
'$schema': 'https://json-schema.org/draft/2020-12/schema',
'type': 'object',
'properties': {
'data': {
'type': 'object',
'properties': {
'projects': {'type': 'array', 'items': {'$ref': '#/definitions/projects'}}
}
}
},
'definitions': {
'projects': {
'type': 'object',
'items': {
'type': 'array',
'properties': {
'pr_functional': {'type': 'string'},
'project_name': {'type': 'string'},
'pr_prio': {'type': 'string'},
'pr_type_incarnation': {'type': 'string'},
'pr_type': {'type': 'string'},
'planning_type_incarnation': {'type': 'string'},
'planning_type': {'type': 'string'},
'pr_code_incarnation': {'type': 'string'},
'calc_end': {'type': 'string'},
'requested_end': {'type': 'string'},
'loaded': {'type': 'string'},
'last_sched_date': {'type': 'string'},
'no_of_tasks_real': {'type': 'string'},
'no_of_links': {'type': 'string'}
}
}
}
}
}
Example Data (abridged)
{
'data': {
'projects': [
{
'pr_functional': 'S+W 20XX',
'project_name': 'Systempflege und Wartung',
'pr_prio': '100',
'pr_type_incarnation': 'Projekt',
'pr_type': '0',
'planning_type_incarnation': 'Termintreu',
'planning_type': '0',
'pr_code_incarnation': 'A-Projekte',
'calc_end': '28.11.25',
'requested_end': '30.11.25',
'loaded': 'J',
'last_sched_date': '28.01.25',
'no_of_tasks_real': '7',
'no_of_links': ''
}
]
}
}