mirror of
https://github.com/rembo10/headphones.git
synced 2026-03-21 12:19:27 +00:00
manual pep8 W291,W293,W391 blank lines, trailing whitespace
This commit is contained in:
@@ -33,7 +33,7 @@ class AuthURLOpener(HeadphonesURLopener):
|
||||
"""
|
||||
URLOpener class that supports http auth without needing interactive password entry.
|
||||
If the provided username/password don't work it simply fails.
|
||||
|
||||
|
||||
user: username to use for HTTP auth
|
||||
pw: password to use for HTTP auth
|
||||
"""
|
||||
@@ -44,7 +44,7 @@ class AuthURLOpener(HeadphonesURLopener):
|
||||
|
||||
# remember if we've tried the username/password before
|
||||
self.numTries = 0
|
||||
|
||||
|
||||
# call the base class
|
||||
urllib.FancyURLopener.__init__(self)
|
||||
|
||||
@@ -58,7 +58,7 @@ class AuthURLOpener(HeadphonesURLopener):
|
||||
if self.numTries == 0:
|
||||
self.numTries = 1
|
||||
return (self.username, self.password)
|
||||
|
||||
|
||||
# if we've tried before then return blank which cancels the request
|
||||
else:
|
||||
return ('', '')
|
||||
|
||||
@@ -198,7 +198,7 @@ class Directory:
|
||||
if c.__class__.__name__ == classname:
|
||||
content.append(c)
|
||||
return content
|
||||
|
||||
|
||||
def tracks(self, ext=None, split=False):
|
||||
content = []
|
||||
for c in self.content:
|
||||
@@ -210,14 +210,14 @@ class Directory:
|
||||
if not split or (split and c.split_file):
|
||||
content.append(c)
|
||||
return content
|
||||
|
||||
|
||||
def update(self):
|
||||
def check_match(filename):
|
||||
for i in self.content:
|
||||
if i.name == filename:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def identify_track_number(filename):
|
||||
if 'split-track' in filename:
|
||||
search = re.search('split-track(\d\d)', filename)
|
||||
@@ -232,7 +232,7 @@ class Directory:
|
||||
return n
|
||||
|
||||
list_dir = glob.glob(os.path.join(self.path, '*'))
|
||||
|
||||
|
||||
# TODO: for some reason removes only one file
|
||||
rem_list = []
|
||||
for i in self.content:
|
||||
@@ -240,7 +240,7 @@ class Directory:
|
||||
rem_list.append(i)
|
||||
for i in rem_list:
|
||||
self.content.remove(i)
|
||||
|
||||
|
||||
for i in list_dir:
|
||||
if not check_match(i):
|
||||
# music file
|
||||
@@ -250,7 +250,7 @@ class Directory:
|
||||
self.content.append(WaveFile(self.path + os.sep + i, track_nr=track_nr))
|
||||
else:
|
||||
self.content.append(WaveFile(self.path + os.sep + i))
|
||||
|
||||
|
||||
# cue file
|
||||
elif os.path.splitext(i)[-1] == '.cue':
|
||||
self.content.append(CueFile(self.path + os.sep + i))
|
||||
@@ -258,11 +258,11 @@ class Directory:
|
||||
# meta file
|
||||
elif i == ALBUM_META_FILE_NAME:
|
||||
self.content.append(MetaFile(self.path + os.sep + i))
|
||||
|
||||
|
||||
# directory
|
||||
elif os.path.isdir(i):
|
||||
self.content.append(Directory(self.path + os.sep + i))
|
||||
|
||||
|
||||
else:
|
||||
self.content.append(File(self.path + os.sep + i))
|
||||
|
||||
@@ -451,7 +451,7 @@ class MetaFile(File):
|
||||
|
||||
content = {}
|
||||
content['tracks'] = [None for m in range(100)]
|
||||
|
||||
|
||||
for l in self.rawcontent.splitlines():
|
||||
parsed_line = re.search('^(.+?)\t(.+?)$', l)
|
||||
if parsed_line:
|
||||
@@ -464,11 +464,11 @@ class MetaFile(File):
|
||||
content['tracks'][int(parsed_track.group(1))][parsed_track.group(2)] = parsed_line.group(2)
|
||||
else:
|
||||
content[parsed_line.group(1)] = parsed_line.group(2)
|
||||
|
||||
|
||||
content['tracks'] = check_list(content['tracks'], ignore=1)
|
||||
|
||||
|
||||
self.content = content
|
||||
|
||||
|
||||
def flac_tags(self, track_nr):
|
||||
common_tags = dict()
|
||||
freeform_tags = dict()
|
||||
@@ -494,7 +494,7 @@ class MetaFile(File):
|
||||
artist = self.content['artist']
|
||||
album = self.content['date'] + ' - ' + self.content['title'] + ' (' + self.content['label'] + ' - ' + self.content['catalog'] + ')'
|
||||
return artist, album
|
||||
|
||||
|
||||
def complete(self):
|
||||
'''Check MetaFile for containing all data'''
|
||||
self.__init__(self.path)
|
||||
@@ -502,7 +502,7 @@ class MetaFile(File):
|
||||
if re.search('^[0-9A-Za-z]+?\t$', l):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def count_tracks(self):
|
||||
'''Returns tracks count'''
|
||||
return len(self.content['tracks']) - self.content['tracks'].count(None)
|
||||
@@ -518,7 +518,7 @@ class WaveFile(File):
|
||||
def filename(self, ext=None, cmd=False):
|
||||
title = meta.content['tracks'][self.track_nr]['title']
|
||||
|
||||
if ext:
|
||||
if ext:
|
||||
if ext[0] != '.':
|
||||
ext = '.' + ext
|
||||
else:
|
||||
@@ -673,5 +673,3 @@ def split(albumpath):
|
||||
# Rename original file
|
||||
os.rename(wave.name, wave.name + '.original')
|
||||
return True
|
||||
|
||||
|
||||
|
||||
@@ -62,14 +62,14 @@ class DBConnection:
|
||||
return
|
||||
|
||||
sqlResult = None
|
||||
|
||||
|
||||
try:
|
||||
with self.connection as c:
|
||||
if args == None:
|
||||
sqlResult = c.execute(query)
|
||||
else:
|
||||
sqlResult = c.execute(query, args)
|
||||
|
||||
|
||||
except sqlite3.OperationalError, e:
|
||||
if "unable to open database file" in e.message or "database is locked" in e.message:
|
||||
logger.warn('Database Error: %s', e)
|
||||
@@ -80,13 +80,13 @@ class DBConnection:
|
||||
except sqlite3.DatabaseError, e:
|
||||
logger.error('Fatal Error executing %s :: %s', query, e)
|
||||
raise
|
||||
|
||||
|
||||
return sqlResult
|
||||
|
||||
def select(self, query, args=None):
|
||||
|
||||
sqlResults = self.action(query, args).fetchall()
|
||||
|
||||
|
||||
if sqlResults == None or sqlResults == [None]:
|
||||
return []
|
||||
|
||||
|
||||
@@ -95,11 +95,11 @@ def sendNZB(nzb):
|
||||
except httplib.InvalidURL, e:
|
||||
logger.error(u"Invalid SAB host, check your config. Current host: %s" % headphones.CONFIG.SAB_HOST)
|
||||
return False
|
||||
|
||||
|
||||
except Exception, e:
|
||||
logger.error(u"Error: " + str(e))
|
||||
return False
|
||||
|
||||
|
||||
if f == None:
|
||||
logger.info(u"No data returned from SABnzbd, NZB not sent")
|
||||
return False
|
||||
@@ -127,12 +127,12 @@ def sendNZB(nzb):
|
||||
else:
|
||||
logger.info(u"Unknown failure sending NZB to sab. Return text is: " + sabText)
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def checkConfig():
|
||||
|
||||
params = { 'mode': 'get_config',
|
||||
'section': 'misc'
|
||||
params = { 'mode': 'get_config',
|
||||
'section': 'misc'
|
||||
}
|
||||
|
||||
if headphones.CONFIG.SAB_USERNAME:
|
||||
@@ -147,18 +147,18 @@ def checkConfig():
|
||||
|
||||
if headphones.CONFIG.SAB_HOST.endswith('/'):
|
||||
headphones.CONFIG.SAB_HOST = headphones.CONFIG.SAB_HOST[0:len(headphones.CONFIG.SAB_HOST)-1]
|
||||
|
||||
|
||||
url = headphones.CONFIG.SAB_HOST + "/" + "api?" + urllib.urlencode(params)
|
||||
|
||||
|
||||
try:
|
||||
f = urllib.urlopen(url).read()
|
||||
except Exception, e:
|
||||
logger.warn("Unable to read SABnzbd config file - cannot determine renaming options (might affect auto & forced post processing)")
|
||||
return (0, 0)
|
||||
|
||||
|
||||
config_options = ast.literal_eval(f)
|
||||
|
||||
|
||||
replace_spaces = config_options['misc']['replace_spaces']
|
||||
replace_dots = config_options['misc']['replace_dots']
|
||||
|
||||
|
||||
return (replace_spaces, replace_dots)
|
||||
|
||||
@@ -347,4 +347,3 @@ class Rutracker():
|
||||
except Exception:
|
||||
logger.exception('Error adding file to utorrent')
|
||||
return
|
||||
|
||||
|
||||
@@ -260,4 +260,3 @@ def getSettingsDirectories():
|
||||
if 'dir_completed_download' in settings:
|
||||
completed = settings['dir_completed_download'][2]
|
||||
return active, completed
|
||||
|
||||
|
||||
Reference in New Issue
Block a user