Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
weilycoder committed Nov 20, 2024
1 parent 8ec974f commit 26e5b8d
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions cyaron/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Classes:
IO: IO tool class. It will process the input and output files.
"""

from __future__ import absolute_import
import os
import re
Expand Down Expand Up @@ -201,6 +202,10 @@ def __write(self, file: IOBase, *args, **kwargs):
self.is_first_char[file] = True

def __write_list(self, file: IOBase, *args, **kwargs):
"""
Write every element in *args into file. If the element isn't "\n", insert `separator`.
It will convert every element into str.
"""
separators = kwargs.get("separator", " ")
if list_like(separators):
if len(separators) == 0:
Expand Down Expand Up @@ -255,9 +260,26 @@ def input_writeln(self, *args, **kwargs):
self.input_write(*args, **kwargs)

def input_write_list(self, *args, **kwargs):
"""
Write hith-dimensional lists in *args into the input file. Splits with `separator`.
It will convert every element into str.
Args:
*args: hith-dimensional lists to write
separator: a string or a string list used to separate every element in different
dimension. Defaults to " ".
"""
self.__write_list(self.input_file, *args, **kwargs)

def input_write_listln(self, *args, **kwargs):
"""
Write hith-dimensional lists in *args into the input file and turn into a new line
Splits with `separator`.
It will convert every element into str.
Args:
*args: hith-dimensional lists to write
separator: a string or a string list used to separate every element in different
dimension. Defaults to " ".
"""
self.input_write_list(*args, "\n", **kwargs)

def input_clear_content(self, pos: int = 0):
Expand Down Expand Up @@ -330,9 +352,26 @@ def output_writeln(self, *args, **kwargs):
self.output_write(*args, **kwargs)

def output_write_list(self, *args, **kwargs):
"""
Write hith-dimensional lists in *args into the output file. Splits with `separator`.
It will convert every element into str.
Args:
*args: hith-dimensional lists to write
separator: a string or a string list used to separate every element in different
dimension. Defaults to " ".
"""
self.__write_list(self.output_file, *args, **kwargs)

def output_write_listln(self, *args, **kwargs):
"""
Write hith-dimensional lists in *args into the output file and turn into a new line
Splits with `separator`.
It will convert every element into str.
Args:
*args: hith-dimensional lists to write
separator: a string or a string list used to separate every element in different
dimension. Defaults to " ".
"""
self.output_write_list(*args, "\n", **kwargs)

def output_clear_content(self, pos: int = 0):
Expand Down

0 comments on commit 26e5b8d

Please sign in to comment.