pyyeti.nastran.bulk.mkcomment

pyyeti.nastran.bulk.mkcomment(comment, width=72, start='$ ', surround=True)[source]

Formats a string into a Nastran comment with wrapping.

Parameters:
  • comment (string) – The string to write out, wrapping to width characters.

  • width (integer; optional) – Specify maximum line length.

  • start (string; optional) – String (i.e. “$ “, “# “) to start each comment line with.

  • surround (bool; optional) – If True, a leading and trailing blank comment line will be included.

Returns:

string – The formatted comment.

Notes

Uses the Python function textwrap.fill() to format the string.

Examples

>>> from pyyeti import nastran
>>> s = ('This is a long comment string to '
...      'demonstrate the wrapping feature of '
...      'this algorithm. It wraps to 72 '
...      'characters by default, but that can '
...      'changed by the user via the `width` '
...      'option. The default start for each '
...      'line is "$ ", but that can be changed '
...      'as well.')
>>> print(nastran.mkcomment(s, width=55), end='')
$
$ This is a long comment string to demonstrate the
$ wrapping feature of this algorithm. It wraps to 72
$ characters by default, but that can changed by the
$ user via the `width` option. The default start for
$ each line is "$ ", but that can be changed as well.
$