Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
refinements to issue #92, checking valid object ids needs to happen j…
Browse files Browse the repository at this point in the history
…ust before reading deferred sections.
  • Loading branch information
PaulDudaRESPEC committed Aug 20, 2019
1 parent 5fbd314 commit 44c17da
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/core/epanet/inp_reader_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,24 @@ def __init__(self):
def read_section(self, project, section_name, section_text):
section_name_upper = section_name.upper()
if section_name_upper == "[QUALITY]":
self.check_valid_node_id(project, 'QUALITY', section_text)
self.defer_quality = section_text
return # Skip read_section, defer until finished_reading is called.
elif section_name_upper == "[COORDINATES]":
self.check_valid_node_id(project, 'COORDINATES', section_text)
self.defer_coordinates = section_text
return # Skip read_section, defer until finished_reading is called.
elif section_name_upper == "[VERTICES]":
self.check_valid_link_id(project, 'VERTICES', section_text)
self.defer_vertices = section_text
return
elif section_name_upper == "[TAGS]":
self.defer_tags = section_text
return # Skip read_section, defer until finished_reading is called.
elif section_name_upper == "[MIXING]":
self.check_valid_node_id(project, 'MIXING', section_text)
self.defer_mixing = section_text
return # Skip read_section, defer until finished_reading is called.
elif section_name_upper == "[EMITTERS]":
self.check_valid_node_id(project, 'EMITTERS', section_text)
self.defer_emitters = section_text
return # Skip read_section, defer until finished_reading is called.
elif section_name_upper == "[STATUS]":
self.check_valid_link_id(project, 'STATUS', section_text)
self.defer_status = section_text
return
elif section_name_upper == "[CALIBRATIONS]":
Expand All @@ -105,24 +99,30 @@ def read_section(self, project, section_name, section_text):

def finished_reading(self, project):
if self.defer_quality:
self.check_valid_node_id(project, 'QUALITY', self.defer_quality)
QualityReader.read(self.defer_quality, project)
self.defer_quality = None
if self.defer_coordinates:
self.check_valid_node_id(project, 'COORDINATES', self.defer_coordinates)
CoordinatesReader.read(self.defer_coordinates, project)
self.defer_coordinates = None
if self.defer_vertices:
self.check_valid_link_id(project, 'VERTICES', self.defer_vertices)
VerticesReader.read(self.defer_vertices, project)
self.defer_vertices = None
if self.defer_tags:
TagsReader.read(self.defer_tags, project)
self.defer_tags = None
if self.defer_mixing:
self.check_valid_node_id(project, 'MIXING', self.defer_mixing)
MixingReader.read(self.defer_mixing, project)
self.defer_mixing = None
if self.defer_emitters:
self.check_valid_node_id(project, 'EMITTERS', self.defer_emitters)
EmittersReader.read(self.defer_emitters, project)
self.defer_emitters = None
if self.defer_status:
self.check_valid_link_id(project, 'STATUS', self.defer_status)
StatusReader.read(self.defer_status, project)
self.defer_status = None
project.metric = project.options.hydraulics.flow_units in flow_units_metric
Expand Down
18 changes: 12 additions & 6 deletions src/core/swmm/inp_reader_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,30 +188,30 @@ def read_section(self, project, section_name, section_text):
elif infiltration.startswith("CURVE"):
self.read_infiltration = SectionReaderAsList(section_name, CurveNumberInfiltrationReader)
elif section_name_upper == "[SUBAREAS]":
self.check_valid_subcatchment_id(project, 'SUBAREAS', section_text)
# self.check_valid_subcatchment_id(project, 'SUBAREAS', section_text)
self.defer_subareas = section_text
return # Skip read_section, defer until finished_reading is called.
elif section_name_upper == "[COORDINATES]":
self.check_valid_node_id(project, 'COORDINATES', section_text)
# self.check_valid_node_id(project, 'COORDINATES', section_text)
self.defer_coordinates = section_text
return # Skip read_section, defer until finished_reading is called.
elif section_name_upper == "[SYMBOLS]":
self.check_valid_raingage_id(project, 'SYMBOLS', section_text)
# self.check_valid_raingage_id(project, 'SYMBOLS', section_text)
self.defer_symbols = section_text
return # Skip read_section, defer until finished_reading is called.
elif section_name_upper == "[TAGS]":
self.defer_tags = section_text
return # Skip read_section, defer until finished_reading is called.
elif section_name_upper == "[LOSSES]":
self.check_valid_link_id(project, 'LOSSES', section_text)
# self.check_valid_link_id(project, 'LOSSES', section_text)
self.defer_losses = section_text
return
elif section_name_upper == "[VERTICES]":
self.check_valid_link_id(project, 'VERTICES', section_text)
# self.check_valid_link_id(project, 'VERTICES', section_text)
self.defer_vertices = section_text
return
elif section_name_upper == "[POLYGONS]":
self.check_valid_subcatchment_id(project, 'POLYGONS', section_text)
# self.check_valid_subcatchment_id(project, 'POLYGONS', section_text)
self.defer_polygons = section_text
return
elif section_name_upper == "[GROUNDWATER]":
Expand Down Expand Up @@ -262,24 +262,30 @@ def read_section(self, project, section_name, section_text):

def finished_reading(self, project):
if self.defer_subareas:
self.check_valid_subcatchment_id(project, 'SUBAREAS', self.defer_subareas)
SubareasReader.read(self.defer_subareas, project)
self.defer_subareas = None
if self.defer_coordinates:
self.check_valid_node_id(project, 'COORDINATES', self.defer_coordinates)
CoordinatesReader.read(self.defer_coordinates, project)
self.defer_coordinates = None
if self.defer_symbols:
self.check_valid_raingage_id(project, 'SYMBOLS', self.defer_symbols)
SymbolsReader.read(self.defer_symbols, project)
self.defer_symbols = None
if self.defer_tags:
TagsReader.read(self.defer_tags, project)
self.defer_tags = None
if self.defer_losses:
self.check_valid_link_id(project, 'LOSSES', self.defer_losses)
LossesReader.read(self.defer_losses, project)
self.defer_losses = None
if self.defer_vertices:
self.check_valid_link_id(project, 'VERTICES', self.defer_vertices)
VerticesReader.read(self.defer_vertices, project)
self.defer_vertices = None
if self.defer_polygons:
self.check_valid_subcatchment_id(project, 'POLYGONS', self.defer_polygons)
PolygonsReader.read(self.defer_polygons, project)
self.defer_polygons = None
project.metric = project.options.flow_units in flow_units_metric
Expand Down

0 comments on commit 44c17da

Please sign in to comment.