from __future__ import unicode_literals
from django.core.management.base import NoArgsCommand

from guardian.utils import clean_orphan_obj_perms


class Command(NoArgsCommand):
    """
    clean_orphan_obj_perms command is a tiny wrapper around
    :func:`guardian.utils.clean_orphan_obj_perms`.

    Usage::

        $ python manage.py clean_orphan_obj_perms
        Removed 11 object permission entries with no targets

    """
    help = "Removes object permissions with not existing targets"

    def handle_noargs(self, **options):
        removed = clean_orphan_obj_perms()
        if options['verbosity'] > 0:
            print("Removed %d object permission entries with no targets" %
                  removed)

from __future__ import unicode_literals
from django.core.management.base import BaseCommand

from guardian.utils import clean_orphan_obj_perms


class Command(BaseCommand):
    """
    clean_orphan_obj_perms command is a tiny wrapper around
    :func:`guardian.utils.clean_orphan_obj_perms`.

    Usage::

        $ python manage.py clean_orphan_obj_perms
        Removed 11 object permission entries with no targets

    """
    help = "Removes object permissions with not existing targets"

    def handle(self, **options):
        removed = clean_orphan_obj_perms()
        if options['verbosity'] > 0:
            print("Removed %d object permission entries with no targets" %
                  removed)

Drop django.core.management.base.NoArgsCommand (django 1.10 compat)
Drop django.core.management.base.NoArgsCommand (django 1.10 compat)

See https://github.com/django/django/blob/stable/1.9.x/django/core/management/base.py#L574-L578

  from __future__ import unicode_literals
- from django.core.management.base import NoArgsCommand
+ from django.core.management.base import BaseCommand
  
  from guardian.utils import clean_orphan_obj_perms
  
  
- class Command(NoArgsCommand):
+ class Command(BaseCommand):
      """
      clean_orphan_obj_perms command is a tiny wrapper around
      :func:`guardian.utils.clean_orphan_obj_perms`.
  
      Usage::
  
          $ python manage.py clean_orphan_obj_perms
          Removed 11 object permission entries with no targets
  
      """
      help = "Removes object permissions with not existing targets"
  
-     def handle_noargs(self, **options):
+     def handle(self, **options):
          removed = clean_orphan_obj_perms()
          if options['verbosity'] > 0:
              print("Removed %d object permission entries with no targets" %
                    removed)
  
Drop django.core.management.base.NoArgsCommand (django 1.10 compat)
## Code Before:
from __future__ import unicode_literals
from django.core.management.base import NoArgsCommand

from guardian.utils import clean_orphan_obj_perms


class Command(NoArgsCommand):
    """
    clean_orphan_obj_perms command is a tiny wrapper around
    :func:`guardian.utils.clean_orphan_obj_perms`.

    Usage::

        $ python manage.py clean_orphan_obj_perms
        Removed 11 object permission entries with no targets

    """
    help = "Removes object permissions with not existing targets"

    def handle_noargs(self, **options):
        removed = clean_orphan_obj_perms()
        if options['verbosity'] > 0:
            print("Removed %d object permission entries with no targets" %
                  removed)

## Instruction:
Drop django.core.management.base.NoArgsCommand (django 1.10 compat)
## Code After:
from __future__ import unicode_literals
from django.core.management.base import BaseCommand

from guardian.utils import clean_orphan_obj_perms


class Command(BaseCommand):
    """
    clean_orphan_obj_perms command is a tiny wrapper around
    :func:`guardian.utils.clean_orphan_obj_perms`.

    Usage::

        $ python manage.py clean_orphan_obj_perms
        Removed 11 object permission entries with no targets

    """
    help = "Removes object permissions with not existing targets"

    def handle(self, **options):
        removed = clean_orphan_obj_perms()
        if options['verbosity'] > 0:
            print("Removed %d object permission entries with no targets" %
                  removed)
