Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
{'title': 'Limits', 'width': 24, 'items': (
Item('Upload rate',
needed_keys=('limit-rate-up',),
human_readable=partial(_limit_rate_hr, 'up'),
machine_readable=partial(_limit_rate_mr, 'up')),
Item('Download rate',
needed_keys=('limit-rate-down',),
human_readable=partial(_limit_rate_hr, 'down'),
machine_readable=partial(_limit_rate_mr, 'down')),
)},
{'title': 'Peers', 'width': 18, 'items': (
Item('Seeding',
needed_keys=('peers-seeding',)),
Item('Connected',
needed_keys=('peers-connected',)),
Item('Uploading',
needed_keys=('peers-uploading',)),
Item('Downloading',
needed_keys=('peers-downloading',)),
)},
{'title': 'Dates and Times', 'width': 44, 'items': (
Item('Created',
needed_keys=('time-created',),
human_readable=partial(_date_hr, 'time-created'),
machine_readable=partial(_date_mr, 'time-created')),
Item('Added',
needed_keys=('time-added',),
human_readable=partial(_date_hr, 'time-added'),
machine_readable=partial(_date_mr, 'time-added')),
human_readable=_ratio_hr,
machine_readable=_ratio_mr),
Item('Isolated',
needed_keys=('status',),
human_readable=_isolated_hr,
machine_readable=_isolated_mr),
Item('Error',
needed_keys=('error',)),
)},
{'title': 'Limits', 'width': 24, 'items': (
Item('Upload rate',
needed_keys=('limit-rate-up',),
human_readable=partial(_limit_rate_hr, 'up'),
machine_readable=partial(_limit_rate_mr, 'up')),
Item('Download rate',
needed_keys=('limit-rate-down',),
human_readable=partial(_limit_rate_hr, 'down'),
machine_readable=partial(_limit_rate_mr, 'down')),
)},
{'title': 'Peers', 'width': 18, 'items': (
Item('Seeding',
needed_keys=('peers-seeding',)),
Item('Connected',
needed_keys=('peers-connected',)),
Item('Uploading',
needed_keys=('peers-uploading',)),
Item('Downloading',
needed_keys=('peers-downloading',)),
)},
machine_readable=_status_mr),
Item('Location',
needed_keys=('path',),),
Item('Available',
needed_keys=('%available', 'size-available'),
human_readable=_available_hr,
machine_readable=_available_mr),
Item('Downloaded',
needed_keys=('size-downloaded', 'size-left', '%downloaded', 'timespan-eta'),
human_readable=_downloaded_hr,
machine_readable=_downloaded_mr),
Item('Uploaded',
needed_keys=('size-uploaded', 'size-total', '%uploaded'),
human_readable=_uploaded_hr,
machine_readable=_uploaded_mr),
Item('Ratio',
needed_keys=('ratio',),
human_readable=_ratio_hr,
machine_readable=_ratio_mr),
Item('Isolated',
needed_keys=('status',),
human_readable=_isolated_hr,
machine_readable=_isolated_mr),
Item('Error',
needed_keys=('error',)),
)},
{'title': 'Limits', 'width': 24, 'items': (
Item('Upload rate',
needed_keys=('limit-rate-up',),
human_readable=partial(_limit_rate_hr, 'up'),
machine_readable=partial(_limit_rate_mr, 'up')),
machine_readable=_size_mr),
Item('Files',
needed_keys=('files',),
human_readable=_files_hr,
machine_readable=_files_mr),
Item('Pieces',
needed_keys=('count-pieces', 'size-piece'),
human_readable=_pieces_hr,
machine_readable=_pieces_mr),
Item('Private',
needed_keys=('private',),
human_readable=_private_hr,
machine_readable=_private_mr),
Item('Comment',
needed_keys=('comment',)),
Item('Creator',
needed_keys=('creator',)),
)},
{'title': 'Status', 'width': 51, 'items': (
Item('State',
needed_keys=('status',),
human_readable=_status_hr,
machine_readable=_status_mr),
Item('Location',
needed_keys=('path',),),
Item('Available',
needed_keys=('%available', 'size-available'),
human_readable=_available_hr,
machine_readable=_available_mr),
Item('Downloaded',
needed_keys=('size-downloaded', 'size-left', '%downloaded', 'timespan-eta'),
Item('Uploading',
needed_keys=('peers-uploading',)),
Item('Downloading',
needed_keys=('peers-downloading',)),
)},
{'title': 'Dates and Times', 'width': 44, 'items': (
Item('Created',
needed_keys=('time-created',),
human_readable=partial(_date_hr, 'time-created'),
machine_readable=partial(_date_mr, 'time-created')),
Item('Added',
needed_keys=('time-added',),
human_readable=partial(_date_hr, 'time-added'),
machine_readable=partial(_date_mr, 'time-added')),
Item('Started',
needed_keys=('time-started',),
human_readable=partial(_date_hr, 'time-started'),
machine_readable=partial(_date_mr, 'time-started')),
Item('Completed',
needed_keys=('time-completed',),
human_readable=partial(_date_hr, 'time-completed'),
machine_readable=partial(_date_mr, 'time-completed')),
Item('Active',
needed_keys=('time-activity',),
human_readable=partial(_date_hr, 'time-activity'),
machine_readable=partial(_date_mr, 'time-activity')),
# Disabled because Transmission returns incorrect time span
# Item('Seeding',
# needed_keys=('timespan-seeding',),
# human_readable=partial(_timespan_hr, 'timespan-seeding'),
self.machine_readable = machine_readable
SECTIONS = (
{'title': 'Torrent', 'width': 60, 'items': (
Item('Name',
needed_keys=('name',)),
Item('ID',
needed_keys=('id',)),
Item('Hash',
needed_keys=('hash',)),
Item('Size',
needed_keys=('size-total', 'size-final'),
human_readable=_size_hr,
machine_readable=_size_mr),
Item('Files',
needed_keys=('files',),
human_readable=_files_hr,
machine_readable=_files_mr),
Item('Pieces',
needed_keys=('count-pieces', 'size-piece'),
human_readable=_pieces_hr,
machine_readable=_pieces_mr),
Item('Private',
needed_keys=('private',),
human_readable=_private_hr,
machine_readable=_private_mr),
Item('Comment',
needed_keys=('comment',)),
Item('Creator',
needed_keys=('creator',)),
)},
self.needed_keys = needed_keys
if human_readable is None:
self.human_readable = lambda torrent, key=needed_keys[0]: str(torrent[key])
else:
self.human_readable = human_readable
if machine_readable is None:
self.machine_readable = self.human_readable
else:
self.machine_readable = machine_readable
SECTIONS = (
{'title': 'Torrent', 'width': 60, 'items': (
Item('Name',
needed_keys=('name',)),
Item('ID',
needed_keys=('id',)),
Item('Hash',
needed_keys=('hash',)),
Item('Size',
needed_keys=('size-total', 'size-final'),
human_readable=_size_hr,
machine_readable=_size_mr),
Item('Files',
needed_keys=('files',),
human_readable=_files_hr,
machine_readable=_files_mr),
Item('Pieces',
needed_keys=('count-pieces', 'size-piece'),
human_readable=_pieces_hr,
machine_readable=_pieces_mr),
Item('Private',
Item('Pieces',
needed_keys=('count-pieces', 'size-piece'),
human_readable=_pieces_hr,
machine_readable=_pieces_mr),
Item('Private',
needed_keys=('private',),
human_readable=_private_hr,
machine_readable=_private_mr),
Item('Comment',
needed_keys=('comment',)),
Item('Creator',
needed_keys=('creator',)),
)},
{'title': 'Status', 'width': 51, 'items': (
Item('State',
needed_keys=('status',),
human_readable=_status_hr,
machine_readable=_status_mr),
Item('Location',
needed_keys=('path',),),
Item('Available',
needed_keys=('%available', 'size-available'),
human_readable=_available_hr,
machine_readable=_available_mr),
Item('Downloaded',
needed_keys=('size-downloaded', 'size-left', '%downloaded', 'timespan-eta'),
human_readable=_downloaded_hr,
machine_readable=_downloaded_mr),
Item('Uploaded',
needed_keys=('size-uploaded', 'size-total', '%uploaded'),
human_readable=_uploaded_hr,
human_readable=_private_hr,
machine_readable=_private_mr),
Item('Comment',
needed_keys=('comment',)),
Item('Creator',
needed_keys=('creator',)),
)},
{'title': 'Status', 'width': 51, 'items': (
Item('State',
needed_keys=('status',),
human_readable=_status_hr,
machine_readable=_status_mr),
Item('Location',
needed_keys=('path',),),
Item('Available',
needed_keys=('%available', 'size-available'),
human_readable=_available_hr,
machine_readable=_available_mr),
Item('Downloaded',
needed_keys=('size-downloaded', 'size-left', '%downloaded', 'timespan-eta'),
human_readable=_downloaded_hr,
machine_readable=_downloaded_mr),
Item('Uploaded',
needed_keys=('size-uploaded', 'size-total', '%uploaded'),
human_readable=_uploaded_hr,
machine_readable=_uploaded_mr),
Item('Ratio',
needed_keys=('ratio',),
human_readable=_ratio_hr,
machine_readable=_ratio_mr),
Item('Isolated',
)},
{'title': 'Dates and Times', 'width': 44, 'items': (
Item('Created',
needed_keys=('time-created',),
human_readable=partial(_date_hr, 'time-created'),
machine_readable=partial(_date_mr, 'time-created')),
Item('Added',
needed_keys=('time-added',),
human_readable=partial(_date_hr, 'time-added'),
machine_readable=partial(_date_mr, 'time-added')),
Item('Started',
needed_keys=('time-started',),
human_readable=partial(_date_hr, 'time-started'),
machine_readable=partial(_date_mr, 'time-started')),
Item('Completed',
needed_keys=('time-completed',),
human_readable=partial(_date_hr, 'time-completed'),
machine_readable=partial(_date_mr, 'time-completed')),
Item('Active',
needed_keys=('time-activity',),
human_readable=partial(_date_hr, 'time-activity'),
machine_readable=partial(_date_mr, 'time-activity')),
# Disabled because Transmission returns incorrect time span
# Item('Seeding',
# needed_keys=('timespan-seeding',),
# human_readable=partial(_timespan_hr, 'timespan-seeding'),
# machine_readable=partial(_timespan_mr, 'timespan-seeding')),
Item('Downloading',
needed_keys=('timespan-downloading',),
human_readable=partial(_timespan_hr, 'timespan-downloading'),