def _notify(self, task, message): """ Shows system notification message according to system requirements. `message` Status message. """ if self.notify_func: message = common.to_utf8(message.strip()) title = common.to_utf8(u"Focus ({0})".format(task.name)) self.notify_func(title, message)
def _notify(self, task, message): """ Shows system notification message according to system requirements. `message` Status message. """ if self.notify_func: message = common.to_utf8(message.strip()) title = common.to_utf8(u'Focus ({0})'.format(task.name)) self.notify_func(title, message)
def testUnicode__to_utf8(self): """ common.to_utf8: properly encodes ``unicode`` string to ``str`` type. """ # strings of urdu chars u = (u'\u06be\u06d2\u062a\u06a9\u0644\u06cc\u0641\u0646' u'\u06c1\u06cc\u06ba\u06c1\u0648\u062a\u06cc') s = ('\xda\xbe\xdb\x92\xd8\xaa\xda\xa9\xd9\x84\xdb' '\x8c\xd9\x81\xd9\x86\xdb\x81\xdb\x8c\xda\xba' '\xdb\x81\xd9\x88\xd8\xaa\xdb\x8c') self.assertIsInstance(common.to_utf8(u), str) self.assertEqual(common.to_utf8(u), s)
def serialize_values(values): """ Serializes list of values into the following format:: "value","value2","value3" """ return ','.join('"{0}"'.format(v) for v in ( common.to_utf8(v).replace('\\', '\\\\').replace('"', '\\"') for v in values))
def serialize_values(values): """ Serializes list of values into the following format:: "value","value2","value3" """ return ','.join('"{0}"'.format(v) for v in (common.to_utf8(v).replace('\\', '\\\\') .replace('"', '\\"') for v in values))
def _save_active_file(self): """ Saves current task information to active file. Example format:: active_task { name "task name"; start_time "2012-04-23 15:18:22"; } """ _parser = parser.SettingParser() # add name _parser.add_option(None, 'name', common.to_utf8(self._name)) # add start time start_time = self._start_time.strftime('%Y-%m-%d %H:%M:%S.%f') _parser.add_option(None, 'start_time', start_time) # write it to file return _parser.write(self._paths['active_file'], self.HEADER_ACTIVE_FILE)
def __str__(self): name = common.to_utf8(self.name) duration = '<1' if self.duration < 1 else '{0}'.format(self.duration) return 'Task (name={0}, duration={1}m)'.format(name, duration)
def __str__(self): return common.to_utf8(self.description)
def testStr__to_utf8(self): """ common.to_utf8: returns same value if already str: """ self.assertIsInstance(common.to_utf8('hey'), str) self.assertEqual(common.to_utf8('hey'), 'hey')