Type annotation, linter fixes and cleanup

This commit is contained in:
Peder Bergebakken Sundt 2022-02-20 00:21:55 +01:00
parent f371f5795c
commit d5750e69fa
4 changed files with 21 additions and 26 deletions

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os, sys, shutil
from remi import start from remi import start
from threading import Timer from threading import Timer
import typer import typer

View File

@ -1,7 +1,6 @@
import requests, json import requests, json
from urllib.parse import urlencode from urllib.parse import urlencode
from functools import wraps from functools import wraps
from . import api
# This must be set to be able to use it on remote hosts # This must be set to be able to use it on remote hosts
BASE_URL = "http://localhost:8080/api" BASE_URL = "http://localhost:8080/api"
@ -58,7 +57,7 @@ def load_path(path:str, data:dict=None):
@request_get @request_get
def is_playing(): def is_playing():
return f"play" return "play"
@request_post @request_post
def set_playing(play: bool): def set_playing(play: bool):
@ -67,7 +66,7 @@ def set_playing(play:bool):
@request_get @request_get
def get_volume(): def get_volume():
return f"volume" return "volume"
@request_post @request_post
def set_volume(volume: int): # between 0 and 100 (you may also exceed 100) def set_volume(volume: int): # between 0 and 100 (you may also exceed 100)
@ -76,11 +75,11 @@ def set_volume(volume:int):# between 0 and 100 (you may also exceed 100)
@request_get @request_get
def get_playlist(): def get_playlist():
return f"playlist" return "playlist"
@request_post @request_post
def playlist_next(): def playlist_next():
return f"playlist/next", None return "playlist/next", None
@request_post @request_post
def playlist_goto(index: int): def playlist_goto(index: int):
@ -89,15 +88,15 @@ def playlist_goto(index:int):
@request_post @request_post
def playlist_previous(): def playlist_previous():
return f"playlist/previous", None return "playlist/previous", None
@request_post @request_post
def playlist_shuffle(): def playlist_shuffle():
return f"playlist/shuffle", None return "playlist/shuffle", None
@request_delete @request_delete
def playlist_clear(): def playlist_clear():
return f"playlist", None return "playlist", None
@request_delete @request_delete
def playlist_remove(index: int): def playlist_remove(index: int):
@ -111,7 +110,7 @@ def playlist_move(index1:int, index2:int):
@request_get @request_get
def get_playlist_looping(): def get_playlist_looping():
return f"playlist/loop" return "playlist/loop"
@request_post @request_post
def playlist_set_looping(looping: bool): def playlist_set_looping(looping: bool):
@ -120,7 +119,7 @@ def playlist_set_looping(looping:bool):
@request_get @request_get
def get_playback_pos(): def get_playback_pos():
return f"time" return "time"
@request_post @request_post
def seek_absolute(pos: float): def seek_absolute(pos: float):

View File

@ -2,7 +2,8 @@ import os
from threading import Timer from threading import Timer
import remi.gui as gui import remi.gui as gui
from remi import App from remi import App
from .utils import Namespace, call_as_thread, seconds_to_timestamp from argparse import Namespace
from .utils import call_as_thread, seconds_to_timestamp
from . import api from . import api
from .constants import colors, icons from .constants import colors, icons
@ -71,7 +72,7 @@ class RemiApp(App):
def make_gui_container(self):#placement and styling def make_gui_container(self):#placement and styling
# Logo image: # Logo image:
self.logo_image.style["width"] = f"100%" self.logo_image.style["width"] = "100%"
for i in (self.playback.previous, self.playback.play, self.playback.next, self.playback.party): for i in (self.playback.previous, self.playback.play, self.playback.next, self.playback.party):
i.style["margin"] = "3px" i.style["margin"] = "3px"
i.style["width"] = "2.8em" i.style["width"] = "2.8em"

View File

@ -1,9 +1,5 @@
from functools import wraps from functools import wraps
from urllib.parse import urlsplit, urlunsplit, parse_qs, urlencode
import threading import threading
import youtube_dl
class Namespace(object): pass
def seconds_to_timestamp(s): def seconds_to_timestamp(s):
return "%i:%.2i" % (s//60, s%60) return "%i:%.2i" % (s//60, s%60)