fixing for pylint and pep8 recommendatins

This commit is contained in:
2013-07-12 00:02:42 +10:00
parent ca4c95219a
commit 0e3e1a2b14
7 changed files with 317 additions and 184 deletions

View File

@@ -27,39 +27,90 @@ class Settings:
"""
def __init__(self, settingsfile):
"""
Initialise settingsfile as a configobj
"""
self.__config = ConfigObj(settingsfile)
def tvrecordingdirectory(self):
"""
Get the TVRecordings setting
"""
return self.__config["TVRecordings"]
def handbrakecommand(self):
"""
Get the HandbrakeCommand setting
"""
return self.__config["HandbrakeCommand"]
def mythtvaddress(self):
"""
Get the MythTV/address setting
"""
return self.__config["MythTV"]["address"]
def mythtvuser(self):
"""
Get the MythTV/user setting
"""
return self.__config["MythTV"]["user"]
def mythtvpassword(self):
"""
Get the MythTV/password setting
"""
return self.__config["MythTV"]["password"]
def mythtvdatabase(self):
"""
Get the MythTV/database setting
"""
return self.__config["MythTV"]["database"]
def sickbeardaddress(self):
"""
Get the Sickbeard/address setting
"""
return self.__config["Sickbeard"]["address"]
def sickbeardport(self):
"""
Get the Sickbeard/port setting
"""
return int(self.__config["Sickbeard"]["port"])
def sickbeardapikey(self):
"""
Get the Sickbeard/APIKey setting
"""
return self.__config["Sickbeard"]["APIKey"]
def unknowndirectory(self):
"""
Get the Shows/UnknownInput directory. It is the directory used for
episodes where nothing is known about it
"""
return self.__config["Shows"]["UnknownInput"]
def getshownames(self, includealias=False):
"""
Get a list of the names of the shows that are specified in the
settings file. If includealias is True, it will also include any
defined aliases in the list.
"""
shows = self.__config["Shows"].sections
result = shows[:]
if includealias:
@@ -68,7 +119,30 @@ class Settings:
result.append(alias)
return result
def findshownameforalias(self, aliasname):
"""
Find the name of the show. If the supplied aliasname is an alias, it
will return the show name. If aliasname is the name of a show, it will
return aliasname
"""
if aliasname in self.getshownames():
# aliasname is the name of an actual show
return aliasname
# search for the show that the alias belongs to
for showsettings in self.__config["Shows"]:
if aliasname in showsettings["alias"]:
return showsettings.name
# Could not find it anywhere
return None
def getshowinputdirectory(self, showname):
"""
Get the InputDirectory setting for the show, showname.
"""
show = self.__getshowsubsection(showname)
if show is None:
return ""
@@ -76,6 +150,11 @@ class Settings:
return show["InputDirectory"]
def getshowunknowndirectory(self, showname):
"""
Get the UnknownDirectory setting for the show, showname. It is used
when the show is known, but the season or episode are not.
"""
show = self.__getshowsubsection(showname)
if show is None:
return ""
@@ -83,6 +162,10 @@ class Settings:
return show["UnknownDirectory"]
def getshowoutputdirectory(self, showname):
"""
Get the OutputDirectory setting for the show, showname.
"""
show = self.__getshowsubsection(showname)
if show is None:
return ""
@@ -90,6 +173,11 @@ class Settings:
return show["OutputDirectory"]
def getshowalias(self, showname):
"""
Get the alias setting for the show, showname. It returns a list of
aliases.
"""
show = self.__getshowsubsection(showname)
if show is None:
return ""
@@ -97,6 +185,10 @@ class Settings:
return show["alias"]
def getshowmythtvepisodeprefix(self, showname):
"""
Get the MythTVEpisodePrefix setting for the show, showname.
"""
show = self.__getshowsubsection(showname)
if show is None:
return ""
@@ -104,13 +196,22 @@ class Settings:
return show["MythTvEpisodePrefix"]
def getshowsickbearsepisodeprefix(self, showname):
"""
Get the SickbeardPrefix setting for the show, showname.
"""
show = self.__getshowsubsection(showname)
if show is None:
return ""
else:
return show["SickbeardPrefix"]
# TODO check if this is actually doing anything. it seems like it
# just returns what is input
def getshow(self, showname):
"""
Get the InputDirectory setting for the show, showname.
"""
showsection = self.__getshowsubsection(showname)
if showsection is None:
return None
@@ -118,6 +219,10 @@ class Settings:
return showsection.name
def __getshowsubsection(self, showname):
"""
Get the configuration options for the show, showname.
"""
if showname in self.getshownames():
return self.__config["Shows"][showname]
else: # check liases