
class Singleton(object):
    _instance = None

    def __new__(cls, *args, **kwargs):
        if cls._instance is None:
            instance = super(Singleton, cls).__new__(cls, *args, **kwargs)
            instance._singleton_init(*args, **kwargs)
            cls._instance = instance
        elif args or kwargs:
            cls._instance.log.warn('Attempted re-initialize of singleton: %s' % (cls._instance, ))
        return cls._instance

    def __init__(self):
        pass

    def _singleton_init(self):
        """Initialize a singleton instance before it is registered."""
        pass


class Singleton(object):
    _instance = None

    def __new__(cls, *args, **kwargs):
        if cls._instance is None:
            instance = super(Singleton, cls).__new__(cls, *args, **kwargs)
            instance._singleton_init(*args, **kwargs)
            cls._instance = instance
        elif args or kwargs:
            cls._instance.log.warn('Attempted re-initialize of singleton: %s' % (cls._instance, ))
        return cls._instance

    def __init__(self, *args, **kwargs):
        pass

    def _singleton_init(self, *args, **kwargs):
        """Initialize a singleton instance before it is registered."""
        pass

Allow for parameters to __init__()
Allow for parameters to __init__()

Signed-off-by: Steve Loranz <749f95e2748aaf836ea2a030a8b369f33fe35144@redhat.com>

  
  class Singleton(object):
      _instance = None
  
      def __new__(cls, *args, **kwargs):
          if cls._instance is None:
              instance = super(Singleton, cls).__new__(cls, *args, **kwargs)
              instance._singleton_init(*args, **kwargs)
              cls._instance = instance
          elif args or kwargs:
              cls._instance.log.warn('Attempted re-initialize of singleton: %s' % (cls._instance, ))
          return cls._instance
  
-     def __init__(self):
+     def __init__(self, *args, **kwargs):
          pass
  
-     def _singleton_init(self):
+     def _singleton_init(self, *args, **kwargs):
          """Initialize a singleton instance before it is registered."""
          pass
  
Allow for parameters to __init__()
## Code Before:

class Singleton(object):
    _instance = None

    def __new__(cls, *args, **kwargs):
        if cls._instance is None:
            instance = super(Singleton, cls).__new__(cls, *args, **kwargs)
            instance._singleton_init(*args, **kwargs)
            cls._instance = instance
        elif args or kwargs:
            cls._instance.log.warn('Attempted re-initialize of singleton: %s' % (cls._instance, ))
        return cls._instance

    def __init__(self):
        pass

    def _singleton_init(self):
        """Initialize a singleton instance before it is registered."""
        pass

## Instruction:
Allow for parameters to __init__()
## Code After:

class Singleton(object):
    _instance = None

    def __new__(cls, *args, **kwargs):
        if cls._instance is None:
            instance = super(Singleton, cls).__new__(cls, *args, **kwargs)
            instance._singleton_init(*args, **kwargs)
            cls._instance = instance
        elif args or kwargs:
            cls._instance.log.warn('Attempted re-initialize of singleton: %s' % (cls._instance, ))
        return cls._instance

    def __init__(self, *args, **kwargs):
        pass

    def _singleton_init(self, *args, **kwargs):
        """Initialize a singleton instance before it is registered."""
        pass
