Ejemplo n.º 1
0
 def test_update_config(self):
     dest = os.path.join(tempfile.mkdtemp(), os.path.basename(CONFIG_FILE))
     shutil.copy2(CONFIG_FILE, dest)
     # Replace 'Sully' match tag from 'Bars' to 'Drink'
     tags.edit('Bars', 'Sully', 'Drink', 'Sully', {'config': dest})
     tags.load(dest)
     self.assertEqual(tags.find_tag_for('Sully')[0], 'Drink')
Ejemplo n.º 2
0
def process_file(transactions, options):
    """Process file's transactions. Operate in a dedicated edit screen."""
    tag = None
    with TERM.fullscreen():
        try:
            for (i, t) in enumerate(transactions):
                cached_tag, cached_match = tags.find_tag_for(t['payee'])

                tag, match = process_transaction(t, cached_tag
                                                 or t['category'],
                                                 cached_match, options)
                if tag:
                    tags.edit(cached_tag, cached_match, tag, match, options)
                t['category'] = tag
                if not t['payee']:
                    print('Skip transaction: no payee')
                separator = '-' * 3
                print(separator)
            i = i + 1
            if not options.get('batch', False):
                quick_input('Press any key to continue (Ctrl+D to discard '
                            'edits)')
        except KeyboardInterrupt:
            return transactions[:i]
        return transactions[:i]
Ejemplo n.º 3
0
def process_file(transactions, options):
    """Process file's transactions."""
    cat = None
    try:
        i = 0
        for (i, t) in enumerate(transactions):
            cat, match = process_transaction(t, options)
            tags.edit(t, cat, match, options)
        i = i + 1
        if not options.get('batch', False):
            quick_input('Press any key to continue (Ctrl+D to discard '
                        'edits)')
    except KeyboardInterrupt:
        return transactions[:i]
    return transactions[:i]
Ejemplo n.º 4
0
def process_transactions(transactions, options):
    """Process file's transactions."""
    cat = None
    try:
        i = 0
        for (i, t) in enumerate(transactions):
            if not t["payee"]:
                print("Skip transaction #%s with no payee field" % (i + 1))
                continue
            cat, match = process_transaction(t, options)
            tags.edit(t, cat, match, options)
        i = i + 1
        if not options["batch"]:
            quick_input("\nPress any key to continue (Ctrl+D to discard " "edits)")
    except KeyboardInterrupt:
        return transactions[:i]
    return transactions[:i]
Ejemplo n.º 5
0
def process_file(transactions, options):
    """Process file's transactions. Operate in a dedicated edit screen."""
    tag = None
    with TERM.fullscreen():
        try:
            for (i, t) in enumerate(transactions):
                cached_tag, cached_match = tags.find_tag_for(t['payee'])

                tag, match = process_transaction(t,
                    cached_tag or t['category'], cached_match, options)
                if tag:
                    tags.edit(cached_tag, cached_match, tag, match, options)
                t['category'] = tag
                if not t['payee']:
                    print('Skip transaction: no payee')
                separator = '-' * 3
                print(separator)
            i = i + 1
            if not options.get('batch', False):
                quick_input('Press any key to continue (Ctrl+D to discard '
                            'edits)')
        except KeyboardInterrupt:
            return transactions[:i]
        return transactions[:i]
Ejemplo n.º 6
0
 def test_edit__drop_empty_category(self):
     t = TRANSACTION.copy()
     t["payee"] = "FOO Art Brut Shop BAR"
     res = tags.edit(t, "SPAM", "FOO", OPTIONS)
     self.assertEqual(set(res.keys()), set(["Bars", "SPAM"]))
Ejemplo n.º 7
0
 def test_edit(self):
     res = tags.edit(TRANSACTION, "Drinks", "Sully bar", OPTIONS)
     self.assertEqual(set(res.keys()), set(["Bars", "Clothes", "Drinks"]))
     self.assertEqual(res["Bars"], ["Art Brut"])
     res = tags.edit(TRANSACTION, "Drinks", {"payee": "Sully"}, OPTIONS)
     self.assertEqual(res["Drinks"], [{"payee": "Sully"}])
Ejemplo n.º 8
0
 def test_edit__drop_empty_category(self):
     t = TRANSACTION.copy()
     t['payee'] = 'FOO Art Brut Shop BAR'
     res = tags.edit(t, 'SPAM', 'FOO', OPTIONS)
     self.assertEqual(set(res.keys()), set(['Bars', 'SPAM']))
Ejemplo n.º 9
0
 def test_edit(self):
     res = tags.edit(TRANSACTION, 'Drinks', 'Sully bar', OPTIONS)
     self.assertEqual(set(res.keys()), set(['Bars', 'Clothes', 'Drinks']))
     self.assertEqual(res['Bars'], ['Art Brut'])
     res = tags.edit(TRANSACTION, 'Drinks', {'payee': 'Sully'}, OPTIONS)
     self.assertEqual(res['Drinks'], [{'payee': 'Sully'}])
Ejemplo n.º 10
0
 def test_edit__drop_empty_category(self):
     t = TRANSACTION.copy()
     t['payee'] = 'FOO Art Brut Shop BAR'
     res = tags.edit(t, 'SPAM', 'FOO', OPTIONS)
     self.assertEqual(set(res.keys()), set(['Bars', 'SPAM']))
Ejemplo n.º 11
0
 def test_edit(self):
     res = tags.edit(TRANSACTION, 'Drinks', 'Sully bar', OPTIONS)
     self.assertEqual(set(res.keys()), set(['Bars', 'Clothes', 'Drinks']))
     self.assertEqual(res['Bars'], ['Art Brut'])