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[source]

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[source]

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[source]

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

lintrans.crash_reporting._get_display_settings() str[source]

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[source]

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[source]

Return the only instance of LintransMainWindow.

Raises

RuntimeError – If there is not exactly 1 instance of LintransMainWindow

lintrans.crash_reporting._get_post_mortem() str[source]

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

lintrans.crash_reporting._get_system_info() str[source]

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) NoReturn[source]

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[source]

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

lintrans.crash_reporting.set_signal_handler() None[source]

Set the signal handlers to generate crash reports first.

lintrans.global_settings module

This module provides the GlobalSettings class, which is used to access global settings.

class lintrans.global_settings.GlobalSettingsData[source]

Bases: object

A simple dataclass to store the configurable data of the global settings.

__eq__(other)

Return self==value.

__hash__ = None
__init__(update_type: UpdateType = UpdateType.prompt, cursor_epsilon: int = 5, snap_dist: float = 0.1, snap_to_int_coords: bool = True) None
__repr__()

Return repr(self).

__slots__ = ('update_type', 'cursor_epsilon', 'snap_dist', 'snap_to_int_coords')
cursor_epsilon: int

This is the distance in pixels that the cursor needs to be from the point to drag it.

classmethod load_from_file(filename: str) Tuple[str, GlobalSettingsData][source]

Return the global settings data that was previously saved to filename along with some extra information.

The tuple we return has the version of lintrans that was used to save the file, and the data itself.

Raises
  • EOFError – If the file doesn’t contain a pickled Python object

  • FileNotFoundError – If the file doesn’t exist

  • ValueError – If the file contains a pickled object of the wrong type

save_to_file(filename: str) None[source]

Save the global settings data to a file, creating parent directories as needed.

snap_dist: float

This is the distance in grid coords that the cursor needs to be from an integer point to snap to it.

snap_to_int_coords: bool

This decides whether or not vectors should snap to integer coordinates when being dragged around.

update_type: UpdateType

This is the desired type of update prompting.

class lintrans.global_settings.UpdateType

Bases: Enum

An enum of possible update prompt types.

auto = 1
never = 3
prompt = 2

lintrans.updating module

This module provides functions for updating the lintrans executable in a proper installation.

If the user is using a standalone executable for lintrans, then we don’t know where it is and we therefore can’t update it.

lintrans.updating.new_version_exists() Tuple[bool, Optional[str]][source]

Check if the latest version of lintrans is newer than the current version.

This function either returns (False, None) or (True, str) where the string is the new version.

Note

This function will default to False if it can’t get the current or latest version, or if get_executable_path() returns ‘’ (probablybecause lintrans is being run as a Python package)

However, it will return True if the executable path is defined but the executable doesn’t actually exist.

This last behaviour is mostly to make testing easier by spoofing get_executable_path().

lintrans.updating.update_lintrans() None[source]

Update the lintrans binary executable, failing silently.

This function only makes sense if lintrans was installed, rather than being used as an executable. We ask the GlobalSettings singleton where the executable is and, if it exists, then we replace the old executable with the new one. This means that the next time lintrans gets run, it will use the most recent version.

Note

This function doesn’t care if the latest version on GitHub is actually newer than the current version. Use new_version_exists() to check.

lintrans.updating.update_lintrans_in_background(*, check: bool) None[source]

Use multithreading to run update_lintrans() in the background.