core.lnp module

PyLNP main library.

class core.lnp.PyLNP[source]

Bases: object

PyLNP library class.

Acts as an abstraction layer between the UI and the Dwarf Fortress instance.


Detects the location of Dwarf Fortress by walking up the directory tree.

static get_commandline_args()[source]

Responsible for the actual parsing of command line options.


Initializes the DF folder and related variables.


Initializes the main program (errorlog, path registration, etc.).


Instantiates the UI object.


Verify that macOS isn’t isolating our application.


Parses and acts on command line options.


Reloads the program to allow the user to change DF folders.


Saves LNP configuration.

class core.lnp.UI[source]

Bases: object

Specifies the interface required by the core PyLNP library for communicating with the user. Provided for reference; UIs do not need to inherit from this.


Called before running DF if an invalid configuration is detected. <errors> contains a list of discovered problems, which should be shown to the user. A true return value will launch DF anyway; a false return value cancels.

on_program_running(path, is_df)[source]

Called when attempting to launch a program that is already running. <path> provides the path to the program that is being launched, so you can request a forced launch. <is_df> specifies if the program is DF (True) or a utility (False).


When no saves are detected, this function will be called. This should provide the user with an option to import a previous DF install or starter pack into the newly selected DF version.


Called when PyLNP.json specifies a desired update interval but the user configuration does not hold a value for this. <interval> contains the number of days between update checks. A true return value will change the configuration to use the specified interval. A false return value will turn off automatic update checks.


Called when an update is available. Use this to show a notification and prompt the user for further action.


Notifies the UI to start. On return, PyLNP will terminate.