lintrans

Module contents

This is the top-level lintrans package, which contains all the subpackages of the project.

Subpackages

Submodules

lintrans.__main__ module

This module provides a main() function to interpret command line arguments and run the program.

lintrans.__main__.main() None

Interpret program-specific command line arguments and run the main window in most cases.

If the user supplies --help or --version, then we simply respond to that and then return. If they don’t supply either of these, then we run lintrans.gui.main_window.main().

Parameters

args (List[str]) – The full argument list (including program name)

lintrans.crash_reporting module

This module provides functions to report crashes and log them.

The only functions you should be calling directly are set_excepthook() and set_signal_handler() to setup handlers for unhandled exceptions and unhandled operating system signals respectively.

lintrans.crash_reporting._get_crash_report(datetime_string: str, error_origin: str) str

Return a string crash report, ready to be written to a file and stderr.

Parameters
  • datetime_string (str) – The datetime to use in the report; should be the same as the one in the filename

  • error_origin (str) – The origin of the error. Get this by calling _get_error_origin()

lintrans.crash_reporting._get_datetime_string() str

Get the date and time as a string with a space in the middle.

lintrans.crash_reporting._get_display_settings() str

Return a string representing all of the display settings.

lintrans.crash_reporting._get_error_origin(*, exc_type: Optional[Type[BaseException]], exc_value: BaseException | None, traceback: types.TracebackType | None, signal_number: int | None, stack_frame: frame | None) str

Return a string specifying the full origin of the error, as best as we can determine.

This function has effectively two signatures. If the fatal error is caused by an exception, then the first 3 arguments will be used to match the signature of sys.excepthook(). If it’s caused by a signal, then the last two will be used to match the signature of the handler in signal.signal(). This function should never be used outside this file, so we don’t account for a mixture of arguments.

Parameters
  • exc_type (Type[BaseException] | None) – The type of the exception that caused the crash

  • exc_value (BaseException | None) – The value of the exception itself

  • traceback (types.TracebackType | None) – The traceback object

  • signal_number (int | None) – The number of the signal that caused the crash

  • stack_frame (types.FrameType | None) – The current stack frame object

lintrans.crash_reporting._get_main_window() LintransMainWindow

Return the only instance of LintransMainWindow.

Raises

RuntimeError – If there is not exactly 1 instance of LintransMainWindow

lintrans.crash_reporting._get_post_mortem() str

Return whatever post mortem data we could gather from the window.

lintrans.crash_reporting._get_system_info() str

Return a string of all the system we could gather.

lintrans.crash_reporting._report_crash(*, exc_type: Optional[Type[BaseException]] = None, exc_value: Optional[BaseException] = None, traceback: Optional[TracebackType] = None, signal_number: Optional[int] = None, stack_frame: Optional[frame] = None) None

Generate a crash report and write it to a log file and stderr.

See _get_error_origin() for an explanation of the arguments. Everything is handled internally if you just use the public functions set_excepthook() and set_signal_handler().

lintrans.crash_reporting.set_excepthook() None

Change sys.excepthook() to generate a crash report first.

lintrans.crash_reporting.set_signal_handler() None

Set the signal handlers to generate crash reports first.

lintrans.global_settings module

This module provides the global_settings attribute, which should be used to access global settings.

class lintrans.global_settings._GlobalSettings

Bases: object

A class to provide global settings that can be shared throughout the app.

The directory methods are split up into things like get_save_directory() and get_crash_reports_directory() to make sure the directories exist and discourage the use of other directories in the root one.

Warning

This class should never be directly used and should only be accessed through the global_settings attribute.

__init__() None

Create the global settings object and initialize state.

static __new__(cls) _GlobalSettings

Override __new__() to implement a singleton. This class will only be created once.

get_crash_reports_directory() str

Return the default directory for crash reports.

get_save_directory() str

Return the default directory for save files.

lintrans.global_settings.global_settings = <lintrans.global_settings._GlobalSettings object>

This attribute is the only way that global settings should be accessed.

For the private class, see _GlobalSettings.