Example #1
0
 def read(new_text):
     """Read this section from the text representation"""
     report_options = ReportOptions()
     lines = new_text.splitlines()
     for line in lines:
         line = SectionReader.set_comment_check_section(report_options, line)
         if line:
             (attr_name, attr_value) = line.split(None, 1)
             attr_name = attr_name.upper()
             if attr_name == "NODES":
                 report_options.nodes.extend(attr_value.split())
             elif attr_name == "LINKS":
                 report_options.links.extend(attr_value.split())
             elif attr_name == "STATUS":
                 report_options.setattr_keep_type("status", attr_value)
             elif attr_name == "FILE":
                 report_options.file = attr_value
             elif attr_name == "SUMMARY":
                 report_options.setattr_keep_type("summary", attr_value)
             elif attr_name == "PAGESIZE" or attr_name == "PAGE":
                 report_options.pagesize = attr_value
             elif attr_name == "ENERGY":
                 report_options.setattr_keep_type("energy", attr_value)
             else:
                 report_options.parameters.append(line)
     return report_options
    def __init__(self):
        """Initialize the sections of an EPANET input file.
           Any sections not initialized here will be handled by the generic core.project_base.Section class."""
        self.title = Title()
        self.junctions = SectionAsList("[JUNCTIONS]")  # (list of Junction)
        self.reservoirs = SectionAsList("[RESERVOIRS]")  # (list of Reservoir)
        self.tanks = SectionAsList("[TANKS]")  # (list of Tank)
        self.pipes = SectionAsList("[PIPES]")  # (list of Pipe)
        self.pumps = SectionAsList("[PUMPS]")  # (list of Pump)
        self.valves = SectionAsList("[VALVES]")  # (list of Valve)
        # self.emitters = [(Junction, "emitter_coefficient")]
        self.patterns = SectionAsList("[PATTERNS]")  # (list of Pattern)
        self.curves = SectionAsList("[CURVES]")  # (list of Curve)
        self.energy = EnergyOptions()
        self.status = SectionAsList("[STATUS]")  # (list of Status)
        self.controls = Control()
        self.rules = Rule()
        self.demands = SectionAsList("[DEMANDS]")  # (list of Demand)
        self.reactions = Reactions()
        self.sources = SectionAsList("[SOURCES]")  # (list of Source)
        # self.options = MapOptions,
        self.options = Options()
        self.times = TimesOptions()
        self.report = ReportOptions()
        self.labels = SectionAsList("[LABELS]")  # (list of Label)
        self.backdrop = BackdropOptions()
        self.calibrations = SectionAsList(
            "[CALIBRATIONS]")  # (list of Calibration)

        ProjectBase.__init__(
            self
        )  # Do this after setting attributes so they will all get added to sections[]
Example #3
0
    def __init__(self):
        """Initialize the sections of an EPANET input file.
           Any sections not initialized here will be handled by the generic core.project_base.Section class."""
        ProjectBase.__init__(self)

        self.title = Title()
        self.backdrop = BackdropOptions()       # BACKDROP      bounding rectangle and file name of backdrop image
        self.map = MapOptions()                 # MAP           map's bounding rectangle and units
        self.junctions = SectionAsList("[JUNCTIONS]")  # (list of Junction)
        self.reservoirs = SectionAsList("[RESERVOIRS]")  # (list of Reservoir)
        self.tanks = SectionAsList("[TANKS]")  # (list of Tank)
        self.pipes = SectionAsList("[PIPES]")  # (list of Pipe)
        self.pumps = SectionAsList("[PUMPS]")  # (list of Pump)
        self.valves = SectionAsList("[VALVES]")  # (list of Valve)
        # self.emitters = [(Junction, "emitter_coefficient")]
        self.patterns = SectionAsList("[PATTERNS]")  # (list of Pattern)
        self.curves = SectionAsList("[CURVES]")  # (list of Curve)
        self.energy = EnergyOptions()
        self.status = SectionAsList("[STATUS]")  # (list of Status)
        self.controls = Control()
        self.rules = Rule()
        self.demands = SectionAsList("[DEMANDS]")  # (list of Demand)
        self.reactions = Reactions()
        self.sources = SectionAsList("[SOURCES]")  # (list of Source)
        # self.options = MapOptions,
        self.options = Options()
        self.times = TimesOptions()
        self.report = ReportOptions()
        self.labels = SectionAsList("[LABELS]")  # (list of Label)
        self.backdrop = BackdropOptions()
        self.calibrations = SectionAsList("[CALIBRATIONS]") # (list of Calibration)

        self.sections = [
            self.title,
            self.options,
            self.report,
            self.junctions,
            self.tanks,
            self.reservoirs,
            self.pipes,
            self.pumps,
            self.valves,
            self.controls,
            self.patterns,
            self.curves,
            self.backdrop,
            self.map,
            self.labels]  # Start with a sensible order of sections.
        self.add_sections_from_attributes()  # Add any sections not added in the line above, should not be any left.