Skip to content

Commit

Permalink
Add descriptions to impl tags within the flags module
Browse files Browse the repository at this point in the history
  • Loading branch information
keckler committed Jan 22, 2024
1 parent e9c8536 commit b296074
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions armi/reactor/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,17 @@ def fromString(cls, typeSpec):
.. impl:: Retrieve flag from a string.
:id: I_ARMI_FLAG_TO_STR0
:implements: R_ARMI_FLAG_TO_STR
For a string passed as ``typeSpec``, first converts the whole string
to uppercase.
Then tries to parse the string for any special phrases, as defined
in the module dictionary ``_CONVERSIONS``, and converts those phrases
to flags directly.
Then splits the remaining string into separate words based on the presence
of spaces. Looping over each of the words, any numbers are stripped out
and the remaining string is matched up to any class attribute names.
If any matches are found these are returned as flags.
"""

def updateMethod(typeSpec):
Expand All @@ -281,6 +292,12 @@ def toString(cls, typeSpec):
.. impl:: Convert a flag to string.
:id: I_ARMI_FLAG_TO_STR1
:implements: R_ARMI_FLAG_TO_STR
This converts the representation of a bunch of flags from ``typeSpec``,
which might look like ``Flags.A|B``,
into a string with spaces in between the flag names, which would look
like ``'A B'``. This is done via nesting string splitting and replacement
actions.
"""
return str(typeSpec).split("{}.".format(cls.__name__))[1].replace("|", " ")

Expand Down

0 comments on commit b296074

Please sign in to comment.