mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
style: flake8 linting
This commit is contained in:
parent
0c3201930c
commit
9f8bd4cd3f
8 changed files with 22 additions and 22 deletions
|
|
@ -21,7 +21,7 @@ import sys
|
|||
import codecs
|
||||
import json
|
||||
import csv
|
||||
import xml.etree.ElementTree as et
|
||||
from xml.etree import ElementTree
|
||||
|
||||
from datetime import datetime, date
|
||||
from beets.plugins import BeetsPlugin
|
||||
|
|
@ -188,18 +188,18 @@ class XMLFormat(ExportFormat):
|
|||
|
||||
def export(self, data, **kwargs):
|
||||
# Creates the XML file structure.
|
||||
library = et.Element(u'library')
|
||||
tracks = et.SubElement(library, u'tracks')
|
||||
library = ElementTree.Element(u'library')
|
||||
tracks = ElementTree.SubElement(library, u'tracks')
|
||||
if data and isinstance(data[0], dict):
|
||||
for index, item in enumerate(data):
|
||||
track = et.SubElement(tracks, u'track')
|
||||
track = ElementTree.SubElement(tracks, u'track')
|
||||
for key, value in item.items():
|
||||
track_details = et.SubElement(track, key)
|
||||
track_details = ElementTree.SubElement(track, key)
|
||||
track_details.text = value
|
||||
# Depending on the version of python the encoding needs to change
|
||||
try:
|
||||
data = et.tostring(library, encoding='unicode', **kwargs)
|
||||
data = ElementTree.tostring(library, encoding='unicode', **kwargs)
|
||||
except LookupError:
|
||||
data = et.tostring(library, encoding='utf-8', **kwargs)
|
||||
data = ElementTree.tostring(library, encoding='utf-8', **kwargs)
|
||||
|
||||
self.out_stream.write(data)
|
||||
|
|
|
|||
|
|
@ -907,7 +907,7 @@ class LyricsPlugin(plugins.BeetsPlugin):
|
|||
return _scrape_strip_cruft(lyrics, True)
|
||||
|
||||
def append_translation(self, text, to_lang):
|
||||
import xml.etree.ElementTree as et
|
||||
from xml.etree import ElementTree
|
||||
|
||||
if not self.bing_auth_token:
|
||||
self.bing_auth_token = self.get_bing_access_token()
|
||||
|
|
@ -925,7 +925,8 @@ class LyricsPlugin(plugins.BeetsPlugin):
|
|||
self.bing_auth_token = None
|
||||
return self.append_translation(text, to_lang)
|
||||
return text
|
||||
lines_translated = et.fromstring(r.text.encode('utf-8')).text
|
||||
lines_translated = ElementTree.fromstring(
|
||||
r.text.encode('utf-8')).text
|
||||
# Use a translation mapping dict to build resulting lyrics
|
||||
translations = dict(zip(text_lines, lines_translated.split('|')))
|
||||
result = ''
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ Put something like the following in your config.yaml to configure:
|
|||
from __future__ import division, absolute_import, print_function
|
||||
|
||||
import requests
|
||||
import xml.etree.ElementTree as et
|
||||
from xml.etree import ElementTree
|
||||
from six.moves.urllib.parse import urljoin, urlencode
|
||||
from beets import config
|
||||
from beets.plugins import BeetsPlugin
|
||||
|
|
@ -28,7 +28,7 @@ def get_music_section(host, port, token, library_name):
|
|||
r = requests.get(url)
|
||||
|
||||
# Parse xml tree and extract music section key.
|
||||
tree = et.fromstring(r.content)
|
||||
tree = ElementTree.fromstring(r.content)
|
||||
for child in tree.findall('Directory'):
|
||||
if child.get('title') == library_name:
|
||||
return child.get('key')
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ from __future__ import absolute_import, division, print_function
|
|||
|
||||
import random
|
||||
import string
|
||||
import xml.etree.ElementTree as et
|
||||
from xml.etree import ElementTree
|
||||
from hashlib import md5
|
||||
from urllib.parse import urlencode
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ class SubsonicPlaylistPlugin(BeetsPlugin):
|
|||
|
||||
def get_playlist(self, playlist_id):
|
||||
xml = self.send('getPlaylist', {'id': playlist_id}).text
|
||||
playlist = et.fromstring(xml)[0]
|
||||
playlist = ElementTree.fromstring(xml)[0]
|
||||
if playlist.attrib.get('code', '200') != '200':
|
||||
alt_error = 'error getting playlist, but no error message found'
|
||||
self._log.warn(playlist.attrib.get('message', alt_error))
|
||||
|
|
@ -101,9 +101,8 @@ class SubsonicPlaylistPlugin(BeetsPlugin):
|
|||
self.config.set_args(opts)
|
||||
ids = self.config['playlist_ids'].as_str_seq()
|
||||
if self.config['playlist_names'].as_str_seq():
|
||||
playlists = et.fromstring(
|
||||
self.send('getPlaylists').text
|
||||
)[0]
|
||||
playlists = ElementTree.fromstring(
|
||||
self.send('getPlaylists').text)[0]
|
||||
if playlists.attrib.get('code', '200') != '200':
|
||||
alt_error = 'error getting playlists,' \
|
||||
' but no error message found'
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ from hashlib import md5
|
|||
import os
|
||||
import shutil
|
||||
from itertools import chain
|
||||
from pathlib2 import PurePosixPath
|
||||
from pathlib import PurePosixPath
|
||||
import ctypes
|
||||
import ctypes.util
|
||||
|
||||
|
|
|
|||
4
setup.py
4
setup.py
|
|
@ -122,7 +122,7 @@ setup(
|
|||
'requests_oauthlib'
|
||||
] + (
|
||||
# Tests for the thumbnails plugin need pathlib on Python 2 too.
|
||||
['pathlib2'] if (sys.version_info < (3, 4, 0)) else []
|
||||
['pathlib'] if (sys.version_info < (3, 4, 0)) else []
|
||||
),
|
||||
|
||||
# Plugin (optional) dependencies:
|
||||
|
|
@ -144,7 +144,7 @@ setup(
|
|||
'web': ['flask', 'flask-cors'],
|
||||
'import': ['rarfile'],
|
||||
'thumbnails': ['pyxdg', 'Pillow'] +
|
||||
(['pathlib2'] if (sys.version_info < (3, 4, 0)) else []),
|
||||
(['pathlib'] if (sys.version_info < (3, 4, 0)) else []),
|
||||
'metasync': ['dbus-python'],
|
||||
'sonosupdate': ['soco'],
|
||||
'scrub': ['mutagen>=1.33'],
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ from test.helper import TestHelper
|
|||
import re # used to test csv format
|
||||
import json
|
||||
from xml.etree.ElementTree import Element
|
||||
import xml.etree.ElementTree as et
|
||||
from xml.etree import ElementTree
|
||||
|
||||
|
||||
class ExportPluginTest(unittest.TestCase, TestHelper):
|
||||
|
|
@ -85,7 +85,7 @@ class ExportPluginTest(unittest.TestCase, TestHelper):
|
|||
format_type='xml',
|
||||
artist=item1.artist
|
||||
)
|
||||
library = et.fromstring(out)
|
||||
library = ElementTree.fromstring(out)
|
||||
self.assertIsInstance(library, Element)
|
||||
for track in library[0]:
|
||||
for details in track:
|
||||
|
|
|
|||
2
tox.ini
2
tox.ini
|
|
@ -23,7 +23,7 @@ passenv =
|
|||
deps =
|
||||
{test,cov}: {[_test]deps}
|
||||
flake8: {[_flake8]deps}
|
||||
py27: pathlib2
|
||||
py27: pathlib
|
||||
commands =
|
||||
py27-test: python -m nose {posargs}
|
||||
py38-cov: python -bb -m nose --with-coverage {posargs}
|
||||
|
|
|
|||
Loading…
Reference in a new issue