def save(self, polyfile, ret_fobj=False):
        """Save all data to a text file (appends data if file exists).

        Polyfile can be either a path to a file or a file object that
        was opened with the write "w" parameter. By using the file
        object, multiple instances of this class can write their data.

        If `ret_fobj` is `True`, then the file object will not be
        closed and returned.
        """
        if is_file_obj(polyfile):
            fobj = polyfile
        else:
            fobj = pathlib.Path(polyfile).open("a")

        # Who the hell would use more then 10 million polygons or
        # polygon points? -> 08d (easier if other people want to import)
        data2write = []
        data2write.append("[Polygon {:08d}]".format(self.unique_id))
        data2write.append("X Axis = {}".format(self.axes[0]))
        data2write.append("Y Axis = {}".format(self.axes[1]))
        data2write.append("Name = {}".format(self.name))
        data2write.append("Inverted = {}".format(self.inverted))
        for i, point in enumerate(self.points):
            data2write.append("point{:08d} = {:.15e} {:.15e}".format(i,
                                                                     point[0],
                                                                     point[1]))
        # Add new lines
        for i in range(len(data2write)):
            data2write[i] += "\n"

        # begin writing to fobj
        fobj.writelines(data2write)

        if ret_fobj:
            return fobj
        else:
            fobj.close()
def save ( self , polyfile , ret_fobj = False ) : if is_file_obj ( polyfile ) : fobj = polyfile else : fobj = pathlib . Path ( polyfile ) . open ( "a" ) data2write = [ ] data2write . append ( "[Polygon {:08d}]" . format ( self . unique_id ) ) data2write . append ( "X Axis = {}" . format ( self . axes [ 0 ] ) ) data2write . append ( "Y Axis = {}" . format ( self . axes [ 1 ] ) ) data2write . append ( "Name = {}" . format ( self . name ) ) data2write . append ( "Inverted = {}" . format ( self . inverted ) ) for i , point in enumerate ( self . points ) : data2write . append ( "point{:08d} = {:.15e} {:.15e}" . format ( i , point [ 0 ] , point [ 1 ] ) ) for i in range ( len ( data2write ) ) : data2write [ i ] += "\n" fobj . writelines ( data2write ) if ret_fobj : return fobj else : fobj . close ( )
Save all data to a text file (appends data if file exists).

        Polyfile can be either a path to a file or a file object that
        was opened with the write "w" parameter. By using the file
        object, multiple instances of this class can write their data.

        If `ret_fobj` is `True`, then the file object will not be
        closed and returned.