def label_labeling_based_recommend(self, labelings, target_label): """ @data: data is lists of recommend contents's ids that can get from key of user id """ engine = LabelLabelingBasedRecommendEngine(self) data = engine.run(Labelings(labelings), Label(target_label)) return data
def label_interest_based_recommend(self, interests, target_label): """ @data: data is lists of recommend contents's ids that can get from key of user id """ engine = LabelInterestBasedRecommendEngine(self) data = engine.run(Interests(interests), Label(target_label)) return data
def select_all(): labels = [] sql = "SELECT * FROM labels ORDER BY name" results = run_sql(sql) for row in results: artist = Label(row['name'], row['id']) labels.append(artist) return labels
def select(id): label = None sql = "SELECT * from labels WHERE id = %s" values = [id] result = run_sql(sql, values)[0] if result is not None: label = Label(result['name'], result['id']) return label
def setUp(self): self.artist = Artist("Frightened Rabbit") self.label = Label("Fat Cat Records") self.album = Album( "Midnight Organ Fight", self.artist, "Indie Rock", 22.99, 13.79, "2008", "https://is2-ssl.mzstatic.com/image/thumb/Music123/v4/53/79/37/53793762-eeef-8cce-96b2-6de1c18740e2/source/600x600bb.jpg", 6, self.label, 15)
from models.label import Label from models.milestone import Milestone from models.issue import Issue from templates import simple import sys project_id = sys.argv[1] lbl_result = {} mls_result = {} for label in simple.labels: lbl_result[label['name']] = Label(project_id).create(label) for milestone in simple.milestones: mls_result[milestone['title']] = Milestone(project_id).create(milestone) for task in simple.issues[milestone['title']]: print(mls_result[milestone['title']]) task['milestone_id'] = mls_result[milestone['title']]['id'] print(Issue(project_id).create(task))
async def load_location(sid: str, location: Location, *, complete=False): pr: PlayerRoom = game_state.get(sid) if pr.active_location != location: pr.active_location = location pr.save() # 1. Load client options client_options = pr.player.as_dict() client_options["location_user_options"] = LocationUserOption.get( user=pr.player, location=location).as_dict() client_options["default_user_options"] = pr.player.default_options.as_dict( ) if pr.user_options: client_options["room_user_options"] = pr.user_options.as_dict() await sio.emit("Client.Options.Set", client_options, room=sid, namespace=GAME_NS) # 2. Load room info if complete: await sio.emit( "Room.Info.Set", { "name": pr.room.name, "creator": pr.room.creator.name, "invitationCode": str(pr.room.invitation_code), "isLocked": pr.room.is_locked, "default_options": pr.room.default_options.as_dict(), "players": [{ "id": rp.player.id, "name": rp.player.name, "location": rp.active_location.id, "role": rp.role, } for rp in pr.room.players], "publicName": config.get("General", "public_name", fallback=""), }, room=sid, namespace=GAME_NS, ) # 3. Load location await sio.emit("Location.Set", location.as_dict(), room=sid, namespace=GAME_NS) # 4. Load all location settings (DM) if complete and pr.role == Role.DM: await sio.emit( "Locations.Settings.Set", { l.id: {} if l.options is None else l.options.as_dict() for l in pr.room.locations }, room=sid, namespace=GAME_NS, ) # 5. Load Board locations = [{ "id": l.id, "name": l.name, "archived": l.archived } for l in pr.room.locations.order_by(Location.index)] await sio.emit("Board.Locations.Set", locations, room=sid, namespace=GAME_NS) floors = [floor for floor in location.floors.order_by(Floor.index)] if "active_floor" in client_options["location_user_options"]: index = next(i for i, f in enumerate(floors) if f.name == client_options["location_user_options"]["active_floor"]) lower_floors = floors[index - 1::-1] if index > 0 else [] higher_floors = floors[index + 1:] if index < len(floors) else [] floors = [floors[index], *lower_floors, *higher_floors] for floor in floors: await sio.emit( "Board.Floor.Set", floor.as_dict(pr.player, pr.role == Role.DM), room=sid, namespace=GAME_NS, ) # 6. Load Initiative location_data = Initiative.get_or_none(location=location) if location_data: await sio.emit("Initiative.Set", location_data.as_dict(), room=sid, namespace=GAME_NS) # 7. Load labels if complete: labels = Label.select().where((Label.user == pr.player) | (Label.visible == True)) label_filters = LabelSelection.select().where( (LabelSelection.user == pr.player) & (LabelSelection.room == pr.room)) await sio.emit( "Labels.Set", [l.as_dict() for l in labels], room=sid, namespace=GAME_NS, ) await sio.emit( "Labels.Filters.Set", [l.label.uuid for l in label_filters], room=sid, namespace=GAME_NS, ) # 8. Load Notes await sio.emit( "Notes.Set", [ note.as_dict() for note in Note.select().where((Note.user == pr.player) & (Note.room == pr.room)) ], room=sid, namespace=GAME_NS, ) # 9. Load Markers await sio.emit( "Markers.Set", [ marker.as_string() for marker in Marker.select(Marker.shape_id).where( (Marker.user == pr.player) & (Marker.location == location)) ], room=sid, namespace=GAME_NS, ) # 10. Load Assets if complete: await sio.emit( "Asset.List.Set", Asset.get_user_structure(pr.player), room=sid, namespace=GAME_NS, )
artist_repository.save(paramore) phoebe_bridgers = Artist("Phoebe Bridgers") artist_repository.save(phoebe_bridgers) sara = Artist("Sara Bareilles") artist_repository.save(sara) tallest_man = Artist("The Tallest Man on Earth") artist_repository.save(tallest_man) dermot_kennedy = Artist("Dermot Kennedy") artist_repository.save(dermot_kennedy) rage = Artist("Rage Against the Machine") artist_repository.save(rage) paul_simon = Artist("Paul Simon") artist_repository.save(paul_simon) # LABELS fourteenth = Label("14th Floor (Warner)") label_repository.save(fourteenth) atlantic = Label("Atlantic Records") label_repository.save(atlantic) capitol = Label("Capitol Records") label_repository.save(capitol) columbia = Label("Columbia Records") label_repository.save(columbia) dead_oceans = Label("Dead Oceans") label_repository.save(dead_oceans) epic = Label("Epic Records (Sony)") label_repository.save(epic) fat_cat = Label("Fat Cat Records") label_repository.save(fat_cat) fueled_by_ramen = Label("Fueled By Ramen") label_repository.save(fueled_by_ramen)
def create_label(): name = request.form['label-name'] label = Label(name) label_repository.save(label) return redirect("/labels")
def setUp(self): self.label = Label("Atlantic Records")