Skip to main content
Skip table of contents

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__(self, module, query_parameters=None, skip_hidden_fields=True)

module: PPMS module instance

query_parameters: dict or None

skip_hidden_fields: bool (default True)

ModuleReader instance

Initialize a reader for a specific module.

  • query_parameters are not relevant when using the ModuleReader directly

  • Hidden datafields are skipped when skip_hidden_fields=True.

ModuleReader.read_module_data_as_dictionary(self)

dict with the key data containing the module content

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(self)

dict (JSON Schema Draft 2020-12)

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-df-heading

Use datafield heading instead of Python ID

✅ key = dfc.get_heading()

If not set, key = customizing name (Python ID).

get-tech-value

Use technical/raw value instead of text

✅ value = datafield.get_raw_value()

If not set, value = datafield.get_text_value() (string).

In Schema, enables type inference.

Without get-tech-value all values will be of type string

Examples

Read schema and data

PY
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)
JSON
{
  '$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)
JSON
{
  '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': ''
      }
    ]
  }
}
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.