Helper Functions

The helper functions are mostly involved in converting units, file saving, or have been adapted from other sources as needed.

class helpers.mock_output

Bases: KeyboardEmulation

send_backspaces(count)

Output the given number of backspaces.

send_string(string)

Output the given string.

helpers.write_command(control, text=None, value=None, visible=True, group=False)

Create RTF-formatted string.

Parameters:
  • control (str) – any RTF or RTF/CRE control word, required

  • text (str) – unformatted text, optional

  • value (int) – numeric value associated with control word, can be positive or negative

  • visible (bool) – signal that the group is set as ignored, default True

  • group (bool) – whether this command should be a group, default False

Returns:

RTF-formatted string

Return type:

str

helpers.return_commits(repo, max_entries=100)

Adapted from dulwich, returns commit info.

helpers.ms_to_hours(millis)

Convert milliseconds to formatted hour:min:sec.milli.

helpers.hours_to_ms(hour_str)

Convert formatted hour:min:sec.milli to milliseconds.

helpers.in_to_pt(inch)

Convert inch to point.

helpers.pixel_to_in(pixel)

Convert pixel to inch.

helpers.in_to_pixel(inch)

Convert inch to pixel.

helpers.inch_to_spaces(inch, chars_per_in=10)

Convert inch to approximate spaces for monospaced fonts.

helpers.save_json(json_dict, file_path)

Save dict to json file.

helpers.add_custom_dicts(custom_dict_paths, dictionaries)

Takes list of dictionary paths, returns Plover dict config.

helpers.load_dictionary_stack_from_backup(path)

Restore Plover dicts from backup file.

helpers.backup_dictionary_stack(dictionaries, path)

Takes Plover dict config, creates backup file.

helpers.remove_empty_from_dict(d)

Removes dict key:value if value is None-like recursively.

helpers.hide_file(filename)

Helper for windows os to hide autosave file.

helpers.extract_ngram(text, n=2)

Return n-gram iterator from string of text.