ToDonePy Submodules¶
Module contents¶
Function definitions for ToDonePy
Class: Filer¶
-
class
ToDonePy.filer.
Filer
(path: pathlib.Path, create: bool = True)¶ Bases:
object
A class for gracefully handling file interactions
Designed particularly for passing context in a Click program.
- Path
A Unix filepath to the desired file
- Create
If the file does not already exist, create it.
-
append
(rows: List[List[str]]) → None¶ Appends contents of rows to self.path.
Contents of self.path will not be overwritten, if it exists.
rows is a list of lists. rows[0] is line 1, rows[0][0] is is line 1, column 1
- Rows
An list of strings to write to self.path
- Returns
None
-
delete
(contains: str) → bool¶ Deletes all lines from self where
contains in line
- Contains
string to use for line deletion
- Returns
True, if successful, false otherwise
-
read
() → List[List[str]]¶ Read the lines of self.path
- Note
Reads in all lines, so will suffer on large files
- Returns
A list of lines where each line is a list
of column values
-
sort
(cols: List[int]) → None¶ Sort the contents of self by columns
- Cols
List of columns, 0-indexed, to sort by
- Returns
None
-
write
(rows: List[List[str]]) → None¶ Writes contents of rows to self.path.
If the file exists, it overwrites.
rows is a list of lists. rows[0] is line 1, rows[0][0] is is line 1, column 1
- Rows
An list of strings to write to self.path
- Returns
None
Function: counted_list¶
-
ToDonePy.counted_list.
counted_list
(lines: List[List[str]], number: int, connector: str) → List[str]¶ Safely iterate over lists of unknown length
- Lines
List containing items to be echoed
- Number
Number of strings to be echoed
- Connector
For pretty printing. What to join entries with
- Returns
List of lines for echoing
Function: file_len¶
-
ToDonePy.file_len.
file_len
(file: pathlib.Path) → int¶ Find the number of lines in a file
- File
Path to the file
- Returns
Number of lines in a file