OsProject

OsProject
edit
id  py-yprinciple-gen
state  active
owner  WolfgangFahl
title  py-yprinciple-gen
url  https://github.com/WolfgangFahl/py-yprinciple-gen
version  0.5.3
description  python Y-Principle generator
date  2026-07-26
since  2022-11-27
until  


Motivation

BITPlan has been proposing the Y-Principle since it's inception in 1999.

When we started using Semantic MediaWiki in 2013 we needed a way to apply the principle to the usage of SMW.

We therefore implemented the ProfiWiki approach which was first implemented in Java.

This project is a migration of the Java based solution to Python. It uses ngwidgets which is based on NiceGUI and therefore needs no separate javascript frontend.

tickets

Installation

pip install py-yprinciple-gen
# alternatively if your pip is not a python3 pip
pip3 install py-yprinciple-gen 
# local install from source directory of py-yprinciple-gen 
pip install .

upgrade

pip install py-yprinciple-gen  -U
# alternatively if your pip is not a python3 pip
pip3 install py-yprinciple-gen -U


Usage

Command line

ypgen -h
usage: ypgen [-h] [-a] [-d] [--debugLocalPath DEBUGLOCALPATH]
             [--debugPort DEBUGPORT] [--debugRemotePath DEBUGREMOTEPATH]
             [--debugServer DEBUGSERVER] [-f] [-q] [-v] [-V] [--apache APACHE]
             [-c] [-l] [-i INPUT] [-rol] [--host HOST] [--port PORT] [-s]
             [--context CONTEXT] [--topics [TOPICS ...]]
             [--targets [TARGETS ...]] [-ga] [-gf] [--targetPath TARGETPATH]
             [--sidif SIDIF] [-nd] [--editor] [--push] [--wikiId WIKIID]
             [--source SOURCE] [--login]
python Y-Principle generator
options:
  -h, --help            show this help message and exit
  -a, --about           show version info and open documentation
  -d, --debug           enable debug output
  --debugLocalPath DEBUGLOCALPATH
                        remote debug Server path mapping - localPath - path on
                        machine where python runs
  --debugPort DEBUGPORT
                        remote debug Port [default: 5678]
  --debugRemotePath DEBUGREMOTEPATH
                        remote debug Server path mapping - remotePath - path
                        on debug server
  --debugServer DEBUGSERVER
                        remote debug Server
  -f, --force           force overwrite or unsafe actions
  -q, --quiet           suppress all output
  -v, --verbose         increase output verbosity
  -V, --version         show program's version number and exit
  --apache APACHE       create an apache configuration file for the given
                        domain
  -c, --client          start client
  -l, --local           run with local file system access
  -i INPUT, --input INPUT
                        input file
  -rol, --render_on_load
                        render on load
  --host HOST           the host to serve / listen from (default: localhost)
  --port PORT           the port to serve from (default: 8778)
  -s, --serve           start webserver
  --context CONTEXT     context to generate from [default: MetaModel]
  --topics [TOPICS ...]
                        list of topic names [default: None]
  --targets [TARGETS ...]
                        list of target names [default: None]
  -ga, --genViaMwApi    generate elements via Api
  -gf, --genToFile      generate elements to files
  --targetPath TARGETPATH
                        path for the files to be generated - uses wikibackup
                        default path for wikiId if not specified
  --sidif SIDIF         path to SiDIF input file
  -nd, --noDry          switch off dry run [default: False]
  --editor              open editor for results [default: False]
  --push                push from source to target [default: False]
  --wikiId WIKIID, --target WIKIID
                        id of the wiki to generate for [default: wiki]
  --source SOURCE       id of the wiki to get concept and contexts (schemas)
                        from [default: profiwiki]
  --login               login to source wiki for access permission

Web server

# serve the generator web UI for the MetaModel context of the wiki with the id "wiki"
ypgen --context MetaModel --wikiId wiki --serve

Batch generation

Batch mode needs one of --genViaMwApi, --genToFile or --push. Without one of these the arguments are parsed but nothing is generated.

Generation is a dry run unless --noDry is given. A dry run reports the size of the diff per page, a real run reports the diff url of the resulting revision.

via the MediaWiki Api

# dry run - show which pages would change
ypgen --wikiId partner --context MetaModel --targets listOf --genViaMwApi
# write the pages
ypgen --wikiId partner --context MetaModel --targets listOf --genViaMwApi --noDry

to files

ypgen --wikiId wiki --context MetaModel --topics Event --targets help --genToFile --targetPath /tmp/ypgen --noDry

Targets

If --targets is omitted all targets are generated, if --topics is omitted all topics of the context are generated. The available targets are:

category, concept, form, help, listOf, template, properties, property, python