fitzzftw.patch.lines.FileLine¶
---
config:
height: 300px
width: 300px
title: FileLine
---
classDiagram
PatchLine <|-- FileLine
Inheritage diagramm for FileLine¶
- class FileLine[source]¶
Bases:
PatchLineRepresents 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
contentproperty.Public Data Attributes:
The raw line content, stripped of the diff prefix and trailing newline (ro).
The line content, dynamically normalized according to the --normalize-ws rule (ro).
The line content, dynamically normalized according to the --ignore-all-ws rule (ro).
The diff prefix character (' ', '+', or '-') (ro).
Indicates if the original raw line contained trailing whitespace before the newline (ro).
Checks if the line content is an empty string (ro).
Get the processed line for filesystem output (ro).
State of the newline termination at the end of the line ((rw)).
Public Methods:
__init__(raw_line)Initializes the FileLine instance.
__repr__()Return repr(self).
- __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.