code: def init(plugindirs=[]):
      
  
      # initialize the builtin plugins
      from .translators import yang,yin,dsdl
      yang.pyang_plugin_init()
      yin.pyang_plugin_init()
      dsdl.pyang_plugin_init()
  
      # initialize installed plugins
      for ep in pkg_resources.iter_entry_points(group='pyang.plugin'):
          plugin_init = ep.load()
          plugin_init()
  
      # search for plugins in std directories (plugins directory first)
      basedir = os.path.split(sys.modules['pyang'].__file__)[0]
      plugindirs.insert(0, basedir + "/transforms")
      plugindirs.insert(0, basedir + "/plugins")
  
      # add paths from env
      pluginpath = os.getenv('PYANG_PLUGINPATH')
      if pluginpath is not None:
          plugindirs.extend(pluginpath.split(os.pathsep))
  
      syspath = sys.path
      for plugindir in plugindirs:
          sys.path = [plugindir] + syspath
          try:
              fnames = os.listdir(plugindir)
          except OSError:
              continue
          modnames = []
          for fname in fnames:
              if (fname.startswith(".#") or
                  fname.startswith("__init__.py") or
                  fname.endswith("_flymake.py") or
                  fname.endswith("_flymake.pyc")):
                  pass
              elif fname.endswith(".py"):
                  modname = fname[:-3]
                  if modname not in modnames:
                      modnames.append(modname)
              elif fname.endswith(".pyc"):
                  modname = fname[:-4]
                  if modname not in modnames:
                      modnames.append(modname)
          for modname in modnames:
              pluginmod = __import__(modname)
              try:
                  pluginmod.pyang_plugin_init()
              except AttributeError as s:
                  print(pluginmod.__dict__)
                  raise AttributeError(pluginmod.__file__ + ': ' + str(s))
          sys.path = syspath
docs: Initialize the plugin framework