parameters: (self)
return_statement: return packages
docstring: Returns a master list of every available package from all sources
  
          :return:
              A dict in the format:
              {
                  'Package Name': {
                      # Package details - see example-packages.json for format
                  },
                  ...
              }
docstring_summary: Returns a master list of every available package from all sources
docstring_tokens: Returns a master list of every available package from all sources
function: def list_available_packages(self):
          """
          Returns a master list of every available package from all sources
  
          :return:
              A dict in the format:
              {
                  'Package Name': {
                      # Package details - see example-packages.json for format
                  },
                  ...
              }
          """
  
          if self.settings.get('debug'):
              console_write(u"Fetching list of available packages", True)
              console_write(u"  Platform: %s-%s" % (sublime.platform(),sublime.arch()))
              console_write(u"  Sublime Text Version: %s" % sublime.version())
              console_write(u"  Package Control Version: %s" % __version__)
  
          cache_ttl = self.settings.get('cache_length')
          repositories = self.list_repositories()
          packages = {}
          bg_downloaders = {}
          active = []
          repos_to_download = []
          name_map = self.settings.get('package_name_map', {})
  
          # Repositories are run in reverse order so that the ones first
          # on the list will overwrite those last on the list
          for repo in repositories[::-1]:
              cache_key = repo + '.packages'
              repository_packages = get_cache(cache_key)
  
              if repository_packages != None:
                  packages.update(repository_packages)
  
              else:
                  domain = urlparse(repo).hostname
                  if domain not in bg_downloaders:
                      bg_downloaders[domain] = BackgroundDownloader(
                          self.settings, REPOSITORY_PROVIDERS)
                  bg_downloaders[domain].add_url(repo)
                  repos_to_download.append(repo)
  
          for bg_downloader in list(bg_downloaders.values()):
              bg_downloader.start()
              active.append(bg_downloader)
  
          # Wait for all of the downloaders to finish
          while active:
              bg_downloader = active.pop()
              bg_downloader.join()
  
          # Grabs the results and stuff it all in the cache
          for repo in repos_to_download:
              domain = urlparse(repo).hostname
              bg_downloader = bg_downloaders[domain]
              provider = bg_downloader.get_provider(repo)
  
              # Allow name mapping of packages for schema version < 2.0
              repository_packages = {}
              for name, info in provider.get_packages():
                  name = name_map.get(name, name)
                  info['name'] = name
                  repository_packages[name] = info
  
              # Display errors we encountered while fetching package info
              for url, exception in provider.get_failed_sources():
                  console_write(exception, True)
              for name, exception in provider.get_broken_packages():
                  console_write(exception, True)
  
              cache_key = repo + '.packages'
              set_cache(cache_key, repository_packages, cache_ttl)
              packages.update(repository_packages)
  
              renamed_packages = provider.get_renamed_packages()
              set_cache_under_settings(self, 'renamed_packages', repo, renamed_packages, cache_ttl)
  
              unavailable_packages = provider.get_unavailable_packages()
              set_cache_under_settings(self, 'unavailable_packages', repo, unavailable_packages, cache_ttl, list_=True)
  
          return packages
function_tokens: def list_available_packages ( self ) : if self . settings . get ( 'debug' ) : console_write ( u"Fetching list of available packages" , True ) console_write ( u"  Platform: %s-%s" % ( sublime . platform ( ) , sublime . arch ( ) ) ) console_write ( u"  Sublime Text Version: %s" % sublime . version ( ) ) console_write ( u"  Package Control Version: %s" % __version__ ) cache_ttl = self . settings . get ( 'cache_length' ) repositories = self . list_repositories ( ) packages = { } bg_downloaders = { } active = [ ] repos_to_download = [ ] name_map = self . settings . get ( 'package_name_map' , { } ) # Repositories are run in reverse order so that the ones first # on the list will overwrite those last on the list for repo in repositories [ : : - 1 ] : cache_key = repo + '.packages' repository_packages = get_cache ( cache_key ) if repository_packages != None : packages . update ( repository_packages ) else : domain = urlparse ( repo ) . hostname if domain not in bg_downloaders : bg_downloaders [ domain ] = BackgroundDownloader ( self . settings , REPOSITORY_PROVIDERS ) bg_downloaders [ domain ] . add_url ( repo ) repos_to_download . append ( repo ) for bg_downloader in list ( bg_downloaders . values ( ) ) : bg_downloader . start ( ) active . append ( bg_downloader ) # Wait for all of the downloaders to finish while active : bg_downloader = active . pop ( ) bg_downloader . join ( ) # Grabs the results and stuff it all in the cache for repo in repos_to_download : domain = urlparse ( repo ) . hostname bg_downloader = bg_downloaders [ domain ] provider = bg_downloader . get_provider ( repo ) # Allow name mapping of packages for schema version < 2.0 repository_packages = { } for name , info in provider . get_packages ( ) : name = name_map . get ( name , name ) info [ 'name' ] = name repository_packages [ name ] = info # Display errors we encountered while fetching package info for url , exception in provider . get_failed_sources ( ) : console_write ( exception , True ) for name , exception in provider . get_broken_packages ( ) : console_write ( exception , True ) cache_key = repo + '.packages' set_cache ( cache_key , repository_packages , cache_ttl ) packages . update ( repository_packages ) renamed_packages = provider . get_renamed_packages ( ) set_cache_under_settings ( self , 'renamed_packages' , repo , renamed_packages , cache_ttl ) unavailable_packages = provider . get_unavailable_packages ( ) set_cache_under_settings ( self , 'unavailable_packages' , repo , unavailable_packages , cache_ttl , list_ = True ) return packages