-
Notifications
You must be signed in to change notification settings - Fork 0
Python class
Flav20 edited this page Feb 19, 2025
·
8 revisions
If we translate the rust into python, we'll have:
class WithEOL:
# head: Read the n first lines
# if n > (numbers of lines in the file) => return the whole file
def head(path: str, n: int, \
remove_empty_string: bool = False, \
regex_keep: list = [] \
regex_pass: list = [] \
restrict: bool = True):
...
# between: Read the lines [n1, n2]
# if n1 > n2 => return an empty list
# if n1 > (numbers of lines in the file) => return an empty list
def between(path: str, n1: int, n2: int \
remove_empty_string: bool = False, \
regex_keep: list = [] \
regex_pass: list = [] \
restrict: bool = True):
...
# tail: Read the n last lines
# if n > (numbers of lines in the file) => return the whole file
def tail(path: str, n: int, \
remove_empty_string: bool = False, \
regex_keep: list = [] \
regex_pass: list = [] \
restrict: bool = True):
...
# parse: Read the whole file
def parse(path: str, \
remove_empty_string: bool = False \
regex_keep: list = [] \
regex_pass: list = []):
...
# Count the number of lines
def count_lines(path: str \
remove_empty_string: bool = False, \
regex_keep: list = [] \
regex_pass: list = []):
...
class WithCustomDelims:
# head: Read the n first lines
# if n > (numbers of lines in the file) => return the whole file
def head(path: str, n: int, delimiter: list \
remove_empty_string: bool = False, \
regex_keep: list = [] \
regex_pass: list = [] \
restrict: bool = True \
buffer_size: int = 1024):
...
# between: Read the lines [n1, n2]
# if n1 > n2 => return an empty list
# if n1 > (numbers of lines in the file) => return an empty list
def between(path: str, n1: int, n2: int, delimiter: list \
remove_empty_string: bool = False, \
regex_keep: list = [] \
regex_pass: list = [] \
restrict: bool = True \
buffer_size: int = 1024):
...
# tail: Read the n last lines
# if n > (numbers of lines in the file) => return the whole file
def tail(path: str, n: int, delimiter: list \
remove_empty_string: bool = False, \
regex_keep: list = [] \
regex_pass: list = [] \
restrict: bool = True \
buffer_size: int = 1024):
...
# parse: Read the whole file
def parse(path: str, delimiter: list \
remove_empty_string: bool = False \
regex_keep: list = [] \
regex_pass: list = [] \
buffer_size: int = 1024):
...
# Count the number of lines
def count_lines(path: str, delimiter: list \
remove_empty_string: bool = False, \
regex_keep: list = [] \
regex_pass: list = [] \
buffer_size: int = 1024):
...