mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-05 17:43:37 +00:00
Change browser, bs4 parser and classes code to PEP8 standards
This commit is contained in:
parent
09c4beb07c
commit
026123dc69
4 changed files with 39 additions and 35 deletions
|
@ -21,6 +21,7 @@
|
|||
* Fix Episode Status Management error popup from coming up when show is selected without expanding
|
||||
* Add BET network logo
|
||||
* Remove unused force variable from code and PEP8
|
||||
* Change browser, bs4 parser and classes code to PEP8 standards
|
||||
|
||||
[develop changelog]
|
||||
* Fix traceback error when using the menu item Manage/Update Kodi
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
# SickGear is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
@ -22,6 +22,7 @@ import string
|
|||
from sickbeard import encodingKludge as ek
|
||||
from sickbeard import logger
|
||||
|
||||
|
||||
# use the built-in if it's available (python 2.6), if not use the included library
|
||||
try:
|
||||
import json
|
||||
|
@ -32,6 +33,7 @@ except ImportError:
|
|||
if os.name == 'nt':
|
||||
from ctypes import windll
|
||||
|
||||
|
||||
# adapted from http://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python/827490
|
||||
def getWinDrives():
|
||||
""" Return list of detected drives """
|
||||
|
@ -61,11 +63,11 @@ def foldersAtPath(path, includeParent=False, includeFiles=False):
|
|||
else:
|
||||
path = os.path.dirname(path)
|
||||
|
||||
if path == "":
|
||||
if path == '':
|
||||
if os.name == 'nt':
|
||||
entries = [{'current_path': 'Root'}]
|
||||
for letter in getWinDrives():
|
||||
letterPath = letter + ':\\'
|
||||
letterPath = '%s:\\' % letter
|
||||
entries.append({'name': letterPath, 'path': letterPath})
|
||||
return entries
|
||||
else:
|
||||
|
@ -77,21 +79,23 @@ def foldersAtPath(path, includeParent=False, includeFiles=False):
|
|||
|
||||
# if we're at the root then the next step is the meta-node showing our drive letters
|
||||
if path == parentPath and os.name == 'nt':
|
||||
parentPath = ""
|
||||
parentPath = ''
|
||||
|
||||
try:
|
||||
fileList = [{'name': filename, 'path': ek.ek(os.path.join, path, filename)} for filename in ek.ek(os.listdir, path)]
|
||||
fileList = [{'name': filename, 'path': ek.ek(os.path.join, path, filename)} for filename in
|
||||
ek.ek(os.listdir, path)]
|
||||
except OSError, e:
|
||||
logger.log(u"Unable to open " + path + ": " + repr(e) + " / " + str(e), logger.WARNING)
|
||||
fileList = [{'name': filename, 'path': ek.ek(os.path.join, parentPath, filename)} for filename in ek.ek(os.listdir, parentPath)]
|
||||
logger.log(u'Unable to open %s: %r / %s' % (path, e, e), logger.WARNING)
|
||||
fileList = [{'name': filename, 'path': ek.ek(os.path.join, parentPath, filename)} for filename in
|
||||
ek.ek(os.listdir, parentPath)]
|
||||
|
||||
if not includeFiles:
|
||||
fileList = filter(lambda entry: ek.ek(os.path.isdir, entry['path']), fileList)
|
||||
|
||||
# prune out directories to proect the user from doing stupid things (already lower case the dir to reduce calls)
|
||||
hideList = ["boot", "bootmgr", "cache", "msocache", "recovery", "$recycle.bin", "recycler",
|
||||
"system volume information", "temporary internet files"] # windows specific
|
||||
hideList += [".fseventd", ".spotlight", ".trashes", ".vol", "cachedmessages", "caches", "trash"] # osx specific
|
||||
hideList = ['boot', 'bootmgr', 'cache', 'msocache', 'recovery', '$recycle.bin', 'recycler',
|
||||
'system volume information', 'temporary internet files'] # windows specific
|
||||
hideList += ['.fseventd', '.spotlight', '.trashes', '.vol', 'cachedmessages', 'caches', 'trash'] # osx specific
|
||||
fileList = filter(lambda entry: entry['name'].lower() not in hideList, fileList)
|
||||
|
||||
fileList = sorted(fileList,
|
||||
|
@ -99,7 +103,7 @@ def foldersAtPath(path, includeParent=False, includeFiles=False):
|
|||
|
||||
entries = [{'current_path': path}]
|
||||
if includeParent and parentPath != path:
|
||||
entries.append({'name': "..", 'path': parentPath})
|
||||
entries.append({'name': '..', 'path': parentPath})
|
||||
entries.extend(fileList)
|
||||
|
||||
return entries
|
|
@ -1,6 +1,6 @@
|
|||
import sickbeard
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
|
||||
class BS4Parser:
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.soup = BeautifulSoup(*args, **kwargs)
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
||||
import re
|
||||
import datetime
|
||||
import sickbeard
|
||||
|
||||
import sickbeard
|
||||
from lib.dateutil import parser
|
||||
from sickbeard.common import Quality
|
||||
|
||||
|
@ -35,7 +35,7 @@ class SearchResult:
|
|||
self.show = None
|
||||
|
||||
# URL to the NZB/torrent file
|
||||
self.url = ""
|
||||
self.url = ''
|
||||
|
||||
# used by some providers to store extra info associated with the result
|
||||
self.extraInfo = []
|
||||
|
@ -47,58 +47,57 @@ class SearchResult:
|
|||
self.quality = Quality.UNKNOWN
|
||||
|
||||
# release name
|
||||
self.name = ""
|
||||
self.name = ''
|
||||
|
||||
# size of the release (-1 = n/a)
|
||||
self.size = -1
|
||||
|
||||
# release group
|
||||
self.release_group = ""
|
||||
self.release_group = ''
|
||||
|
||||
# version
|
||||
self.version = -1
|
||||
|
||||
def __str__(self):
|
||||
|
||||
if self.provider == None:
|
||||
return "Invalid provider, unable to print self"
|
||||
if self.provider is None:
|
||||
return 'Invalid provider, unable to print self'
|
||||
|
||||
myString = self.provider.name + " @ " + self.url + "\n"
|
||||
myString += "Extra Info:\n"
|
||||
myString = '%s @ %s\n' % (self.provider.name, self.url)
|
||||
myString += 'Extra Info:\n'
|
||||
for extra in self.extraInfo:
|
||||
myString += " " + extra + "\n"
|
||||
|
||||
myString += "Episode: " + str(self.episodes) + "\n"
|
||||
myString += "Quality: " + Quality.qualityStrings[self.quality] + "\n"
|
||||
myString += "Name: " + self.name + "\n"
|
||||
myString += "Size: " + str(self.size) + "\n"
|
||||
myString += "Release Group: " + str(self.release_group) + "\n"
|
||||
myString += ' %s\n' % extra
|
||||
myString += 'Episode: %s\n' % self.episodes
|
||||
myString += 'Quality: %s\n' % Quality.qualityStrings[self.quality]
|
||||
myString += 'Name: %s\n' % self.name
|
||||
myString += 'Size: %s\n' % str(self.size)
|
||||
myString += 'Release Group: %s\n' % self.release_group
|
||||
|
||||
return myString
|
||||
|
||||
def fileName(self):
|
||||
return self.episodes[0].prettyName() + "." + self.resultType
|
||||
return self.episodes[0].prettyName() + '.' + self.resultType
|
||||
|
||||
|
||||
class NZBSearchResult(SearchResult):
|
||||
"""
|
||||
Regular NZB result with an URL to the NZB
|
||||
"""
|
||||
resultType = "nzb"
|
||||
resultType = 'nzb'
|
||||
|
||||
|
||||
class NZBDataSearchResult(SearchResult):
|
||||
"""
|
||||
NZB result where the actual NZB XML data is stored in the extraInfo
|
||||
"""
|
||||
resultType = "nzbdata"
|
||||
resultType = 'nzbdata'
|
||||
|
||||
|
||||
class TorrentSearchResult(SearchResult):
|
||||
"""
|
||||
Torrent result with an URL to the torrent
|
||||
"""
|
||||
resultType = "torrent"
|
||||
resultType = 'torrent'
|
||||
|
||||
# torrent hash
|
||||
content = None
|
||||
|
@ -138,9 +137,9 @@ class AllShowsListUI:
|
|||
if searchterm.lower() in name.lower():
|
||||
if 'firstaired' not in curShow:
|
||||
curShow['firstaired'] = str(datetime.date.fromordinal(1))
|
||||
curShow['firstaired'] = re.sub("([-]0{2}){1,}", "", curShow['firstaired'])
|
||||
curShow['firstaired'] = re.sub('([-]0{2}){1,}', '', curShow['firstaired'])
|
||||
fixDate = parser.parse(curShow['firstaired'], fuzzy=True).date()
|
||||
curShow['firstaired'] = fixDate.strftime("%Y-%m-%d")
|
||||
curShow['firstaired'] = fixDate.strftime('%Y-%m-%d')
|
||||
|
||||
if curShow not in searchResults:
|
||||
searchResults += [curShow]
|
||||
|
@ -191,8 +190,8 @@ class Proper:
|
|||
self.scene_episode = -1
|
||||
|
||||
def __str__(self):
|
||||
return str(self.date) + " " + self.name + " " + str(self.season) + "x" + str(self.episode) + " of " + str(
|
||||
self.indexerid) + " from " + str(sickbeard.indexerApi(self.indexer).name)
|
||||
return str(self.date) + ' ' + self.name + ' ' + str(self.season) + 'x' + str(self.episode) + ' of ' + str(
|
||||
self.indexerid) + ' from ' + str(sickbeard.indexerApi(self.indexer).name)
|
||||
|
||||
|
||||
class ErrorViewer():
|
||||
|
|
Loading…
Reference in a new issue