Code cleanup with pylint

This commit is contained in:
RemixDev
2021-04-10 11:53:52 +02:00
parent eda8fd3d13
commit 69c165e2bc
18 changed files with 323 additions and 350 deletions

View File

@ -9,30 +9,28 @@ def getBitrateNumberFromText(txt):
txt = str(txt).lower()
if txt in ['flac', 'lossless', '9']:
return TrackFormats.FLAC
elif txt in ['mp3', '320', '3']:
if txt in ['mp3', '320', '3']:
return TrackFormats.MP3_320
elif txt in ['128', '1']:
if txt in ['128', '1']:
return TrackFormats.MP3_128
elif txt in ['360', '360_hq', '15']:
if txt in ['360', '360_hq', '15']:
return TrackFormats.MP4_RA3
elif txt in ['360_mq', '14']:
if txt in ['360_mq', '14']:
return TrackFormats.MP4_RA2
elif txt in ['360_lq', '13']:
if txt in ['360_lq', '13']:
return TrackFormats.MP4_RA1
else:
return None
return None
def changeCase(str, type):
if type == "lower":
return str.lower()
elif type == "upper":
return str.upper()
elif type == "start":
return string.capwords(str)
elif type == "sentence":
return str.capitalize()
else:
return str
def changeCase(txt, case_type):
if case_type == "lower":
return txt.lower()
if case_type == "upper":
return txt.upper()
if case_type == "start":
return string.capwords(txt)
if case_type == "sentence":
return txt.capitalize()
return str
def removeFeatures(title):
clean = title

View File

@ -1,6 +1,8 @@
from pathlib import Path
import sys
import os
if os.name == 'nt':
import winreg # pylint: disable=E0401
homedata = Path.home()
userdata = ""
@ -23,7 +25,6 @@ if os.getenv("DEEMIX_MUSIC_DIR"):
elif os.getenv("XDG_MUSIC_DIR"):
musicdata = Path(os.getenv("XDG_MUSIC_DIR")) / "deemix Music"
elif os.name == 'nt':
import winreg
sub_key = r'SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'
music_guid = '{4BD8D571-6D19-48D3-BE97-422220080E43}'
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, sub_key) as key:

View File

@ -52,17 +52,16 @@ def antiDot(string):
return string
def pad(num, max, settings):
def pad(num, max_val, settings):
if int(settings['paddingSize']) == 0:
paddingSize = len(str(max))
paddingSize = len(str(max_val))
else:
paddingSize = len(str(10 ** (int(settings['paddingSize']) - 1)))
if paddingSize == 1:
paddingSize = 2
if settings['padTracks']:
return str(num).zfill(paddingSize)
else:
return str(num)
return str(num)
def generateFilename(track, settings, template):
filename = template or "%artist% - %title%"