pyyeti.guitools.write_text_file¶
- pyyeti.guitools.write_text_file(wtfunc)[source]¶
Decorator that processes the file argument for writing
- Parameters:
wtfunc (function) – Function that writes text to a file. The first argument to that function is a file argument. The file argument can be the name of a file, or a file_like object as returned by
open()orio.StringIO(). It can also be input as the integer 1 to write to stdout (or usesys.stdout). Finally, it can also be the name of a directory or None; in these cases, a GUI is opened for file selection. To write to a string,import ioand setf = io.StringIO(); afterwards, retrieve string byf.getvalue(). For example, seepyyeti.nastran.bulk.wtgrids().- Returns:
function – Function that processes the file argument before calling wtfunc.
See also
Examples
>>> from pyyeti.guitools import write_text_file >>> @write_text_file ... def dowrite(f, string, number): ... f.write(f'{string} = {number:.3f}\n') >>> dowrite(1, 'param', number=45.3) param = 45.300