How to use the stig.views.ColumnBase function in stig

To help you get started, we’ve selected a few stig examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rndusr / stig / stig / views / torrent.py View on Github external
header = {'left': 'Up', 'right': '?/s'}
    width = 6
    min_width = 6
    needed_keys = ('rate-up',)

    def get_value(self):
        return self._from_cache(_ensure_hide_unit, self.data['rate-up'])

    @classmethod
    def set_unit(cls, unit):
        cls.header['right'] = '%s/s' % unit

COLUMNS['rate-up'] = RateUp


class RateDown(ColumnBase):
    header = {'left': 'Dn', 'right': '?/s'}
    width = 6
    min_width = 6
    needed_keys = ('rate-down',)

    def get_value(self):
        return self._from_cache(_ensure_hide_unit, self.data['rate-down'])

    @classmethod
    def set_unit(cls, unit):
        cls.header['right'] = '%s/s' % unit

COLUMNS['rate-down'] = RateDown


class LimitRateUp(ColumnBase):
github rndusr / stig / stig / views / peer.py View on Github external
class RateDown(ColumnBase):
    header = {'left': 'Dn', 'right': '?/s'}
    width = 6
    min_width = 6

    def get_value(self):
        return self._from_cache(_ensure_hide_unit, self.data['rate-down'])

    @classmethod
    def set_unit(cls, unit):
        cls.header['right'] = '%s/s' % unit

COLUMNS['rate-down'] = RateDown


class ETA(ColumnBase):
    header = {'left': 'ETA'}
    width = 5
    min_width = 3

    def get_value(self):
        return self.data['eta']

COLUMNS['eta'] = ETA


class RateEst(ColumnBase):
    header = {'left': 'Est', 'right': '?/s'}
    width = 7
    min_width = 7

    def get_value(self):
github rndusr / stig / stig / views / torrent.py View on Github external
header = {'left': 'LmtDn', 'right': '?/s'}
    width = 9
    min_width = 9
    needed_keys = ('limit-rate-down',)

    def get_value(self):
        return self._from_cache(_ensure_hide_unit, self.data['limit-rate-down'])

    @classmethod
    def set_unit(cls, unit):
        cls.header['right'] = '%s/s' % unit

COLUMNS['limit-rate-down'] = LimitRateDown


class Eta(ColumnBase):
    header = {'left': 'ETA'}
    width = 5
    min_width = 9
    needed_keys = ('timespan-eta',)

    def get_value(self):
        return self.data['timespan-eta']

COLUMNS['eta'] = Eta


class Tracker(ColumnBase):
    header = {'left': 'Tracker'}
    width = 10
    min_width = 5
    needed_keys = ('trackers',)
github rndusr / stig / stig / views / tracker.py View on Github external
COLUMNS['url-scrape'] = ScrapeURL


class Status(ColumnBase):
    header = {'left': 'Status'}
    align = 'right'
    width = 10
    min_width = 5

    def get_value(self):
        return self.data['status']

COLUMNS['status'] = Status


class Error(ColumnBase):
    header = {'left': 'Error'}
    align = 'left'
    width = None
    min_width = 20

    def get_value(self):
        return self.data['error']

COLUMNS['error'] = Error


class ErrorAnnounce(ColumnBase):
    header = {'left': 'Announce Error'}
    align = 'left'
    width = None
    min_width = 10
github rndusr / stig / stig / views / torrent.py View on Github external
COLUMNS['limit-rate-down'] = LimitRateDown


class Eta(ColumnBase):
    header = {'left': 'ETA'}
    width = 5
    min_width = 9
    needed_keys = ('timespan-eta',)

    def get_value(self):
        return self.data['timespan-eta']

COLUMNS['eta'] = Eta


class Tracker(ColumnBase):
    header = {'left': 'Tracker'}
    width = 10
    min_width = 5
    needed_keys = ('trackers',)
    align = 'left'

    def get_value(self):
        if len(self.data['trackers']) > 0:
            return self.data['trackers'][0]['url-announce'].domain
        else:
            return ''

COLUMNS['tracker'] = Tracker


class _TimeBase(ColumnBase):
github rndusr / stig / stig / views / torrent.py View on Github external
COLUMNS['peers'] = Peers


class Seeds(ColumnBase):
    header = {'left': 'Seeds'}
    width = 5
    min_width = 5
    needed_keys = ('peers-seeding',)

    def get_value(self):
        return self.data['peers-seeding']

COLUMNS['seeds'] = Seeds


class Ratio(ColumnBase):
    header = {'left': 'Ratio'}
    width = 5
    min_width = 5
    needed_keys = ('ratio',)

    def get_value(self):
        return self.data['ratio']

COLUMNS['ratio'] = Ratio


class RateUp(ColumnBase):
    header = {'left': 'Up', 'right': '?/s'}
    width = 6
    min_width = 6
    needed_keys = ('rate-up',)
github rndusr / stig / stig / views / tracker.py View on Github external
'an'    : 'url-announce',
            'sc'    : 'url-scrape',
            'st'    : 'status',
            'err'   : 'err',
            'erran' : 'error-announce',
            'errsc' : 'error-scrape',
            'dns'   : 'downloads',
            'lcs'   : 'leeches',
            'sds'   : 'seeds',
            'lan'   : 'last-announce',
            'nan'   : 'next-announce',
            'lsc'   : 'last-scrape',
            'nsc'   : 'next-scrape' }


class Torrent(ColumnBase):
    header = {'left': 'Torrent'}
    align = 'left'
    width = None
    min_width = 7
    may_have_wide_chars = True

    def get_value(self):
        return self.data['tname']

COLUMNS['torrent'] = Torrent


class Tier(ColumnBase):
    header = {'left': 'Tier'}
    align = 'right'
    width = 4
github rndusr / stig / stig / views / peer.py View on Github external
from ..logging import make_logger
log = make_logger(__name__)

from . import (ColumnBase, _ensure_hide_unit)


COLUMNS = {}
ALIASES = { 'cl'   : 'client',
            'cn'   : 'country',
            '%dn'  : '%downloaded',
            'rup'  : 'rate-up',
            'rdn'  : 'rate-down',
            're'   : 'rate-est' }


class Torrent(ColumnBase):
    header = {'left': 'Torrent'}
    align = 'left'
    width = None
    min_width = 7
    may_have_wide_chars = True

    def get_value(self):
        return self.data['tname']

COLUMNS['torrent'] = Torrent


class Client(ColumnBase):
    header = {'left': 'Client'}
    align = 'left'
    width = None
github rndusr / stig / stig / views / file.py View on Github external
header = {'left': 'Priority'}
    width = 4
    min_width = 4
    align = 'left'

    def get_value(self):
        val = self.get_raw_value()
        return '' if val == 'normal' else val

    def get_raw_value(self):
        return 'off' if self.data['is-wanted'] is False else self.data['priority']

COLUMNS['priority'] = Priority


class Marked(ColumnBase):
    interfaces = ('tui',)

COLUMNS['marked'] = Marked


import os
class TorrentFileDirectory(dict):
    """
    A mapping with the same keys as a TorrentFile instance but represents a directory

    Values recursively summarize the values of all the TorrentFiles in the subtree.
    """
    nodetype = 'parent'

    def __init__(self, name, tree, filtered_count=0):
        tfiles = tuple(tree.files)
github rndusr / stig / stig / views / peer.py View on Github external
COLUMNS['torrent'] = Torrent


class Client(ColumnBase):
    header = {'left': 'Client'}
    align = 'left'
    width = None
    min_width = 6

    def get_value(self):
        return self.data['client']

COLUMNS['client'] = Client


class Country(ColumnBase):
    header = {'left': 'Country'}
    align = 'right'
    width = 7
    min_width = 7

    def get_value(self):
        return self.data['country']

COLUMNS['country'] = Country


class Host(ColumnBase):
    header = {'left': 'Host'}
    align = 'right'
    width = None
    min_width = 4