mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-06 21:21:12 -07:00
PEP8: Tests for membership should use in
/not in
* .has_key() is deprecated, use `in`
This commit is contained in:
parent
92ae852513
commit
1fd904eb5b
5 changed files with 37 additions and 37 deletions
|
@ -227,7 +227,7 @@ def initialize(section=None):
|
|||
if __INITIALIZED__:
|
||||
return False
|
||||
|
||||
if os.environ.has_key('NTM_LOGFILE'):
|
||||
if 'NTM_LOGFILE' in os.environ:
|
||||
LOG_FILE = os.environ['NTM_LOGFILE']
|
||||
LOG_DIR = os.path.split(LOG_FILE)[0]
|
||||
|
||||
|
@ -259,7 +259,7 @@ def initialize(section=None):
|
|||
except:
|
||||
print 'Sorry, you MUST add the nzbToMedia folder to the PYTHONPATH environment variable'
|
||||
print 'or find another way to force Python to use ' + SYS_ENCODING + ' for string encoding.'
|
||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
if 'NZBOP_SCRIPTDIR' in os.environ:
|
||||
sys.exit(NZBGET_POSTPROCESS_ERROR)
|
||||
else:
|
||||
sys.exit(1)
|
||||
|
@ -270,13 +270,13 @@ def initialize(section=None):
|
|||
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
||||
if not config.migrate():
|
||||
logger.error("Unable to migrate config file %s, exiting ..." % (CONFIG_FILE))
|
||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
if 'NZBOP_SCRIPTDIR' in os.environ:
|
||||
pass # We will try and read config from Environment.
|
||||
else:
|
||||
sys.exit(-1)
|
||||
|
||||
# run migrate to convert NzbGet data from old cfg style to new cfg style
|
||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
if 'NZBOP_SCRIPTDIR' in os.environ:
|
||||
CFG = config.addnzbget()
|
||||
|
||||
else: # load newly migrated config
|
||||
|
@ -441,9 +441,9 @@ def initialize(section=None):
|
|||
GENERALOPTS = GENERALOPTS.split(',')
|
||||
if GENERALOPTS == ['']:
|
||||
GENERALOPTS = []
|
||||
if not '-fflags' in GENERALOPTS:
|
||||
if '-fflags' not in GENERALOPTS:
|
||||
GENERALOPTS.append('-fflags')
|
||||
if not '+genpts' in GENERALOPTS:
|
||||
if '+genpts' not in GENERALOPTS:
|
||||
GENERALOPTS.append('+genpts')
|
||||
try:
|
||||
OUTPUTQUALITYPERCENT = int(CFG["Transcoder"]["outputQualityPercent"])
|
||||
|
|
|
@ -228,7 +228,7 @@ class NTMRotatingLogHandler(object):
|
|||
def log_error_and_exit(self, error_msg):
|
||||
log(error_msg, ERROR)
|
||||
|
||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
if 'NZBOP_SCRIPTDIR' in os.environ:
|
||||
sys.exit(core.NZBGET_POSTPROCESS_ERROR)
|
||||
elif not self.console_logging:
|
||||
sys.exit(error_msg.encode(core.SYS_ENCODING, 'xmlcharrefreplace'))
|
||||
|
|
|
@ -186,7 +186,7 @@ class ConfigObj(configobj.ConfigObj, Section):
|
|||
CFG_NEW['Posix'][option] = value
|
||||
values.pop(option)
|
||||
if option == "remote_path":
|
||||
if value and not value in ['0', '1', 0, 1]:
|
||||
if value and value not in ['0', '1', 0, 1]:
|
||||
value = 1
|
||||
elif not value:
|
||||
value = 0
|
||||
|
@ -251,14 +251,14 @@ class ConfigObj(configobj.ConfigObj, Section):
|
|||
CFG_NEW = config()
|
||||
|
||||
try:
|
||||
if os.environ.has_key('NZBPO_NDCATEGORY') and os.environ.has_key('NZBPO_SBCATEGORY'):
|
||||
if 'NZBPO_NDCATEGORY' in os.environ and 'NZBPO_SBCATEGORY' in os.environ:
|
||||
if os.environ['NZBPO_NDCATEGORY'] == os.environ['NZBPO_SBCATEGORY']:
|
||||
logger.warning("%s category is set for SickBeard and NzbDrone. "
|
||||
"Please check your config in NZBGet" % (os.environ['NZBPO_NDCATEGORY']))
|
||||
|
||||
section = "Nzb"
|
||||
key = 'NZBOP_DESTDIR'
|
||||
if os.environ.has_key(key):
|
||||
if key in os.environ:
|
||||
option = 'default_downloadDirectory'
|
||||
value = os.environ[key]
|
||||
CFG_NEW[section][option] = value
|
||||
|
@ -268,7 +268,7 @@ class ConfigObj(configobj.ConfigObj, Section):
|
|||
cfgKeys = ['auto_update', 'check_media', 'safe_mode']
|
||||
for index in range(len(envKeys)):
|
||||
key = 'NZBPO_' + envKeys[index]
|
||||
if os.environ.has_key(key):
|
||||
if key in os.environ:
|
||||
option = cfgKeys[index]
|
||||
value = os.environ[key]
|
||||
CFG_NEW[section][option] = value
|
||||
|
@ -278,7 +278,7 @@ class ConfigObj(configobj.ConfigObj, Section):
|
|||
cfgKeys = ['mount_points']
|
||||
for index in range(len(envKeys)):
|
||||
key = 'NZBPO_' + envKeys[index]
|
||||
if os.environ.has_key(key):
|
||||
if key in os.environ:
|
||||
option = cfgKeys[index]
|
||||
value = os.environ[key]
|
||||
CFG_NEW[section][option] = value
|
||||
|
@ -289,10 +289,10 @@ class ConfigObj(configobj.ConfigObj, Section):
|
|||
'WAIT_FOR', 'WATCH_DIR']
|
||||
cfgKeys = ['enabled', 'apikey', 'host', 'port', 'ssl', 'web_root', 'method', 'delete_failed', 'remote_path',
|
||||
'wait_for', 'watch_dir']
|
||||
if os.environ.has_key(envCatKey):
|
||||
if envCatKey in os.environ:
|
||||
for index in range(len(envKeys)):
|
||||
key = 'NZBPO_CPS' + envKeys[index]
|
||||
if os.environ.has_key(key):
|
||||
if key in os.environ:
|
||||
option = cfgKeys[index]
|
||||
value = os.environ[key]
|
||||
if os.environ[envCatKey] not in CFG_NEW[section].sections:
|
||||
|
@ -306,10 +306,10 @@ class ConfigObj(configobj.ConfigObj, Section):
|
|||
'DELETE_FAILED', 'TORRENT_NOLINK', 'NZBEXTRACTIONBY', 'REMOTE_PATH', 'PROCESS_METHOD']
|
||||
cfgKeys = ['enabled', 'host', 'port', 'username', 'password', 'ssl', 'web_root', 'watch_dir', 'fork',
|
||||
'delete_failed', 'Torrent_NoLink', 'nzbExtractionBy', 'remote_path', 'process_method']
|
||||
if os.environ.has_key(envCatKey):
|
||||
if envCatKey in os.environ:
|
||||
for index in range(len(envKeys)):
|
||||
key = 'NZBPO_SB' + envKeys[index]
|
||||
if os.environ.has_key(key):
|
||||
if key in os.environ:
|
||||
option = cfgKeys[index]
|
||||
value = os.environ[key]
|
||||
if os.environ[envCatKey] not in CFG_NEW[section].sections:
|
||||
|
@ -323,10 +323,10 @@ class ConfigObj(configobj.ConfigObj, Section):
|
|||
envCatKey = 'NZBPO_HPCATEGORY'
|
||||
envKeys = ['ENABLED', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'WAIT_FOR', 'WATCH_DIR', 'REMOTE_PATH']
|
||||
cfgKeys = ['enabled', 'apikey', 'host', 'port', 'ssl', 'web_root', 'wait_for', 'watch_dir', 'remote_path']
|
||||
if os.environ.has_key(envCatKey):
|
||||
if envCatKey in os.environ:
|
||||
for index in range(len(envKeys)):
|
||||
key = 'NZBPO_HP' + envKeys[index]
|
||||
if os.environ.has_key(key):
|
||||
if key in os.environ:
|
||||
option = cfgKeys[index]
|
||||
value = os.environ[key]
|
||||
if os.environ[envCatKey] not in CFG_NEW[section].sections:
|
||||
|
@ -340,10 +340,10 @@ class ConfigObj(configobj.ConfigObj, Section):
|
|||
'REMOTE_PATH']
|
||||
cfgKeys = ['enabled', 'host', 'port', 'username', 'password', 'apikey', 'ssl', 'web_root', 'watch_dir',
|
||||
'remote_path']
|
||||
if os.environ.has_key(envCatKey):
|
||||
if envCatKey in os.environ:
|
||||
for index in range(len(envKeys)):
|
||||
key = 'NZBPO_MY' + envKeys[index]
|
||||
if os.environ.has_key(key):
|
||||
if key in os.environ:
|
||||
option = cfgKeys[index]
|
||||
value = os.environ[key]
|
||||
if os.environ[envCatKey] not in CFG_NEW[section].sections:
|
||||
|
@ -355,10 +355,10 @@ class ConfigObj(configobj.ConfigObj, Section):
|
|||
envCatKey = 'NZBPO_GZCATEGORY'
|
||||
envKeys = ['ENABLED', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'LIBRARY', 'REMOTE_PATH']
|
||||
cfgKeys = ['enabled', 'apikey', 'host', 'port', 'ssl', 'web_root', 'watch_dir', 'library', 'remote_path']
|
||||
if os.environ.has_key(envCatKey):
|
||||
if envCatKey in os.environ:
|
||||
for index in range(len(envKeys)):
|
||||
key = 'NZBPO_GZ' + envKeys[index]
|
||||
if os.environ.has_key(key):
|
||||
if key in os.environ:
|
||||
option = cfgKeys[index]
|
||||
value = os.environ[key]
|
||||
if os.environ[envCatKey] not in CFG_NEW[section].sections:
|
||||
|
@ -372,10 +372,10 @@ class ConfigObj(configobj.ConfigObj, Section):
|
|||
'TORRENT_NOLINK', 'NZBEXTRACTIONBY', 'WAIT_FOR', 'DELETE_FAILED', 'REMOTE_PATH']
|
||||
cfgKeys = ['enabled', 'host', 'apikey', 'port', 'ssl', 'web_root', 'watch_dir', 'fork', 'delete_failed',
|
||||
'Torrent_NoLink', 'nzbExtractionBy', 'wait_for', 'delete_failed', 'remote_path']
|
||||
if os.environ.has_key(envCatKey):
|
||||
if envCatKey in os.environ:
|
||||
for index in range(len(envKeys)):
|
||||
key = 'NZBPO_ND' + envKeys[index]
|
||||
if os.environ.has_key(key):
|
||||
if key in os.environ:
|
||||
option = cfgKeys[index]
|
||||
value = os.environ[key]
|
||||
if os.environ[envCatKey] not in CFG_NEW[section].sections:
|
||||
|
@ -390,7 +390,7 @@ class ConfigObj(configobj.ConfigObj, Section):
|
|||
cfgKeys = ['compressedExtensions', 'mediaExtensions', 'metaExtensions']
|
||||
for index in range(len(envKeys)):
|
||||
key = 'NZBPO_' + envKeys[index]
|
||||
if os.environ.has_key(key):
|
||||
if key in os.environ:
|
||||
option = cfgKeys[index]
|
||||
value = os.environ[key]
|
||||
CFG_NEW[section][option] = value
|
||||
|
@ -400,7 +400,7 @@ class ConfigObj(configobj.ConfigObj, Section):
|
|||
cfgKeys = ['niceness', 'ionice_class', 'ionice_classdata']
|
||||
for index in range(len(envKeys)):
|
||||
key = 'NZBPO_' + envKeys[index]
|
||||
if os.environ.has_key(key):
|
||||
if key in os.environ:
|
||||
option = cfgKeys[index]
|
||||
value = os.environ[key]
|
||||
CFG_NEW[section][option] = value
|
||||
|
@ -428,7 +428,7 @@ class ConfigObj(configobj.ConfigObj, Section):
|
|||
'outputAudioOtherChannels']
|
||||
for index in range(len(envKeys)):
|
||||
key = 'NZBPO_' + envKeys[index]
|
||||
if os.environ.has_key(key):
|
||||
if key in os.environ:
|
||||
option = cfgKeys[index]
|
||||
value = os.environ[key]
|
||||
CFG_NEW[section][option] = value
|
||||
|
@ -438,7 +438,7 @@ class ConfigObj(configobj.ConfigObj, Section):
|
|||
cfgKeys = ['wake', 'host', 'port', 'mac']
|
||||
for index in range(len(envKeys)):
|
||||
key = 'NZBPO_WOL' + envKeys[index]
|
||||
if os.environ.has_key(key):
|
||||
if key in os.environ:
|
||||
option = cfgKeys[index]
|
||||
value = os.environ[key]
|
||||
CFG_NEW[section][option] = value
|
||||
|
@ -449,10 +449,10 @@ class ConfigObj(configobj.ConfigObj, Section):
|
|||
'USER_SCRIPT_SUCCESSCODES', 'USER_SCRIPT_CLEAN', 'USDELAY', 'USREMOTE_PATH']
|
||||
cfgKeys = ['user_script_mediaExtensions', 'user_script_path', 'user_script_param', 'user_script_runOnce',
|
||||
'user_script_successCodes', 'user_script_clean', 'delay', 'remote_path']
|
||||
if os.environ.has_key(envCatKey):
|
||||
if envCatKey in os.environ:
|
||||
for index in range(len(envKeys)):
|
||||
key = 'NZBPO_' + envKeys[index]
|
||||
if os.environ.has_key(key):
|
||||
if key in os.environ:
|
||||
option = cfgKeys[index]
|
||||
value = os.environ[key]
|
||||
if os.environ[envCatKey] not in CFG_NEW[section].sections:
|
||||
|
|
|
@ -157,7 +157,7 @@ def category_search(inputDirectory, inputName, inputCategory, root, categories):
|
|||
tordir = True
|
||||
|
||||
imdbid = [item for item in pathlist if '.cp(tt' in item] # This looks for the .cp(tt imdb id in the path.
|
||||
if imdbid and not '.cp(tt' in inputName:
|
||||
if imdbid and '.cp(tt' not in inputName:
|
||||
inputName = imdbid[0] # This ensures the imdb id is preserved and passed to CP
|
||||
tordir = True
|
||||
|
||||
|
@ -454,7 +454,7 @@ def convert_to_ascii(inputName, dirName):
|
|||
dirName = os.path.join(dir, base2)
|
||||
logger.info("Renaming directory to: %s." % (base2), 'ENCODER')
|
||||
os.rename(os.path.join(dir, base), dirName)
|
||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
if 'NZBOP_SCRIPTDIR' in os.environ:
|
||||
print "[NZB] DIRECTORY=%s" % (dirName) # Return the new directory to NZBGet.
|
||||
|
||||
for dirname, dirnames, filenames in os.walk(dirName, topdown=False):
|
||||
|
@ -1038,7 +1038,7 @@ def find_imdbid(dirName, inputName):
|
|||
imdbid = m.group(1)
|
||||
logger.info("Found imdbID [%s] via file name" % imdbid)
|
||||
return imdbid
|
||||
if os.environ.has_key('NZBPR__DNZB_MOREINFO'):
|
||||
if 'NZBPR__DNZB_MOREINFO' in os.environ:
|
||||
dnzb_more_info = os.environ.get('NZBPR__DNZB_MOREINFO', '')
|
||||
if dnzb_more_info != '':
|
||||
regex = re.compile(r'^http://www.imdb.com/title/(tt[0-9]+)/$', re.IGNORECASE)
|
||||
|
@ -1110,7 +1110,7 @@ def extractFiles(src, dst=None, keep_archive=None):
|
|||
fullFileName = os.path.basename(inputFile)
|
||||
archiveName = os.path.splitext(fullFileName)[0]
|
||||
archiveName = re.sub(r"part[0-9]+", "", archiveName)
|
||||
if not archiveName in extracted_archive or keep_archive is True:
|
||||
if archiveName not in extracted_archive or keep_archive is True:
|
||||
continue # don't remove if we haven't extracted this archive, or if we want to preserve them.
|
||||
logger.info("Removing extracted archive %s from folder %s ..." % (fullFileName, folder))
|
||||
try:
|
||||
|
|
|
@ -594,11 +594,11 @@ def processList(List, newDir, bitbucket):
|
|||
for item in List:
|
||||
newfile = None
|
||||
ext = os.path.splitext(item)[1].lower()
|
||||
if ext in ['.iso', '.bin', '.img'] and not ext in core.IGNOREEXTENSIONS:
|
||||
if ext in ['.iso', '.bin', '.img'] and ext not in core.IGNOREEXTENSIONS:
|
||||
logger.debug("Attempting to rip disk image: %s" % (item), "TRANSCODER")
|
||||
newList.extend(ripISO(item, newDir, bitbucket))
|
||||
remList.append(item)
|
||||
elif re.match(".+VTS_[0-9][0-9]_[0-9].[Vv][Oo][Bb]", item) and not '.vob' in core.IGNOREEXTENSIONS:
|
||||
elif re.match(".+VTS_[0-9][0-9]_[0-9].[Vv][Oo][Bb]", item) and '.vob' not in core.IGNOREEXTENSIONS:
|
||||
logger.debug("Found VIDEO_TS image file: %s" % (item), "TRANSCODER")
|
||||
if not vtsPath:
|
||||
try:
|
||||
|
@ -618,7 +618,7 @@ def processList(List, newDir, bitbucket):
|
|||
if combine:
|
||||
newList.extend(combineCD(combine))
|
||||
for file in newList:
|
||||
if isinstance(file, str) and not 'concat:' in file and not os.path.isfile(file):
|
||||
if isinstance(file, str) and 'concat:' not in file and not os.path.isfile(file):
|
||||
success = False
|
||||
break
|
||||
if success and newList:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue