<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_source_attributes(source):
 """ Retreives a dictionary of source attributes from the source class :param source: Seismic source as instance of :class: `openquake.hazardlib.source.base.BaseSeismicSource` :returns: Dictionary of source attributes """

    attrs = {"id": source.source_id,
             "name": source.name,
             "tectonicRegion": source.tectonic_region_type}
    if isinstance(source, NonParametricSeismicSource):
        if source.data[0][0].weight is not None:
            weights = []
            for data in source.data:
                weights.append(data[0].weight)
            attrs['rup_weights'] = numpy.array(weights)
    print(attrs)
    return attrs