def handle(self, *args, **options):
        for permission in StoredPermission.objects.all():
            try:
                Permission.get(
                    {'pk': '%s.%s' % (permission.namespace, permission.name)},
                    proxy_only=True
                )
            except __HOLE__:
                permission.delete()
dataset/ETHPy150Open mayan-edms/mayan-edms/mayan/apps/permissions/management/commands/purgepermissions.py/Command.handle