mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Output rating when dumping tag trees
This commit is contained in:
parent
039a582b96
commit
4b7ed56566
@ -159,9 +159,9 @@ class TagTreeItem(object): # {{{
|
||||
return None
|
||||
|
||||
def dump_data(self):
|
||||
fmt = '%s [count=%s]'
|
||||
fmt = '%s [count=%s%s]'
|
||||
if self.type == self.CATEGORY:
|
||||
return fmt % (self.py_name, len(self.child_tags()))
|
||||
return fmt % (self.py_name, len(self.child_tags()), '')
|
||||
tag = self.tag
|
||||
if tag.use_sort_as_name:
|
||||
name = tag.sort
|
||||
@ -172,7 +172,10 @@ class TagTreeItem(object): # {{{
|
||||
name = tag.name
|
||||
count = len(self.id_set)
|
||||
count = count if count > 0 else tag.count
|
||||
return fmt % (name, count,)
|
||||
rating = tag.avg_rating or 0
|
||||
if rating:
|
||||
rating = ',rating=%.1f' % rating
|
||||
return fmt % (name, count, rating or '')
|
||||
|
||||
def toggle(self, set_to=None):
|
||||
'''
|
||||
|
@ -408,8 +408,11 @@ def dump_categories_tree(data):
|
||||
ans, indent = [], ' '
|
||||
def dump_node(node, level=0):
|
||||
item = items[node['id']]
|
||||
rating = item.get('avg_rating', None) or 0
|
||||
if rating:
|
||||
rating = ',rating=%.1f' % rating
|
||||
try:
|
||||
ans.append(indent*level + item['name'] + ' [count=%s]' % (item['count'],))
|
||||
ans.append(indent*level + item['name'] + ' [count=%s%s]' % (item['count'], rating or ''))
|
||||
except KeyError:
|
||||
print(item)
|
||||
raise
|
||||
|
Loading…
x
Reference in New Issue
Block a user