Address errors, improvements, formatting

- Removed unused code not portable due to buffer() use
- raw_input() does not exist in Python 3
- Fixed octal constant syntax for Python 3
- Fixed TypeError
- Replace if not exists: makedirs(path) with single call: using makedirs(path, exist_ok=True)
- Class inherits from object, can be safely removed from bases in python3: pylint's useless-object-inheritance (W0235) check

Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
This commit is contained in:
JoeLametta
2019-08-10 09:10:00 +00:00
parent 8446c290e7
commit 35201d5290
18 changed files with 31 additions and 65 deletions

View File

@@ -21,7 +21,6 @@
import requests
import struct
from errno import EEXIST
from os import makedirs
from os.path import dirname, exists, join
@@ -40,7 +39,7 @@ class EntryNotFound(Exception):
pass
class _AccurateRipResponse(object):
class _AccurateRipResponse:
"""
An AccurateRip response contains a collection of metadata identifying a
particular digital audio compact disc.
@@ -143,13 +142,11 @@ def _download_entry(path):
def _save_entry(raw_entry, path):
logger.debug('saving AccurateRip entry to %s', path)
# XXX: os.makedirs(exist_ok=True) in py3
try:
makedirs(dirname(path))
makedirs(dirname(path), exist_ok=True)
except OSError as e:
if e.errno != EEXIST:
logger.error('could not save entry to %s: %s', path, e)
return
logger.error('could not save entry to %s: %s', path, e)
return
open(path, 'wb').write(raw_entry)

View File

@@ -292,7 +292,7 @@ def validate_template(template, kind):
'variable(s): {}'.format(', '.join(matches)))
class VersionGetter(object):
class VersionGetter:
"""
I get the version of a program by looking for it in command output
according to a regexp.

View File

@@ -19,14 +19,13 @@
# along with whipper. If not, see <http://www.gnu.org/licenses/>.
from os import getenv, makedirs
from os.path import join, expanduser, exists
from os.path import join, expanduser
def config_path():
path = join(getenv('XDG_CONFIG_HOME') or join(expanduser('~'), '.config'),
'whipper')
if not exists(path):
makedirs(path)
makedirs(path, exist_ok=True)
return join(path, 'whipper.conf')
@@ -35,8 +34,7 @@ def cache_path(name=None):
'whipper')
if name:
path = join(path, name)
if not exists(path):
makedirs(path)
makedirs(path, exist_ok=True)
return path
@@ -46,6 +44,5 @@ def data_path(name=None):
'whipper')
if name:
path = join(path, name)
if not exists(path):
makedirs(path)
makedirs(path, exist_ok=True)
return path

View File

@@ -45,7 +45,7 @@ class NotFoundException(MusicBrainzException):
return "Disc not found in MusicBrainz"
class TrackMetadata(object):
class TrackMetadata:
artist = None
title = None
duration = None # in ms
@@ -56,7 +56,7 @@ class TrackMetadata(object):
mbidWorks = []
class DiscMetadata(object):
class DiscMetadata:
"""
:param artist: artist(s) name
:param sortName: release artist sort name

View File

@@ -21,7 +21,7 @@
import re
class PathFilter(object):
class PathFilter:
"""
I filter path components for safe storage on file systems.
"""

View File

@@ -333,7 +333,7 @@ class Program:
if prompt:
guess = (deltas[lowest])[0].mbid
release = raw_input(
release = input(
"\nPlease select a release [%s]: " % guess)
if not release:
@@ -505,8 +505,7 @@ class Program:
stop = self.result.table.getTrackEnd(trackResult.number)
dirname = os.path.dirname(trackResult.filename)
if not os.path.exists(dirname):
os.makedirs(dirname)
os.makedirs(dirname, exist_ok=True)
if not what:
what = 'track %d' % (trackResult.number, )

View File

@@ -24,7 +24,7 @@ import tempfile
"""Rename files on file system and inside metafiles in a resumable way."""
class Operator(object):
class Operator:
def __init__(self, statePath, key):
self._todo = []
@@ -116,7 +116,7 @@ class FileRenamer(Operator):
"""
class Operation(object):
class Operation:
def verify(self):
"""