# Path: scm/models.py
# class PackageChecker(models.Model):
#     module = models.CharField(max_length=200, verbose_name='Python module containing the checker class')
#     name = models.CharField(max_length=200, verbose_name='Python checker class name')
#     description = models.CharField(max_length=200, verbose_name='description')
# 
#     def check_package(self, package_file, logical_component, installation_method):
#         checker_impl = getattr(__import__(self.module, fromlist=[self.name]), self.name)
#         checker_impl.check(checker_impl(), package_file, logical_component, installation_method)
# 
#     def __str__(self):
#         return self.description
# 
# class PackageCheckerBaseImpl(object):
#     description = None
#     def check(self, fileinfo, logical_component, installation_method):
#         raise NotImplemented()


from django.core.management.base import BaseCommand, CommandError
from django.db.transaction import atomic
from scm.models import PackageChecker, PackageCheckerBaseImpl
        from MAGE.settings import INSTALLED_APPS
import importlib

    def __init__(self):
        super(Command, self).__init__()
        self.this_launch = []

    def register(self, checker):
        if not issubclass(checker, PackageCheckerBaseImpl):
            raise Exception('a checker must be a subclass of PackageCheckerBaseImpl (' + checker.__name__ + ')')
        print(u'registering checker named ' + checker.__name__)
        pc = PackageChecker.objects.get_or_create(module=checker.__module__ , name=checker.__name__)
        pc[0].description = checker.description if checker.description else checker.__name__
        pc[0].save()
        self.this_launch.append(pc[0])

    def end_sync(self):
        for pc in PackageChecker.objects.all():
            if not pc in self.this_launch:
                print(u'removing checker named ' + pc.name)
                pc.delete()

    def handle(self, *args, **options):
        if len(args) != 0:
            raise CommandError('this command takes no parameters')

        ## Load all checkers
        for app in [ i for i in INSTALLED_APPS if not i.startswith('django.')]:
            try:
                module = importlib.import_module(app + '.checkers')
                for value in module.__dict__.values():
                    try:

# Path: scm/models.py
# class PackageChecker(models.Model):
#     module = models.CharField(max_length=200, verbose_name='Python module containing the checker class')
#     name = models.CharField(max_length=200, verbose_name='Python checker class name')
#     description = models.CharField(max_length=200, verbose_name='description')
# 
#     def check_package(self, package_file, logical_component, installation_method):
#         checker_impl = getattr(__import__(self.module, fromlist=[self.name]), self.name)
#         checker_impl.check(checker_impl(), package_file, logical_component, installation_method)
# 
#     def __str__(self):
#         return self.description
# 
# class PackageCheckerBaseImpl(object):
#     description = None
#     def check(self, fileinfo, logical_component, installation_method):
#         raise NotImplemented()


# Path: scm/management/commands/synccheckers.py
from django.core.management.base import BaseCommand, CommandError
from django.db.transaction import atomic
from scm.models import PackageChecker, PackageCheckerBaseImpl
        from MAGE.settings import INSTALLED_APPS
import importlib


    def __init__(self):
        super(Command, self).__init__()
        self.this_launch = []

    def register(self, checker):
        if not issubclass(checker, PackageCheckerBaseImpl):
            raise Exception('a checker must be a subclass of PackageCheckerBaseImpl (' + checker.__name__ + ')')
        print(u'registering checker named ' + checker.__name__)
        pc = PackageChecker.objects.get_or_create(module=checker.__module__ , name=checker.__name__)
        pc[0].description = checker.description if checker.description else checker.__name__
        pc[0].save()
        self.this_launch.append(pc[0])

    def end_sync(self):
        for pc in PackageChecker.objects.all():
            if not pc in self.this_launch:
                print(u'removing checker named ' + pc.name)
                pc.delete()

    def handle(self, *args, **options):
        if len(args) != 0:
            raise CommandError('this command takes no parameters')

        ## Load all checkers
        for app in [ i for i in INSTALLED_APPS if not i.startswith('django.')]:
            try:
                module = importlib.import_module(app + '.checkers')
                for value in module.__dict__.values():
                    try:

                        if value.__class__ is type and issubclass(value, PackageCheckerBaseImpl):