From 70336f57578d5891b2590f17db70bd8b4cf08998 Mon Sep 17 00:00:00 2001 From: poly000 <1348292515a@gmail.com> Date: Tue, 9 Jan 2024 16:47:53 +0800 Subject: [PATCH] fix pylint & flake8 --- feeluown/nowplaying/nowplaying.py | 16 ++++++++-------- feeluown/plugin.py | 5 +++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/feeluown/nowplaying/nowplaying.py b/feeluown/nowplaying/nowplaying.py index e11438625b..ab18b0dc03 100644 --- a/feeluown/nowplaying/nowplaying.py +++ b/feeluown/nowplaying/nowplaying.py @@ -23,11 +23,11 @@ # todo: fix! aionp.interface.macos treat aionp time as milisecond while # other two interface treat it as microsecond (which is commented # at aionp.interface.base) -def sec_to_μs(t_sec): +def sec_to_us(t_sec): return int(t_sec * 1000 * 1000) -def μs_to_sec(t_microsec): +def us_to_sec(t_microsec): return t_microsec / 1000 / 1000 @@ -82,10 +82,10 @@ def update_song_metadata(self, meta: dict): self.set_playback_property(PlayProp.Metadata, metadata) def update_duration(self, duration): - self.set_playback_property(PlayProp.Duration, int(sec_to_μs(duration or 0))) + self.set_playback_property(PlayProp.Duration, int(sec_to_us(duration or 0))) def update_position(self, position): - self.set_playback_property(PlayProp.Position, int(sec_to_μs(position or 0))) + self.set_playback_property(PlayProp.Position, int(sec_to_us(position or 0))) def update_playback_status(self, state): self.set_playback_property(PlayProp.PlaybackStatus, @@ -118,16 +118,16 @@ def on_shuffle(self, shuffle: bool): self._app.playlist.playback_mode = PlaybackMode.sequential def on_set_position(self, track_id: str, position: int): - self._app.player.position = μs_to_sec(position) + self._app.player.position = us_to_sec(position) def on_seek(self, offset_us: int): - self._app.player.position = μs_to_sec(offset_us) + self._app.player.position = us_to_sec(offset_us) def get_playback_property(self, name: PlayProp): if name == PlayProp.Duration: - return sec_to_μs(self._app.player.duration) + return sec_to_us(self._app.player.duration) elif name == PlayProp.Position: - return sec_to_μs(self._app.player.position) + return sec_to_us(self._app.player.position) elif name == PlayProp.PlaybackStatus: return StatePlaybackStatusMapping[self._app.player.state] elif name == PlayProp.Rate: diff --git a/feeluown/plugin.py b/feeluown/plugin.py index c6bea1908d..a1874320f4 100644 --- a/feeluown/plugin.py +++ b/feeluown/plugin.py @@ -201,8 +201,9 @@ def _scan_entry_points(self): https://packaging.python.org/guides/creating-and-discovering-plugins/ """ try: - import importlib_metadata # pylint: disable=redefined-outer-name - entry_points = importlib_metadata.entry_points().select(group='fuo.plugins_v1') + import importlib_metadata # pylint: disable=redefined-outer-name + entry_points = importlib_metadata.entry_points() \ + .select(group='fuo.plugins_v1') except ImportError: import pkg_resources entry_points = pkg_resources.iter_entry_points('fuo.plugins_v1')