inpString¶
Module Contents¶
- class inpString.inpString(inputStr, ss=False)¶
Bases:
strAn
inpStringobject behaves like a regularstr, except it will internally store the string value without any leading or trailing spaces (Abaqus is space-insensitive regarding leading or trailing spaces in names). This class will track the leading and trailing spaces using interned string patterns, which will be used to reproduce the original string exactly.- static __new__(inputStr, ss=False)¶
- __init__(inputStr, ss)¶
Creates the
inpStringinstance.This is meant to operate on text which corresponds to a single string item. For example, a set name, a parameter name, etc. Thus, in most cases inputStr should be a single word with surrounding whitespace. The only time inputStr should contain a space between alphanumeric characters is when the value of interest is a quoted string and includes spaces between words.
Example usage:
>>> from inpString import inpString >>> inpString(' Nodeset-1') inpString(' Nodeset-1', False)
If we desire to remove trailing and leading spaces, we can set ss = True:
>>> inpString(' Nodeset-1', ss=True) inpString('Nodeset-1', True)
- ss¶
If True, leading and trailing spaces will be permanently removed from inputStr. Defaults to False.
- Type:
- _value¶
Stores the non-whitespace information of inputStr. Defaults to None
- _formatStr¶
Stores the whitespace information of inputStr, with placeholder symbols (“%s”) where
_valueshould be reinserted. Defaults to None
- _evalString(inputStr)¶
_evalString(inputStr)
Evaluates the input string and performs some formatting. This will separate whitespace from alphanumeric characters, but it will leave spaces between alphanumeric characters.
This will set
_valueand_formatStr, but the function has no direct return.Here’s an example of the
_valueand_formatStrattributes for a simple case:>>> from inpString import inpString >>> s1 = inpString(' Nodeset-1') >>> s1._value 'Nodeset-1' >>> s1._formatStr ' %s'
Here are the same attributes when ss = True:
>>> s2 = inpString(' Nodeset-1', ss=True) >>> s2._value 'Nodeset-1' >>> s2._formatStr '%s'
Finally, if we have a quoted string with spaces, the spaces inside the quotes are included with
_valuebecause they’re meaningful. The spaces outside the quotes are tracked in_formatStras usual:>>> s3 = inpString(' "Nodeset Name with Spaces"') >>> s3._value '"Nodeset Name with Spaces"' >>> s3._formatStr ' %s'
- _outstr()¶
Generates the output string.
_valueis subbed into_formatStr. Should not need to be called by the user directly.Example usage:
>>> from inpString import inpString >>> s = inpString(' Nodeset-1') >>> s._outstr() ' Nodeset-1'
This function can also handle cases where inputStr to
__init__()was only whitespace:>>> s = inpString(' ') >>> s._outstr() ' '
- Returns:
The string in the original formatting.
- Return type:
- __str__()¶
Calls
_outstr()to create a string of object in the original formatting.Example usage:
>>> from inpString import inpString >>> print(inpString(' Nodeset-1')) Nodeset-1
- Return type:
- __repr__()¶
Creates a string representation which can be used to recreate the object.
Example usage:
>>> from inpString import inpString >>> inpString(' Nodeset-1') inpString(' Nodeset-1', False)
- Return type:
- __getnewargs__()¶
__getnewargs__():
This function is required so the class can pickle/unpickle properly. This enables multiprocessing, and should not need to be called by the user.
Example usage:
>>> from inpString import inpString >>> s = inpString(' Nodeset-1') >>> s.__getnewargs__() (' Nodeset-1', False)
- __weakref__¶
list of weak references to the object (if defined)