Selfie
Loading...
Searching...
No Matches
selfie_lib.ConvertToWindowsNewlines.ConvertToWindowsNewlines Class Reference

Public Member Functions

 __init__ (self, sink)
 
 append (self, value, start_index=None, end_index=None)
 

Public Attributes

 sink
 

Detailed Description

Definition at line 1 of file ConvertToWindowsNewlines.py.

Constructor & Destructor Documentation

◆ __init__()

selfie_lib.ConvertToWindowsNewlines.ConvertToWindowsNewlines.__init__ (   self,
  sink 
)

Definition at line 2 of file ConvertToWindowsNewlines.py.

2 def __init__(self, sink):
3 self.sink = sink
4

Member Function Documentation

◆ append()

selfie_lib.ConvertToWindowsNewlines.ConvertToWindowsNewlines.append (   self,
  value,
  start_index = None,
  end_index = None 
)

Definition at line 5 of file ConvertToWindowsNewlines.py.

5 def append(self, value, start_index=None, end_index=None):
6 # If value is a single character
7 if isinstance(value, str) and len(value) == 1:
8 if value != "\n":
9 self.sink.write(value)
10 else:
11 self.sink.write("\r\n")
12 # If value is a CharSequence (in Python, a str)
13 elif isinstance(value, str):
14 # If start_index and end_index are provided, use the slice of the string
15 if start_index is not None and end_index is not None:
16 value_to_append = value[start_index:end_index]
17 else:
18 value_to_append = value
19 self.sink.write(value_to_append.replace("\n", "\r\n"))
20 return self

Member Data Documentation

◆ sink

selfie_lib.ConvertToWindowsNewlines.ConvertToWindowsNewlines.sink

Definition at line 3 of file ConvertToWindowsNewlines.py.


The documentation for this class was generated from the following file: