PyFunceble/helpers.py
def write(self, data_to_write, overwrite=False):
        """
        Write or append data into the given file path.

        :param data_to_write: The data to write.
        :type data_to_write: str

        :param overwrite:
            Tell us if we have to overwrite the
            content of the file we are working with.
        :type overwrite: bool
        """

        if overwrite or not path.isfile(self.file):
            # * We have to overwrite the file data.
            # or
            # * The file path does not already exist.

            with open(self.file, "w", encoding="utf-8", newline="\n") as file:
                # We prepare the file for writting.

                if data_to_write and isinstance(data_to_write, str):
                    # * A data  to write is given.
                    # and
                    # * The data to write is a string

                    # We write the string into the file.
                    file.write(data_to_write)
        else:
            # * We do not have to overwrite the file data.
            # or
            # * The file path does already exist.

            with open(self.file, "a", encoding="utf-8", newline="\n") as file:
                # We prepare the file for append writting.

                if data_to_write and isinstance(data_to_write, str):
                    # * A data  to write is given.
                    # and
                    # * The data to write is a string

                    # We append the string into the file.
                    file.write(data_to_write)
def write(self, data_to_write, overwrite=False):
        if overwrite or not path.isfile(self.file):
            # * We have to overwrite the file data.
            # or
            # * The file path does not already exist.

            with open(self.file, "w", encoding="utf-8", newline="\n") as file:
                # We prepare the file for writting.

                if data_to_write and isinstance(data_to_write, str):
                    # * A data  to write is given.
                    # and
                    # * The data to write is a string

                    # We write the string into the file.
                    file.write(data_to_write)
        else:
            # * We do not have to overwrite the file data.
            # or
            # * The file path does already exist.

            with open(self.file, "a", encoding="utf-8", newline="\n") as file:
                # We prepare the file for append writting.

                if data_to_write and isinstance(data_to_write, str):
                    # * A data  to write is given.
                    # and
                    # * The data to write is a string

                    # We append the string into the file.
                    file.write(data_to_write)
def write ( self , data_to_write , overwrite = False ) : if overwrite or not path . isfile ( self . file ) : # * We have to overwrite the file data. # or # * The file path does not already exist. with open ( self . file , "w" , encoding = "utf-8" , newline = "\n" ) as file : # We prepare the file for writting. if data_to_write and isinstance ( data_to_write , str ) : # * A data  to write is given. # and # * The data to write is a string # We write the string into the file. file . write ( data_to_write ) else : # * We do not have to overwrite the file data. # or # * The file path does already exist. with open ( self . file , "a" , encoding = "utf-8" , newline = "\n" ) as file : # We prepare the file for append writting. if data_to_write and isinstance ( data_to_write , str ) : # * A data  to write is given. # and # * The data to write is a string # We append the string into the file. file . write ( data_to_write )
Write or append data into the given file path.

        :param data_to_write: The data to write.
        :type data_to_write: str

        :param overwrite:
            Tell us if we have to overwrite the
            content of the file we are working with.
        :type overwrite: bool
Write or append data into the given file path .