示例#1
0
def generate_movement(fields, current_row):
    mvt_values = {}
    mvt_piece = []
    mvt_parts = []
    title = ws.cell(column=(fields.index('movement')), row=current_row).value
    piece_title = ws.cell(column=(fields.index('piece')), row=current_row).value
    cmp = ws.cell(column=(fields.index('composer')), row=current_row).value
    fn = cmp.split(', ')[1]
    ln = cmp.split(', ')[0]
    composer_name = "{0} {1}".format(fn, ln)
    try:
        # If Movement exists don't recreate it
        Movement.objects.filter(piece__title__iexact=piece_title).get(title__iexact=title)
    except Movement.DoesNotExist:
        # If Movement doesn't exist, make it
        for field in MOVEMENT_FIELDS:
            cell_value = ws.cell(column=(fields.index(field)), row=current_row).value
            if field == 'piece':
                try:
                    mvt_piece.append(Piece.objects.filter(composer__title__iexact=composer_name).get(title__iexact=piece_title))
                except Piece.DoesNotExist:
                    continue
            elif field == 'parts':
                mvt_parts = generate_parts(current_row, cell_value.split(', '))
            else:
                mvt_values[field] = cell_value
        new_mvt = Movement(title=title)
        new_mvt.piece = mvt_piece[0]
        new_mvt.save()
        for part in mvt_parts:
            new_mvt.parts.add(part)
        new_mvt.save()
        print("Movement is not in data set - New Movement created: {0}".format(title))
        return
    return
示例#2
0
    catalog_type=" ",
    catalog_number=0,
    piece_year=0,
)
sym8.save()
sym2 = Piece(title="Symphony No 2", composer=sibelius, publisher=" ", catalog_type=" ", catalog_number=0, piece_year=0)
sym2.save()
vlast = Piece(title="Ma Vlast", composer=smetana, publisher=" ", catalog_type=" ", catalog_number=0, piece_year=0)
vlast.save()
bride = Piece(
    title="The Bartered Bride", composer=smetana, publisher=" ", catalog_type=" ", catalog_number=0, piece_year=0
)
bride.save()

naeg = Movement(title="NA - Egmont Overture, Op. 84", piece=egmont, scorefile_name=" ", recordingfile_name=" ")
naeg.save()
ovfi = Movement(title="Overture - Fidelio", piece=fidelio, scorefile_name=" ", recordingfile_name=" ")
ovfi.save()
onesym5 = Movement(title="I - Symphony No. 5", piece=sym5, scorefile_name=" ", recordingfile_name=" ")
onesym5.save()
twosym5 = Movement(title="II - Symphony No. 5", piece=sym5, scorefile_name=" ", recordingfile_name=" ")
twosym5.save()
onesym7 = Movement(title="I - Symphony No. 7, op. 92", piece=sym7, scorefile_name=" ", recordingfile_name=" ")
onesym7.save()
twosym7 = Movement(title="II - Symphony No. 7, op. 92", piece=sym7, scorefile_name=" ", recordingfile_name=" ")
twosym7.save()
threesym7 = Movement(title="III - Symphony No. 7, op. 92", piece=sym7, scorefile_name=" ", recordingfile_name=" ")
threesym7.save()
foursym7 = Movement(title="IV - Symphony No. 7, op. 92", piece=sym7, scorefile_name=" ", recordingfile_name=" ")
foursym7.save()
nast = Movement(title="NA - In the Steppes of Central Asia", piece=steppes, scorefile_name=" ", recordingfile_name=" ")