Example #1
0
 def read(new_text):
     times_options = TimesOptions()
     for line in new_text.splitlines():
         try:
             SectionReader.set_text_line(times_options, line)
         except:
             print("TimesOptionsReader skipping input line: " + line)
     return times_options
Example #2
0
 def read(new_text):
     energy_options = EnergyOptions()
     for line in new_text.splitlines():
         try:
             line = SectionReader.set_comment_check_section(energy_options, line)
             fields = line.split()
             if len(fields) > 1:
                 if fields[0].upper() == "PUMP":
                     energy_options.pumps.append(PumpEnergyReader.read(line))
                 else:
                     SectionReader.set_text_line(energy_options, line)
         except:
             print("BackdropOptions skipping input line: " + line)
     return energy_options
Example #3
0
 def read(new_text):
     """Read properties from text.
         Args:
             new_text (str): Text to parse into properties.
     """
     reactions = Reactions()
     # Replace "zero" (any capitalization) with numeral 0
     zero_pos = new_text.upper().find("ZERO")
     while zero_pos >= 0:
         new_text = new_text[:zero_pos] + '0' + new_text[zero_pos + len("ZERO"):]
         zero_pos = new_text.upper().find("ZERO", zero_pos)
     for line in new_text.splitlines():
         upper_line = line.upper().strip()
         if upper_line.startswith("BULK") or upper_line.startswith("WALL") or upper_line.startswith("TANK"):
             reactions.value.append(upper_line)
             #reactions.comment += '\n' + line  # TODO: parse into table of per pipe values
         else:
             SectionReader.set_text_line(reactions, line)
     return reactions