"""
Tasks for cleaning compiled resources.

:copyright: Copyright 2013-2016, Dorian Pula <dorian.pula@amber-penguin-software.ca>
:license: AGPL v3+
"""

import fnmatch
import os

import invoke as inv

from . import docs, test


@inv.task
def python(ctx):
    """Cleans out all compiled Python bytecode and object files."""
    for root, dirs, files in os.walk(os.curdir):
        for _file in files:
            if fnmatch.fnmatch(_file, '*.pyc'):
                os.remove(os.path.join(root, _file))


@inv.task(docs.clean, test.clean, python, name='all')
def clean_all(ctx):
    """Cleans up all generated files."""
    print('All clean!')
