@@ -0,0 +1,1779 @@
+from django.core.management.base import BaseCommand, CommandError%0Afrom django.conf import settings%0Aimport os%0Aimport re%0A%0AANNOTATION_RE = re.compile(%22#%5B%5Cs%5D*?(TODO%7CFIXME%7CHACK%7CXXX)%5B%5Cs:%5D?(.+)%22)%0A%0Aclass Command(BaseCommand):%0A    help = 'Show all annotations like TODO, FIXME, HACK or XXX in your py files.'%0A    args = 'tag'%0A    label = 'annotation tag (TODO, FIXME, HACK, XXX)'%0A%0A    def handle(self, *args, **options):%0A        # don't add django internal code%0A        apps = filter(lambda app: not app.startswith('django.contrib'),%0A                        settings.INSTALLED_APPS)%0A        for app_dir in apps:%0A            for top, dirs, files in os.walk(app_dir):%0A                for f in files:%0A                    if os.path.splitext(f)%5B1%5D in %5B'.py'%5D:%0A                        fpath = os.path.join(top, f)%0A                        annotation_lines = %5B%5D%0A                        with open(fpath, 'r') as f:%0A                            i = 0%0A                            for line in f.readlines():%0A                                i += 1%0A                                if ANNOTATION_RE.search(line):%0A                                    tag, msg = ANNOTATION_RE.findall(line)%5B0%5D%0A                                    if len(args) == 1:%0A                                        search_for_tag = args%5B0%5D.upper()%0A                                        if not search_for_tag == tag:%0A                                            break%0A                                    annotation_lines.append(%22%5B%253s%5D %25-5s %25s%22 %25 (i, tag, msg.strip()))%0A                            if annotation_lines:%0A                                print fpath+%22:%22%0A                                for annotation in annotation_lines:%0A                                    print %22  * %22+annotation%0A                                print%0A

add notes command