def update_source_model(sm_node, fname):
    """
    :param sm_node: a sourceModel Node object containing sourceGroups
    """
    i = 0
    for group in sm_node:
        if 'srcs_weights' in group.attrib:
            raise InvalidFile('srcs_weights must be removed in %s' % fname)
        if not group.tag.endswith('sourceGroup'):
            raise InvalidFile('wrong NRML, got %s instead of '
                              'sourceGroup in %s' % (group.tag, fname))
        psrcs = []
        others = []
        for src in group:
            try:
                del src.attrib['tectonicRegion']  # make the trt implicit
            except KeyError:
                pass  # already missing
            if src.tag.endswith('pointSource'):
                psrcs.append(src)
            else:
                others.append(src)
        others.sort(key=lambda src: (src.tag, src['id']))
        i, sources = _pointsources2multipoints(psrcs, i)
        group.nodes = sources + others
def update_source_model ( sm_node , fname ) : i = 0 for group in sm_node : if 'srcs_weights' in group . attrib : raise InvalidFile ( 'srcs_weights must be removed in %s' % fname ) if not group . tag . endswith ( 'sourceGroup' ) : raise InvalidFile ( 'wrong NRML, got %s instead of ' 'sourceGroup in %s' % ( group . tag , fname ) ) psrcs = [ ] others = [ ] for src in group : try : del src . attrib [ 'tectonicRegion' ] except KeyError : pass if src . tag . endswith ( 'pointSource' ) : psrcs . append ( src ) else : others . append ( src ) others . sort ( key = lambda src : ( src . tag , src [ 'id' ] ) ) i , sources = _pointsources2multipoints ( psrcs , i ) group . nodes = sources + others
:param sm_node: a sourceModel Node object containing sourceGroups