Esempio n. 1
0
 def _LoadHelpMaps(self):
   """Returns tuple (help type -> [HelpProviders],
                     help name->HelpProvider dict,
                    )."""
   # Walk gslib/commands and gslib/addlhelp to find all HelpProviders.
   for f in os.listdir(os.path.join(gslib.GSLIB_DIR, 'commands')):
     # Handles no-extension files, etc.
     (module_name, ext) = os.path.splitext(f)
     if ext == '.py':
       __import__('gslib.commands.%s' % module_name)
   for f in os.listdir(os.path.join(gslib.GSLIB_DIR, 'addlhelp')):
     (module_name, ext) = os.path.splitext(f)
     if ext == '.py':
       __import__('gslib.addlhelp.%s' % module_name)
   help_type_map = {}
   help_name_map = {}
   for s in gslib.help_provider.ALL_HELP_TYPES:
     help_type_map[s] = []
   # Only include HelpProvider subclasses in the dict.
   for help_prov in itertools.chain(
       HelpProvider.__subclasses__(), Command.__subclasses__()):
     if help_prov is Command:
       # Skip the Command base class itself; we just want its subclasses,
       # where the help command text lives (in addition to non-Command
       # HelpProviders, like naming.py).
       continue
     gslib.help_provider.SanityCheck(help_prov, help_name_map)
     help_name_map[help_prov.help_spec[HELP_NAME]] = help_prov
     for help_name_aliases in help_prov.help_spec[HELP_NAME_ALIASES]:
       help_name_map[help_name_aliases] = help_prov
     help_type_map[help_prov.help_spec[HELP_TYPE]].append(help_prov)
   return (help_type_map, help_name_map)
Esempio n. 2
0
 def _LoadHelpMaps(self):
     """Returns tuple (help type -> [HelpProviders],
                   help name->HelpProvider dict,
                  )."""
     # Walk gslib/commands and gslib/addlhelp to find all HelpProviders.
     for f in os.listdir(
             os.path.join(self.gsutil_bin_dir, 'gslib', 'commands')):
         # Handles no-extension files, etc.
         (module_name, ext) = os.path.splitext(f)
         if ext == '.py':
             __import__('gslib.commands.%s' % module_name)
     for f in os.listdir(
             os.path.join(self.gsutil_bin_dir, 'gslib', 'addlhelp')):
         (module_name, ext) = os.path.splitext(f)
         if ext == '.py':
             __import__('gslib.addlhelp.%s' % module_name)
     help_type_map = {}
     help_name_map = {}
     for s in gslib.help_provider.ALL_HELP_TYPES:
         help_type_map[s] = []
     # Only include HelpProvider subclasses in the dict.
     for help_prov in itertools.chain(HelpProvider.__subclasses__(),
                                      Command.__subclasses__()):
         if help_prov is Command:
             # Skip the Command base class itself; we just want its subclasses,
             # where the help command text lives (in addition to non-Command
             # HelpProviders, like naming.py).
             continue
         gslib.help_provider.SanityCheck(help_prov, help_name_map)
         help_name_map[help_prov.help_spec[HELP_NAME]] = help_prov
         for help_name_aliases in help_prov.help_spec[HELP_NAME_ALIASES]:
             help_name_map[help_name_aliases] = help_prov
         help_type_map[help_prov.help_spec[HELP_TYPE]].append(help_prov)
     return (help_type_map, help_name_map)
Esempio n. 3
0
  def _LoadHelpMaps(self):
    """Returns tuple (help type -> [HelpProviders],
                      help name->HelpProvider dict,
                     )."""

    # Import all gslib.commands submodules.
    for _, module_name, _ in pkgutil.iter_modules(gslib.commands.__path__):
      __import__('gslib.commands.%s' % module_name)
    # Import all gslib.addlhelp submodules.
    for _, module_name, _ in pkgutil.iter_modules(gslib.addlhelp.__path__):
      __import__('gslib.addlhelp.%s' % module_name)

    help_type_map = {}
    help_name_map = {}
    for s in gslib.help_provider.ALL_HELP_TYPES:
      help_type_map[s] = []
    # Only include HelpProvider subclasses in the dict.
    for help_prov in itertools.chain(
        HelpProvider.__subclasses__(), Command.__subclasses__()):
      if help_prov is Command:
        # Skip the Command base class itself; we just want its subclasses,
        # where the help command text lives (in addition to non-Command
        # HelpProviders, like naming.py).
        continue
      gslib.help_provider.SanityCheck(help_prov, help_name_map)
      help_name_map[help_prov.help_spec[HELP_NAME]] = help_prov
      for help_name_aliases in help_prov.help_spec[HELP_NAME_ALIASES]:
        help_name_map[help_name_aliases] = help_prov
      help_type_map[help_prov.help_spec[HELP_TYPE]].append(help_prov)
    return (help_type_map, help_name_map)
Esempio n. 4
0
  def _LoadHelpMaps(self):
    """Returns tuple of help type and help name.

    help type is a dict with key: help type
                             value: list of HelpProviders
    help name is a dict with key: help command name or alias
                             value: HelpProvider

    Returns:
      (help type, help name)
    """

    # Import all gslib.commands submodules.
    for _, module_name, _ in pkgutil.iter_modules(gslib.commands.__path__):
      __import__('gslib.commands.%s' % module_name)
    # Import all gslib.addlhelp submodules.
    for _, module_name, _ in pkgutil.iter_modules(gslib.addlhelp.__path__):
      __import__('gslib.addlhelp.%s' % module_name)

    help_type_map = {}
    help_name_map = {}
    for s in gslib.help_provider.ALL_HELP_TYPES:
      help_type_map[s] = []
    # Only include HelpProvider subclasses in the dict.
    for help_prov in itertools.chain(HelpProvider.__subclasses__(),
                                     Command.__subclasses__()):
      if help_prov is Command:
        # Skip the Command base class itself; we just want its subclasses,
        # where the help command text lives (in addition to non-Command
        # HelpProviders, like naming.py).
        continue
      gslib.help_provider.SanityCheck(help_prov, help_name_map)
      help_name_map[help_prov.help_spec.help_name] = help_prov
      for help_name_aliases in help_prov.help_spec.help_name_aliases:
        help_name_map[help_name_aliases] = help_prov
      help_type_map[help_prov.help_spec.help_type].append(help_prov)
    return (help_type_map, help_name_map)
Esempio n. 5
0
  def _LoadHelpMaps(self):
    """Returns tuple of help type and help name.

    help type is a dict with key: help type
                             value: list of HelpProviders
    help name is a dict with key: help command name or alias
                             value: HelpProvider

    Returns:
      (help type, help name)
    """

    # Import all gslib.commands submodules.
    for _, module_name, _ in pkgutil.iter_modules(gslib.commands.__path__):
      __import__('gslib.commands.%s' % module_name)
    # Import all gslib.addlhelp submodules.
    for _, module_name, _ in pkgutil.iter_modules(gslib.addlhelp.__path__):
      __import__('gslib.addlhelp.%s' % module_name)

    help_type_map = {}
    help_name_map = {}
    for s in gslib.help_provider.ALL_HELP_TYPES:
      help_type_map[s] = []
    # Only include HelpProvider subclasses in the dict.
    for help_prov in itertools.chain(
        HelpProvider.__subclasses__(), Command.__subclasses__()):
      if help_prov is Command:
        # Skip the Command base class itself; we just want its subclasses,
        # where the help command text lives (in addition to non-Command
        # HelpProviders, like naming.py).
        continue
      gslib.help_provider.SanityCheck(help_prov, help_name_map)
      help_name_map[help_prov.help_spec.help_name] = help_prov
      for help_name_aliases in help_prov.help_spec.help_name_aliases:
        help_name_map[help_name_aliases] = help_prov
      help_type_map[help_prov.help_spec.help_type].append(help_prov)
    return (help_type_map, help_name_map)