def read(new_text): controls = Control() lines = new_text.replace(ControlReader.SECTION_NAME, '').strip().splitlines() if len(lines) > 0: first_line = lines[0] if first_line[0] <> ' ': lines[0] = ' ' + lines[0] controls.value = '\n'.join(lines[0:]) return controls
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[]
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.