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
|
return None
|
||||||
|
|
||||||
def dump_data(self):
|
def dump_data(self):
|
||||||
fmt = '%s [count=%s]'
|
fmt = '%s [count=%s%s]'
|
||||||
if self.type == self.CATEGORY:
|
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
|
tag = self.tag
|
||||||
if tag.use_sort_as_name:
|
if tag.use_sort_as_name:
|
||||||
name = tag.sort
|
name = tag.sort
|
||||||
@ -172,7 +172,10 @@ class TagTreeItem(object): # {{{
|
|||||||
name = tag.name
|
name = tag.name
|
||||||
count = len(self.id_set)
|
count = len(self.id_set)
|
||||||
count = count if count > 0 else tag.count
|
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):
|
def toggle(self, set_to=None):
|
||||||
'''
|
'''
|
||||||
|
@ -408,8 +408,11 @@ def dump_categories_tree(data):
|
|||||||
ans, indent = [], ' '
|
ans, indent = [], ' '
|
||||||
def dump_node(node, level=0):
|
def dump_node(node, level=0):
|
||||||
item = items[node['id']]
|
item = items[node['id']]
|
||||||
|
rating = item.get('avg_rating', None) or 0
|
||||||
|
if rating:
|
||||||
|
rating = ',rating=%.1f' % rating
|
||||||
try:
|
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:
|
except KeyError:
|
||||||
print(item)
|
print(item)
|
||||||
raise
|
raise
|
||||||
|
Loading…
x
Reference in New Issue
Block a user