def test_abbrtask(self): self.assertEqual(abbrtask(None, 3), '???') self.assertEqual( abbrtask('feeds.tasks.refresh', 10), '[.]refresh', ) self.assertEqual( abbrtask('feeds.tasks.refresh', 30), 'feeds.tasks.refresh', )
def format_row(self, uuid, task, worker, timestamp, state): mx = self.display_width # include spacing detail_width = mx - 1 - STATE_WIDTH - 1 - TIMESTAMP_WIDTH uuid_space = detail_width - 1 - MIN_TASK_WIDTH - 1 - MIN_WORKER_WIDTH if uuid_space < UUID_WIDTH: uuid_width = uuid_space else: uuid_width = UUID_WIDTH detail_width = detail_width - uuid_width - 1 task_width = int(ceil(detail_width / 2.0)) worker_width = detail_width - task_width - 1 uuid = abbr(uuid, uuid_width).ljust(uuid_width) worker = abbr(worker, worker_width).ljust(worker_width) task = abbrtask(task, task_width).ljust(task_width) state = abbr(state, STATE_WIDTH).ljust(STATE_WIDTH) timestamp = timestamp.ljust(TIMESTAMP_WIDTH) row = "%s %s %s %s %s " % (uuid, worker, task, timestamp, state) if self.screen_width is None: self.screen_width = len(row[:mx]) return row[:mx]
def format_row(self, uuid, task, worker, timestamp, state): mx = self.display_width # include spacing detail_width = mx - 1 - STATE_WIDTH - 1 - TIMESTAMP_WIDTH uuid_space = detail_width - 1 - MIN_TASK_WIDTH - 1 - MIN_WORKER_WIDTH if uuid_space < UUID_WIDTH: uuid_width = uuid_space else: uuid_width = UUID_WIDTH detail_width = detail_width - uuid_width - 1 task_width = int(ceil(detail_width / 2.0)) worker_width = detail_width - task_width - 1 uuid = abbr(uuid, uuid_width).ljust(uuid_width) worker = abbr(worker, worker_width).ljust(worker_width) task = abbrtask(task, task_width).ljust(task_width) state = abbr(state, STATE_WIDTH).ljust(STATE_WIDTH) timestamp = timestamp.ljust(TIMESTAMP_WIDTH) row = '{0} {1} {2} {3} {4} '.format(uuid, worker, task, timestamp, state) if self.screen_width is None: self.screen_width = len(row[:mx]) return row[:mx]
def name(task): """Return the task name and abbreviates it to maximum of 16 characters.""" short_name = abbrtask(task.name, 16) return '<div title="{0}"><b>{1}</b></div>'.format( escape(task.name), escape(short_name), )
def name(task): """Return the task name and abbreviates it to maximum of 16 characters.""" short_name = abbrtask(task.name, 16) return format_html( '<div title="{0}"><b>{1}</b></div>', task.name, short_name, )
def name(task): short_name = abbrtask(task.name, 16) return '<div title="%s"><b>%s</b></div>' % (escape( task.name), escape(short_name))
def name(task): short_name = abbrtask(task.name, 16) return '<div title="{0}"><b>{1}</b></div>'.format( escape(task.name), escape(short_name), )
def test_abbrtask(s, maxsize, expected): assert abbrtask(s, maxsize) == expected
def name(task): short_name = abbrtask(task.name, 16) return '<div title="%s"><b>%s</b></div>' % (escape(task.name), escape(short_name))
def name(task): short_name = abbrtask(task.name, 16) return format_html( '<div title="{0}"><b>{1}</b></div>', task.name, short_name )
def test_abbrtask(self): self.assertEqual(text.abbrtask(None, 3), "???") self.assertEqual(text.abbrtask("feeds.tasks.refresh", 10), "[.]refresh") self.assertEqual(text.abbrtask("feeds.tasks.refresh", 30), "feeds.tasks.refresh")