From 73693115010bf424e67dbf8f25210a4c862500ed Mon Sep 17 00:00:00 2001 From: Jesse Mullan Date: Mon, 27 Oct 2014 11:03:41 -0700 Subject: [PATCH] manual pep8 W291,W293,W391 blank lines, trailing whitespace --- headphones/classes.py | 6 +++--- headphones/cuesplit.py | 32 +++++++++++++++----------------- headphones/db.py | 8 ++++---- headphones/sab.py | 20 ++++++++++---------- headphones/searcher_rutracker.py | 1 - headphones/utorrent.py | 1 - 6 files changed, 32 insertions(+), 36 deletions(-) diff --git a/headphones/classes.py b/headphones/classes.py index acb29f86..165039e9 100644 --- a/headphones/classes.py +++ b/headphones/classes.py @@ -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 ('', '') diff --git a/headphones/cuesplit.py b/headphones/cuesplit.py index b85a319a..0833a138 100755 --- a/headphones/cuesplit.py +++ b/headphones/cuesplit.py @@ -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 - - diff --git a/headphones/db.py b/headphones/db.py index c943b66f..717e8ac2 100644 --- a/headphones/db.py +++ b/headphones/db.py @@ -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 [] diff --git a/headphones/sab.py b/headphones/sab.py index 1a67c028..5d55913e 100644 --- a/headphones/sab.py +++ b/headphones/sab.py @@ -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) diff --git a/headphones/searcher_rutracker.py b/headphones/searcher_rutracker.py index 815cd903..4601efa6 100644 --- a/headphones/searcher_rutracker.py +++ b/headphones/searcher_rutracker.py @@ -347,4 +347,3 @@ class Rutracker(): except Exception: logger.exception('Error adding file to utorrent') return - diff --git a/headphones/utorrent.py b/headphones/utorrent.py index 0e43fff6..df46de70 100644 --- a/headphones/utorrent.py +++ b/headphones/utorrent.py @@ -260,4 +260,3 @@ def getSettingsDirectories(): if 'dir_completed_download' in settings: completed = settings['dir_completed_download'][2] return active, completed -