
import importlib


def import_from_gi(library, version):
    """Import and return a GObject introspection library."""
    try:
        import gi as package
        package_name = 'gi'
    except ImportError:
        import pgi as package
        package_name = 'pgi'

    package.require_version(library, version)

    return importlib.import_module(package_name + '.repository.' + library)


import importlib
from django.utils.functional import lazy


def import_from_gi(library, version):
    """Import and return a GObject introspection library."""
    try:
        import gi as package
        package_name = 'gi'
    except ImportError:
        import pgi as package
        package_name = 'pgi'

    package.require_version(library, version)

    return importlib.import_module(package_name + '.repository.' + library)


def _format_lazy(string, *args, **kwargs):
    """Lazily format a lazy string."""
    string = str(string)
    return string.format(*args, **kwargs)


format_lazy = lazy(_format_lazy, str)

Add utility method to lazy format lazy string
Add utility method to lazy format lazy string

This method is useful to format strings that are lazy (such as those in
Forms).

  
  import importlib
+ from django.utils.functional import lazy
  
  
  def import_from_gi(library, version):
      """Import and return a GObject introspection library."""
      try:
          import gi as package
          package_name = 'gi'
      except ImportError:
          import pgi as package
          package_name = 'pgi'
  
      package.require_version(library, version)
  
      return importlib.import_module(package_name + '.repository.' + library)
  
+ 
+ def _format_lazy(string, *args, **kwargs):
+     """Lazily format a lazy string."""
+     string = str(string)
+     return string.format(*args, **kwargs)
+ 
+ 
+ format_lazy = lazy(_format_lazy, str)
+ 
Add utility method to lazy format lazy string
## Code Before:

import importlib


def import_from_gi(library, version):
    """Import and return a GObject introspection library."""
    try:
        import gi as package
        package_name = 'gi'
    except ImportError:
        import pgi as package
        package_name = 'pgi'

    package.require_version(library, version)

    return importlib.import_module(package_name + '.repository.' + library)

## Instruction:
Add utility method to lazy format lazy string
## Code After:

import importlib
from django.utils.functional import lazy


def import_from_gi(library, version):
    """Import and return a GObject introspection library."""
    try:
        import gi as package
        package_name = 'gi'
    except ImportError:
        import pgi as package
        package_name = 'pgi'

    package.require_version(library, version)

    return importlib.import_module(package_name + '.repository.' + library)


def _format_lazy(string, *args, **kwargs):
    """Lazily format a lazy string."""
    string = str(string)
    return string.format(*args, **kwargs)


format_lazy = lazy(_format_lazy, str)
