from os import listdir
from os.path import basename, dirname, join, splitext
import imp
import sys
def bfs10014():
  global bfs10013
  if (not bfs10013):
    if (sys.version_info[0] == 3):
      sys.meta_path.insert(0, bfs10015())

    bfs10013 = True


bfs10013 = False
def terminate():
  global bfs10013
  if bfs10013:
    bfs10016 = [bfs10017 for bfs10017 in sys.meta_path if isinstance(bfs10017, bfs10015) ]
    for bfs10021 in bfs10016:
      sys.meta_path.remove(bfs10021)

    bfs10013 = False


class bfs10015(object):
  def find_module(self, bfs10020, path=None):
    (bfs10022, bfs10023, bfs10024) = bfs10026(bfs10020, path)
    try:
      is_package = (bfs10024[2] == imp.PKG_DIRECTORY)
      if is_package:
        assert bfs10023
        bfs10023 = join(bfs10023, '__init__.py')

      if bfs10023:
        bfs10025 = (dirname(bfs10023) or '.')
        if ((basename(bfs10023) + '3') in listdir(bfs10025)):
          return Py3Loader(bfs10020, (bfs10023 + '3'), bfs10024)


    finally:
      if bfs10022:
        bfs10022.close()




def bfs10026(name, path=None):
  bfs10027 = list(name.split('.'))
  bfs10030 = bfs10027[(-1)]
  bfs10031 = bfs10027[:(-1)]
  bfs10032 = path
  for (i, bfs10033) in enumerate(bfs10031):
    bfs10035 = '.'.join(bfs10031[:(i + 1)])
    try:
      bfs10034 = sys.modules[bfs10035]
    except KeyError:
      bfs10036 = imp.find_module(bfs10033, bfs10032)
      bfs10034 = imp.load_module(bfs10035, *bfs10036)

    bfs10032 = bfs10034.__path__

  return imp.find_module(bfs10030, bfs10032)

if (sys.version_info < (3, 1)):
  class Py3Loader(object):
    def __init__(self, bfs10040, bfs10037, bfs10041):
      self.bfs10040 = bfs10040
      self.bfs10037 = bfs10037
      self.bfs10041 = bfs10041

    def load_module(self, bfs10040):
      if (bfs10040 != self.bfs10040):
        raise ImportError(('This loader cannot load module %s.' % bfs10040))

      bfs10042 = (self.bfs10041[1] or 'r')
      open_file = open(self.bfs10037, bfs10042)
      return imp.load_module(bfs10040, open_file, self.bfs10037, self.bfs10041)


else:
  try:
    from importlib.abc import SourceLoader
  except ImportError:
    from importlib.abc import PyLoader as SourceLoader

  class Py3Loader(SourceLoader):
    def __init__(self, bfs10040, bfs10037, bfs10041):
      super(Py3Loader, self).__init__()
      self.bfs10040 = bfs10040
      self.bfs10037 = bfs10037
      self.bfs10041 = bfs10041

    def get_data(self, file_path):
      return open(file_path, 'U').read()

    def get_filename(self, bfs10040):
      if (bfs10040 != self.bfs10040):
        raise ImportError(('This loader cannot load module %s.' % bfs10040))

      return self.bfs10037

    def source_path(self, bfs10043):
      try:
        return self.get_filename(bfs10043)
      except ImportError:
        return None


    def is_package(self, bfs10045):
      bfs10044 = basename(self.get_filename(bfs10045))
      return (splitext(bfs10044)[0] == '__init__')

    @classmethod
    def module_repr(bfs10046, bfs10047):
      try:
        bfs10051 = (' from %r' % bfs10047.__file__)
      except AttributeError:
        bfs10051 = ''

      return ('<module %r%s>' % (bfs10047.__name__, bfs10051))



