Browse Source

Py3: Remove over-active 2to3 dictionary items/keys/values conversion

pull/1161/head
Safihre 8 years ago
parent
commit
3b36cfe4c9
  1. 4
      sabnzbd/api.py
  2. 12
      sabnzbd/bpsmeter.py
  3. 8
      sabnzbd/config.py
  4. 2
      sabnzbd/database.py
  5. 4
      sabnzbd/downloader.py
  6. 2
      sabnzbd/interface.py
  7. 2
      sabnzbd/nzbqueue.py
  8. 4
      sabnzbd/nzbstuff.py
  9. 2
      sabnzbd/osxmenu.py
  10. 2
      sabnzbd/rating.py
  11. 4
      sabnzbd/rss.py
  12. 8
      sabnzbd/tvsort.py
  13. 2
      sabnzbd/utils/rsslib.py

4
sabnzbd/api.py

@ -1062,7 +1062,7 @@ class xml_factory(object):
def _dict(self, keyw, lst):
text = []
for key in list(lst.keys()):
for key in lst.keys():
text.append(self.run(key, lst[key]))
if keyw:
return '<%s>%s</%s>\n' % (keyw, ''.join(text), keyw)
@ -1947,7 +1947,7 @@ def list_cats(default=True):
def remove_callable(dic):
""" Remove all callable items from dictionary """
for key, value in list(dic.items()):
for key, value in dic.items():
if callable(value):
del dic[key]
return dic

12
sabnzbd/bpsmeter.py

@ -190,7 +190,7 @@ class BPSMeter(object):
self.defaults()
# Force update of counters and validate data
try:
for server in list(self.grand_total.keys()):
for server in self.grand_total.keys():
self.update(server)
except TypeError:
self.defaults()
@ -292,10 +292,10 @@ class BPSMeter(object):
def get_sums(self):
""" return tuple of grand, month, week, day totals """
return (sum([v for v in list(self.grand_total.values())]),
sum([v for v in list(self.month_total.values())]),
sum([v for v in list(self.week_total.values())]),
sum([v for v in list(self.day_total.values())])
return (sum([v for v in self.grand_total.values()]),
sum([v for v in self.month_total.values()]),
sum([v for v in self.week_total.values()]),
sum([v for v in self.day_total.values()])
)
def amounts(self, server):
@ -472,7 +472,7 @@ class BPSMeter(object):
def midnight(self):
""" Midnight action: dummy update for all servers """
for server in list(self.day_total.keys()):
for server in self.day_total.keys():
self.update(server)

8
sabnzbd/config.py

@ -623,7 +623,7 @@ def get_dconfig(section, keyword, nested=False):
"""
data = {}
if not section:
for section in list(database.keys()):
for section in database.keys():
res, conf = get_dconfig(section, None, True)
data.update(conf)
@ -634,12 +634,12 @@ def get_dconfig(section, keyword, nested=False):
return False, {}
if section in ('servers', 'categories', 'rss'):
data[section] = []
for keyword in list(sect.keys()):
for keyword in sect.keys():
res, conf = get_dconfig(section, keyword, True)
data[section].append(conf)
else:
data[section] = {}
for keyword in list(sect.keys()):
for keyword in sect.keys():
res, conf = get_dconfig(section, keyword, True)
data[section].update(conf)
@ -951,7 +951,7 @@ def get_ordered_categories():
# Transform to list and sort
categories = []
for cat in list(database_cats.keys()):
for cat in database_cats.keys():
if cat != '*':
categories.append(database_cats[cat].get_dict())

2
sabnzbd/database.py

@ -479,7 +479,7 @@ def build_history_info(nzo, storage='', downpath='', postproc_time=0, script_out
# Pack the dictionary up into a single string
# Stage Name is separated by ::: stage lines by ; and stages by \r\n
lines = []
for key, results in list(stages.items()):
for key, results in stages.items():
lines.append('%s:::%s' % (key, ';'.join(results)))
stage_log = '\r\n'.join(lines)

4
sabnzbd/downloader.py

@ -878,7 +878,7 @@ class Downloader(Thread):
break
def unblock_all(self):
for server_id in list(self._timers.keys()):
for server_id in self._timers.keys():
self.unblock(server_id)
@NzbQueueLocker
@ -888,7 +888,7 @@ class Downloader(Thread):
# Clean expired timers
now = time.time()
kicked = []
for server_id in list(self._timers.keys()):
for server_id in self._timers.keys():
if not [stamp for stamp in self._timers[server_id] if stamp >= now]:
logging.debug('Forcing re-evaluation of server %s', server_id)
del self._timers[server_id]

2
sabnzbd/interface.py

@ -1726,7 +1726,7 @@ def handle_server(kwargs, root=None, new_svr=False):
server = unique_svr_name(server)
for kw in ('ssl', 'send_group', 'enable', 'optional'):
if kw not in list(kwargs.keys()):
if kw not in kwargs.keys():
kwargs[kw] = None
if svr and not new_svr:
svr.set_dict(kwargs)

2
sabnzbd/nzbqueue.py

@ -424,7 +424,7 @@ class NzbQueue(object):
if search:
search = search.lower()
removed = []
for nzo_id in list(self.__nzo_table.keys()):
for nzo_id in self.__nzo_table.keys():
if (not search) or search in self.__nzo_table[nzo_id].final_name_pw_clean.lower():
nzo = self.__nzo_table.pop(nzo_id)
nzo.deleted = True

4
sabnzbd/nzbstuff.py

@ -1002,7 +1002,7 @@ class NzbObject(TryList):
# If we couldn't parse it, we ignore it
if pack:
if pack not in list(self.md5packs.values()):
if pack not in self.md5packs.values():
logging.debug('Got md5pack for set %s', nzf.setname)
self.md5packs[setname] = pack
# See if we need to postpone some pars
@ -1348,7 +1348,7 @@ class NzbObject(TryList):
if not nzf.is_par2:
# We have to find the right par-set
blocks_new = 0
for parset in list(self.extrapars.keys()):
for parset in self.extrapars.keys():
if (parset in nzf.filename or parset in original_filename) and self.extrapars[parset]:
for new_nzf in self.extrapars[parset]:
self.add_parfile(new_nzf)

2
sabnzbd/osxmenu.py

@ -80,7 +80,7 @@ class SABnzbdDelegate(NSObject):
# logging.info("building menu")
status_bar = NSStatusBar.systemStatusBar()
self.status_item = status_bar.statusItemWithLength_(NSVariableStatusItemLength)
for i in list(status_icons.keys()):
for i in status_icons.keys():
self.icons[i] = NSImage.alloc().initByReferencingFile_(status_icons[i])
if sabnzbd.DARWIN_VERSION > 9:
# Support for Yosemite Dark Mode

2
sabnzbd/rating.py

@ -122,7 +122,7 @@ class Rating(Thread):
silent=not cfg.rating_enable())
if self.version == 1:
ratings = {}
for k, v in list(self.ratings.items()):
for k, v in self.ratings.items():
ratings[k] = NzbRatingV2().to_v2(v)
self.ratings = ratings
self.version = 2

4
sabnzbd/rss.py

@ -344,7 +344,7 @@ class RSSQueue(object):
# If there's multiple feeds, remove the duplicates based on title and size
if len(uris) > 1:
skip_job = False
for job_link, job in list(jobs.items()):
for job_link, job in jobs.items():
# Allow 5% size deviation because indexers might have small differences for same release
if job.get('title') == title and link != job_link and (job.get('size')*0.95) < size < (job.get('size')*1.05):
logging.info("Ignoring job %s from other feed", title)
@ -504,7 +504,7 @@ class RSSQueue(object):
if self.next_run < time.time():
self.next_run = time.time() + cfg.rss_rate.get() * 60
feeds = config.get_rss()
for feed in list(feeds.keys()):
for feed in feeds.keys():
try:
if feeds[feed].enable.get():
logging.info('Starting scheduled RSS read-out for "%s"', feed)

8
sabnzbd/tvsort.py

@ -360,7 +360,7 @@ class SeriesSorter(object):
# Replace elements
path = path_subst(sorter, mapping)
for key, name in list(REPLACE_AFTER.items()):
for key, name in REPLACE_AFTER.items():
path = path.replace(key, name)
# Lowercase all characters wrapped in {}
@ -609,7 +609,7 @@ class GenericSorter(object):
path = path_subst(sorter, mapping)
for key, name in list(REPLACE_AFTER.items()):
for key, name in REPLACE_AFTER.items():
path = path.replace(key, name)
# Lowercase all characters wrapped in {}
@ -676,7 +676,7 @@ class GenericSorter(object):
if matched_files:
logging.debug("Renaming a series of generic files (%s)", matched_files)
renamed = list(matched_files.values())
for index, file in list(matched_files.items()):
for index, file in matched_files.items():
filepath = os.path.join(current_path, file)
renamed.append(filepath)
self.fname, ext = os.path.splitext(os.path.split(file)[1])
@ -828,7 +828,7 @@ class DateSorter(object):
path = path_subst(sorter, mapping)
for key, name in list(REPLACE_AFTER.items()):
for key, name in REPLACE_AFTER.items():
path = path.replace(key, name)
# Lowercase all characters wrapped in {}

2
sabnzbd/utils/rsslib.py

@ -208,7 +208,7 @@ class RSS:
c+= "length=\"" + str(i.enclosure.length )+ "\" "
c+= "type=\"" + i.enclosure.type + "\"/>\n"
for k in list(i.nsItems.keys()):
for k in i.nsItems.keys():
c += self.optionalWrite( k , i.nsItems[ k ] )
c += "</item>\n\n"

Loading…
Cancel
Save