# livemaker.cli package

## Submodules

## livemaker.cli.cli module

pylivemaker cli.

## livemaker.cli.lmar module

LiveMaker archive CLI tool.

## livemaker.cli.lmgraph module

pylivemaker lsb call graph tool.

`livemaker.cli.lmgraph.``parse_lsb`(lsb_file, root_dir=None)

  Parse one LSB into the graph.

## livemaker.cli.lmlpb module

LiveMaker LPB project settings CLI tool.

## livemaker.cli.lmlsb module

LiveMaker LSB script CLI tool.

`livemaker.cli.lmlsb.``insert_lns`(encoding, lsb_file, script_file, line_number, no_backup)

  Compile specified LNS script and insert it into the specified LSB file.

  The LSB command at line_number must be a TextIns command. The existing text block of the specified TextIns command will be replaced with the new one from script_file.

  script_file should be an LNS script which was initially generated by lmlsb extract.

  The original LSB file will be backed up to <lsb_file>.bak unless the –no-backup option is specified.

## livemaker.cli.lmpatch module

pylivemaker patcher.

## Module contents

LiveMaker LSB/LSC script module.

class `livemaker.lsb.``LMScript`(version=117, param_type=1, flags=0, call_name='', novel_params=[], command_params=[[]], commands=[], **kwargs)

  Bases: `livemaker.lsb.core.BaseSerializable`

  LiveMaker script class.

  A LiveMaker script is a collection of LiveMaker novel commands. One LiveMaker/LiveNovel “Chart” will be serialized as one script file.

  Parameters: | version (int) – Version number. If version is not in the range [MIN_LSB_VERSION, MAX_LSB_VERSION], this LMScript cannot be compiled into a binary LSB. param_type – Unknown type flag (always 1?). flags (int) – Unknown (always 0?). call_name (str) – String name for calling this script (only used for documentation). novel_params (iterable) – Iterable containing string descriptions for parameters that this script accepts (only used for documentation). command_params (iterable(iterable(bool))) – Two dimensional array of booleans specifying the command parameters are for Component type commands. (i.e. command_params[CommandType.BoxNew][PropertyType.PR_NAME] == True means that BoxNew takes a PR_NAME parameter.) commands (iterable) – Iterable containing this script’s Command objects.
  Raises: | `BadLsbError` – If the specified LMScript would be invalid or unsupported.

  `commands`
  `keys`()
  `items`()
  `command_count`

    Return the number of command types supported by this script.

  `param_stream_size`

    Return the length of this script’s param flag bytestream.

  `lm_version`

    Return LiveMaker app version based on an LSB version.

  `to_lsc`()

    Return this script in the tex .lsc format.

  classmethod `from_lsc`(s)

    Create an LMScript from the specified string.

    Parameters: | s – String containing text .lsc format data.
    Raises: | BadLsbError if the string could not be parsed.

    Note

    Currently only supports reading version information.

  classmethod `from_struct`(struct, **kwargs)

    Create an LMScript from the specified struct.

  `to_lsb`()

    Compile this script into binary .lsb format.

  `to_xml`()

    Return this script as an .lsc format XML etree.Element.

  classmethod `from_xml`(root, **kwargs)

    Create an LMScript from the specified XML element.

    Parameters: | root – The root tree element.
    Raises: | `BadLsbError` – If the XML tree could not be parsed.

    Note

    Currently only supports reading header information.

  classmethod `from_file`(infile, **kwargs)

    Parse the specified file into an LMScript.

    Parameters: | infile – Input .lsc or .lsb file. Can be a string, path-like, or file-like object.
    Raises: | `BadLsbError` – If the input file could not be parsed.

  classmethod `from_lsb`(data, **kwargs)

    Parse the specified compiled .lsb data into an LMScript.

    Parameters: | data – Input .lsb data.
    Raises: | `BadLsbError` – If the input data could not be parsed.

  `get_command`(line_no)

    Get specified command by line number.

    Returns: | tuple(cmd_index, cmd)
    Raises: | `KeyError` – the specified line_no does not exist in this LSB.

  `walk`(start=0, unreachable=False)

    Iterate over LSB commands in approximate execution order.

    All conditional branches will be followed (positive condition will be evaluated first), but external jumps and calls will not be followed.

    Parameters: | start (int) – Command index to start from. unreachable (bool) – If True, unreachable commands will be included.
    Yields: | 3-tuple in the form `(index, command, last_calc)`

  `text_scenarios`(run_order=True)

    Return a list of LiveNovel text scenarios contained in this script.

    Parameters: | run_order (bool) – If True, scenarios will be returned in approximately the order they would be run in-game (via walk(). If False, text blocks will be returned in the order they occur in the LSB file.
    Returns: | (line_num, name, scenario)
    Return type: | tuple(int, str, `TpWord`)

  `get_text_blocks`(run_order=False)

    Return LiveNovel scenario text blocks contained in this script.

    Parameters: | run_order (bool) – If True, text blocks will be returned in approximately the order they would be run in-game (via walk(). If False, text blocks will be returned in the order they occur in the LSB file.
    Returns: | list of (identifier, block) tuples

  `replace_text`(text_objects)

    Replace the specified translatable text objects in this LSB.

    Parameters: | text_objects – Iterable containing (identifier, text) tuples

  `replace_text_blocks`(text_objects)

    Replace the specified LiveNovel scenario text blocks in this LSB.

    Parameters: | text_objects – Iterable containing (identifier, text) tuples

  `get_menus`(run_order=True)

    Return a list of LiveNovel text selection menus contained in this script.

    Parameters: | run_order (bool) – If True, menus will be returned in approximately the order they would be run in-game (via walk(). If False, text blocks will be returned in the order they occur in the LSB file.
    Returns: | (line_num, menu)
    Return type: | tuple(int, `BaseSelectionMenu`)

  `get_menu_choices`(run_order=True)

    Return selection menu choices contained in this script.

    Parameters: | run_order (bool) – If True, menus will be returned in approximately the order they would be run in-game (via walk(). If False, menus will be returned in the order they occur in the LSB file.
    Returns: | list of (identifier, choice) tuples

  `replace_menu_choices`(text_objects)

    Replace the specified text selection menu choices in this LSB.

    Parameters: | text_objects – Iterable containing (identifier, text) tuples

class `livemaker.lsb.``LNSCompiler`

  Bases: `_markupbase.ParserBase`

  Attempt to compile a LiveNovel LNS script into a TpWord block.

  Based on Python3 html.parser.HTMLParser.

  Note

  This is only intended to be used to compile scripts which have been decompiled by pylivemaker and then translated/edited for patching. Attempting to compile a script which was not initially generated by pylivemaker may not work as intended.

  `END_TAGS` = ('a', 'style', 'div')
  `reset`()

    Reset this instance. Loses all unprocessed data.

  `compile`(script)

    Compile a [decompiled] script into a TpWord block.

    Parameters: | script (str) – Script data

  `feed`(data)

    Feed data to the parser. Call this as often as you want, with as little or as much text as you want (may include ‘n’).

  `close`()

    Handle any buffered data.

  `get_starttag_text`()

    Return full source of start tag: ‘<…>’.

  `goahead`(end)
  `parse_starttag`(i)
  `check_for_whole_start_tag`(i)
  `parse_endtag`(i)
  `handle_eventtag`(tag, attrs)
  `handle_startendtag`(tag, attrs)
  `handle_starttag`(tag, attrs)
  `handle_endtag`(tag)
  `handle_data`(data)
  `unescape`(s)

class `livemaker.lsb.``LNSDecompiler`(sep='n', include_comments=True, text_only=False)

  Bases: `object`

  Attempt to decompile a TpWord text block into something that resembles LiveMaker’s LiveNovel scenario script format.

  Parameters: | sep (str) – Output line separator (defaults to `os.linesep`). include_comments (bool) – Include comment lines in output. text_only (bool) – Output text only (all tags will be removed except for variable names).
  Raises: | `ValueError` – If tpword is not a `TpWord` instance.

  `decompile`(tpword)

    Decompile the specified TpWord scenario script.

    Parameters: | tpword (`TpWord`) – TpWord object to decompile.