Move imports in mpd component (#28030)

pull/28054/head
Diefferson Koderer Môro 2019-10-21 04:54:00 -03:00 committed by Fabian Affolter
parent 1e27e2827d
commit 6a392e13dd
1 changed files with 2 additions and 11 deletions

View File

@ -3,9 +3,10 @@ from datetime import timedelta
import logging import logging
import os import os
import mpd
import voluptuous as vol import voluptuous as vol
from homeassistant.components.media_player import MediaPlayerDevice, PLATFORM_SCHEMA from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerDevice
from homeassistant.components.media_player.const import ( from homeassistant.components.media_player.const import (
MEDIA_TYPE_MUSIC, MEDIA_TYPE_MUSIC,
MEDIA_TYPE_PLAYLIST, MEDIA_TYPE_PLAYLIST,
@ -85,8 +86,6 @@ class MpdDevice(MediaPlayerDevice):
# pylint: disable=no-member # pylint: disable=no-member
def __init__(self, server, port, password, name): def __init__(self, server, port, password, name):
"""Initialize the MPD device.""" """Initialize the MPD device."""
import mpd
self.server = server self.server = server
self.port = port self.port = port
self._name = name self._name = name
@ -107,8 +106,6 @@ class MpdDevice(MediaPlayerDevice):
def _connect(self): def _connect(self):
"""Connect to MPD.""" """Connect to MPD."""
import mpd
try: try:
self._client.connect(self.server, self.port) self._client.connect(self.server, self.port)
@ -121,8 +118,6 @@ class MpdDevice(MediaPlayerDevice):
def _disconnect(self): def _disconnect(self):
"""Disconnect from MPD.""" """Disconnect from MPD."""
import mpd
try: try:
self._client.disconnect() self._client.disconnect()
except mpd.ConnectionError: except mpd.ConnectionError:
@ -144,8 +139,6 @@ class MpdDevice(MediaPlayerDevice):
def update(self): def update(self):
"""Get the latest data and update the state.""" """Get the latest data and update the state."""
import mpd
try: try:
if not self._is_connected: if not self._is_connected:
self._connect() self._connect()
@ -261,8 +254,6 @@ class MpdDevice(MediaPlayerDevice):
@Throttle(PLAYLIST_UPDATE_INTERVAL) @Throttle(PLAYLIST_UPDATE_INTERVAL)
def _update_playlists(self, **kwargs): def _update_playlists(self, **kwargs):
"""Update available MPD playlists.""" """Update available MPD playlists."""
import mpd
try: try:
self._playlists = [] self._playlists = []
for playlist_data in self._client.listplaylists(): for playlist_data in self._client.listplaylists():