gem/nrml — pull request #57 by micheles (2012-11-30 07:49:19+00:00)
Title: Work on the Rupture parsers

I just pushed my work on the parsers for simpleFaultRupture and complexFaultRupture.

Notice that I am still waiting for the official example files from Damiano,
so I wrote something that works with the current example files.
Some changes to rupture.xsd will be necessary when I get the new example files,
but however the 95% of the work is done.

I prefer to perform an early push so that Lars can have a look and
give some feedback on the approach I am following.

For instance a possibility was to write two parser classes, one for
the SimpleFaultRupture and one for the ComplexFaultRupture. But
looking at how the SourceModelParser is done, I decided to follow
that closely, so there is a single class which is able
to parse both kind of files via a _parse_fn_map dispatching
to different methods, something like

self._parse_fn_map = {
self._SIMPLE_RUPT_TAG: self._parse_simple_rupture,
self._COMPLEX_RUPT_TAG: self._parse_complex_rupture,
}

This avoids writing two nearly identical classes and it is easy
to extend if in the future we want to add the PointFaultRupture
and ArbitrarilyComplexFaultRupture. I have also reused the
parsing of SimpleFaultGeometry and ComplexFaultGeometry performed
in the SourceModelParser by putting the two methods in a mixin
class (even if my adversion against mixins is well known).

The idea here was to be as close as possible to the current design.