def check_ruler(ruler, t): """Build fields status dict obtained by applying ruler to transaction.""" extras = {} match, match_info = tags.match(ruler, t) for (key, val) in match_info.items(): if not val: extras[key] = TERM.red("%s %s" % (TERM.KO, key.title())) else: extras[key] = TERM.green("%s %s" % (TERM.OK, key.title())) if not match: extras["category"] = TERM.red("%s Category" % TERM.KO) else: extras["category"] = TERM.green("%s Category" % TERM.OK) return match, extras
def check_ruler(ruler, t): """Build fields status dict obtained by applying ruler to transaction. """ extras = {} match, match_info = tags.match(ruler, t) if not match: for (key, val) in match_info.iteritems(): if not val: extras[key] = TERM.red('✖ %s' % key.title()) extras['category'] = TERM.red('✖ Category') else: for field in ruler: extras[field] = TERM.green('✔ %s' % field.title()) extras['category'] = TERM.green('✔ Category') return match, extras
def check_ruler(ruler, t): """Build fields status dict obtained by applying ruler to transaction. """ extras = {} match, match_info = tags.match(ruler, t) for (key, val) in match_info.iteritems(): if not val: extras[key] = TERM.red(u'%s %s' % (TERM.KO, key.title())) else: extras[key] = TERM.green(u'%s %s' % (TERM.OK, key.title())) if not match: extras['category'] = TERM.red(u'%s Category' % TERM.KO) else: extras['category'] = TERM.green(u'%s Category' % TERM.OK) return match, extras
def print_field(t, field, matches=None, extras=None): if not extras: extras = {} pad_width = 12 fieldname = extras.get(field, ' ' + field.title()) line = TERM.clear_eol + '%s: %s' % (TERM.ljust( fieldname, pad_width, '.'), colorize_match(t, field.lower(), matches) or TERM.red('<none>')) print(line)
def print_field(t, field, matches=None, extras=None): if not extras: extras = {} pad_width = 12 fieldname = extras.get(field, ' ' + field.title()) line = TERM.clear_eol + '%s: %s' % ( TERM.ljust(fieldname, pad_width, '.'), colorize_match(t, field.lower(), matches) or TERM.red('<none>') ) print(line)
def print_field(t, field, matches=None, extras=None): if not extras: extras = {} pad_width = 12 fieldname = extras.get(field, " " + field.title()) line = TERM.clear_eol + "%s: %s" % ( TERM.ljust(fieldname, pad_width, "."), colorize_match(t, field.lower(), matches) or TERM.red("<none>"), ) print(line)