Ejemplo n.º 1
0
 def delete_song(cls, song_id):
     song = Song().get(song_id, links=True)
     
     if song is None:
         raise NotFoundException()
     
     # remove the song from storage first
     song.remove()
     
     # deleting a song also deletes all the associated versions
     for v in song.versions:
         version = Version().get(v, links=True)
         version.remove()
     
     # then remove the singer and re-index any related objects
     SongIndex.delete_by_id(song.id)
Ejemplo n.º 2
0
 def create_song(cls, song_json, versions, songs):
     if song_json is None:
         return None
     
     # create the song object and save it to the store
     song = Song({"song" : song_json})
     if versions is not None:
         song.versions = versions
     if songs is not None:
         song.songs = songs
     song.save()
     
     # call the indexing process, and index this object and all
     # related ones
     SongIndex.by_id(song.id, cascade=True)
     
     return song
Ejemplo n.º 3
0
 def update_song(cls, song_id, song_json=None, versions=None, songs=None):
     # retrieve and update the song object in the desired way
     song = Song().get(song_id, links=True)
     
     if song is None:
         raise NotFoundException()
     
     if song_json is not None:
         song.patch_song(song_json, replace_all=True, keep_id=True)
     if versions is not None:
         song.versions = versions
     if songs is not None:
         song.songs = songs
     song.save()
     
     # call the indexing process, and index this object and all related ones
     print song.id
     SongIndex.by_id(song.id, cascade=True)
     
     return song
Ejemplo n.º 4
0
"""
Falkirk Hiring Fair	Falkirk Fair	Bothy song in which man is hired to work at a farm near Falkirk, and is critical of the treatment he receives.	Falkirk	Late 19th / Early 20th Century		LV1	LV2; LV3
							
Dumfries Hiring Fair		Bothy song in which man is hired to work at a farm near Dumfries, and is critical of the treatment he receives.	Dumfries	Late 19th / Early 20th Century		LV2	LV1; LV3
							
The Boreland of Balmaghie	Parker of the Boreland	Bothy song in which man is hired to work at a farm near Castle Douglas, and is critical of the treatment he receives.	Castle Douglas	Late 19th / Early 20th Century		LV3	LV1; LV2
Andrew Lammie	Mill o Tifty's Annie	Song of tragic love between Andrew Lammie, the Laird o Fyvie's trumpeter and Mill o Tifty's Annie. Annie's parents disapprove, and have Andrew dismissed and sent away, then kill their daughter for shaming them.		Late 17th century		LV4	
							
The Bonnie Hoose o Airlie		Ballad of feuding lords. Airlie Castle is burned to the ground by Archibald Campbell, while his rival, James Ogilvie, is away.	Airlie, Angus	Mid 16th century		LV5	
The Laird o Drum		Ballad of marriage between social classes.	Drum Castle, Drumoak, Aberdeenshire	Mid 16th century		LV6	
The Cauld Water Well		Sentimental pastoral song celebrating a local wishing well.	Dundee	Late 19th century		LV7	
"""

# Falkirk Hiring Fair
song1 = Song()
song1.title = "Falkirk Hiring Fair"
song1.summary = "Bothy song in which man is hired to work at a farm near Falkirk, and is critical of the treatment he receives."
song1.add_location(relation="main", name="Falkirk")
song1.set_time_period("Late 19th Century", "Early 20th Century")
song1.lv_id = "LV1"
song1.id = song1.makeid()
song_ids.append(song1.id)
# we need the ids of the related songs, which we add get later

# Dumfries Hiring Fair
song2 = Song()
song2.title = "Dumfries Hiring Fair"
song2.summary = "Bothy song in which man is hired to work at a farm near Dumfries, and is critical of the treatment he receives."
song2.add_location(relation="main", name="Dumfries")
song2.set_time_period("Late 19th Century", "Early 20th Century")
Ejemplo n.º 5
0
    
    # record the id and map it to the lvid for later use
    id = resp.json().get("id")
    SINGER_LV_ID_MAP[row[0]] = id

reader = csv.reader(open(songs_versions))
count = 0
for row in reader:
    if count < 2: # skip the first two lines
        count += 1
        continue
    
    # first have a go at the song that appears on this row
    slv_id = _normalise(row[5])
    if slv_id is not None and slv_id not in SONG_LV_ID_MAP.keys():
        song = Song()
        stitle = _normalise(row[0])
        if stitle is not None:
            song.title = stitle
        
        # skip row[1] - alternative title is calculated from versions later
        
        ssummary = _normalise(row[2])
        if ssummary is not None:
            song.summary = ssummary
        
        slocation = _normalise(row[3])
        if slocation is not None:
            song.add_location(relation="main", name=slocation)
        
        scomposer = _normalise(row[4])