fitzzftw.patch.lines.FileLine

        ---
config:
  height: 300px
  width: 300px

title: FileLine
---
classDiagram
  PatchLine <|-- FileLine
    

Inheritage diagramm for FileLine

class FileLine[source]

Bases: PatchLine

Represents a single line read from a file or contained within a patch hunk.

The primary responsibility is to handle the line content and its associated prefix (if it comes from a patch) consistently, especially by immediately stripping the trailing newline character upon initialization.

The actual content, free of the trailing newline, is exposed via the content property.

Public Data Attributes:

content

The raw line content, stripped of the diff prefix and trailing newline (ro).

normalized_ws_content

The line content, dynamically normalized according to the --normalize-ws rule (ro).

ignore_all_ws_content

The line content, dynamically normalized according to the --ignore-all-ws rule (ro).

prefix

The diff prefix character (' ', '+', or '-') (ro).

has_trailing_whitespace

Indicates if the original raw line contained trailing whitespace before the newline (ro).

is_empty

Checks if the line content is an empty string (ro).

line_string

Get the processed line for filesystem output (ro).

has_newline

State of the newline termination at the end of the line ((rw)).

Inherited from PatchLine

content

The cleaned content of the line without trailing newlines (ro).

orig_line

The original of the line without trailing newlines (ro).

has_trailing_whitespace

Public Methods:

__init__(raw_line)

Initializes the FileLine instance.

__repr__()

Return repr(self).

Inherited from PatchLine

__init__(raw_line)

Initializes a PatchLine instance by sanitizing the input.

__repr__()

Return repr(self).

Private Data Attributes:

_INTERNAL_WS_RE

_ALL_WS_RE

Inherited from PatchLine

_TRAIL_WS_RE


__init__(raw_line)[source]

Initializes the FileLine instance.

The raw line content is processed immediately: the trailing newline character is removed, and the cleaned content is stored internally. This prevents issues where the newline character interferes with hunk application logic.

Parameters:

raw_line (str) – The complete, unmodified line string, typically including a trailing newline.

property content: str

The raw line content, stripped of the diff prefix and trailing newline (ro).

This value is used for standard matching when no whitespace flags are set.

Returns:

The cleaned line content as a string.

property has_newline: bool

State of the newline termination at the end of the line ((rw)).

Parameters:

value – Set to False if the line lacks a trailing newline.

Returns:

True if the line ends with a newline, False otherwise.

property has_trailing_whitespace: bool

Indicates if the original raw line contained trailing whitespace before the newline (ro).

Returns:

Boolean value.

property ignore_all_ws_content: str

The line content, dynamically normalized according to the –ignore-all-ws rule (ro).

All forms of whitespace (leading, internal, trailing) are removed from the string.

Returns:

The string content with all whitespace removed.

property is_empty: bool

Checks if the line content is an empty string (ro).

Returns:

True if the line content is empty, False otherwise.

property line_string: str

Get the processed line for filesystem output (ro).

The returned string includes the original line terminator only if the source line had one. This ensures that files without a trailing newline (e.g., at the end of the file) are reconstructed identically to their original or patched state.

Returns:

The content string, optionally suffixed with a newline.

property normalized_ws_content: str

The line content, dynamically normalized according to the –normalize-ws rule (ro).

Internal whitespace runs collapse to a single space; trailing whitespace is removed; leading whitespace is preserved.

Returns:

The normalized string used for matches.

property orig_line: str

The original of the line without trailing newlines (ro).

Returns:

A string representing the text content of the line.

property prefix: str

The diff prefix character (’ ‘, ‘+’, or ‘-’) (ro).

Returns:

The prefix character.