def get_java_name(self): return camelize(self.name, trailing=True)
def test_camelize_trailing(self): """Confirm camilzation of trailing part of string """ self.assertEqual(util.camelize('long_method_name', trailing=True), 'longMethodName')
def test_camelize(self): """Confirm camilzation of string """ self.assertEqual(util.camelize('camel_case_string'), 'CamelCaseString')
def get_java_getter_name(self): return 'get' + camelize(self.name)
def get_json_name(cls, field_name): return camelize(field_name, trailing=True)
def state_dict() -> Dict[str, Any]: """Extends the base state with musiq-specific information and returns it.""" state = base.state_dict() musiq_state: Dict[str, Any] = {} musiq_state["paused"] = storage.get("paused") musiq_state["shuffle"] = storage.get("shuffle") musiq_state["repeat"] = storage.get("repeat") musiq_state["autoplay"] = storage.get("autoplay") musiq_state["volume"] = storage.get("volume") try: current_song = CurrentSong.objects.get() current_song_dict = model_to_dict(current_song) current_song_dict = util.camelize(current_song_dict) current_song_dict["durationFormatted"] = song_utils.format_seconds( current_song_dict["duration"]) musiq_state["currentSong"] = current_song_dict paused = storage.get("paused") if paused: progress = (current_song.last_paused - current_song.created).total_seconds() else: progress = (timezone.now() - current_song.created).total_seconds() progress /= current_song.duration musiq_state["progress"] = progress * 100 except CurrentSong.DoesNotExist: musiq_state["currentSong"] = None musiq_state["paused"] = True musiq_state["progress"] = 0 song_queue = [] total_time = 0 all_songs = queue.all() if storage.get("interactivity") in [ storage.Interactivity.upvotes_only, storage.Interactivity.full_voting, ]: all_songs = all_songs.order_by("-votes", "index") for song in all_songs: song_dict = model_to_dict(song) song_dict = util.camelize(song_dict) song_dict["durationFormatted"] = song_utils.format_seconds( song_dict["duration"]) song_queue.append(song_dict) if song_dict["duration"] < 0: # skip duration of placeholders continue total_time += song_dict["duration"] musiq_state["totalTimeFormatted"] = song_utils.format_seconds(total_time) musiq_state["songQueue"] = song_queue if state["alarm"]: musiq_state["currentSong"] = { "queueKey": -1, "manuallyRequested": False, "votes": 0, "created": "", # https://github.com/python/mypy/issues/4976 **util.camelize(cast(Dict[Any, Any], get_alarm_metadata())), } musiq_state["progress"] = 0 musiq_state["paused"] = False elif redis.get("backup_playing"): musiq_state["currentSong"] = { "queueKey": -1, "manuallyRequested": False, "votes": 0, "internalUrl": "backup_stream", "externalUrl": storage.get("backup_stream"), "artist": "", "title": "Backup Stream", "duration": 60 * 60 * 24, "created": "", } musiq_state["paused"] = False state["musiq"] = musiq_state return state
def get_json_name(self): from core.util import camelize return camelize(self.name)