Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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
Exemplo n.º 4
0
 def test_match__ruler_no_partial_match(self):
     self.assertTrue(tags.match("sully ba", TRANSACTION))
Exemplo n.º 5
0
 def test_match__basic_ruler_insensitive_case(self):
     self.assertTrue(tags.match("sully bar", TRANSACTION))
Exemplo n.º 6
0
 def test_match__ruler_no_partial_match(self):
     self.assertTrue(tags.match('sully ba', TRANSACTION))
Exemplo n.º 7
0
 def test_match__basic_ruler_insensitive_case(self):
     self.assertTrue(tags.match('sully bar', TRANSACTION))