<s> import json <EOL> import re <EOL> import os <EOL> from itertools import chain <EOL> try : <EOL> from urllib . parse import urljoin , urlparse <EOL> except ( ImportError ) : <EOL> from urlparse import urljoin , urlparse <EOL> from . . console_write import console_write <EOL> from . provider_exception import ProviderException <EOL> from . schema_compat import platforms_to_releases <EOL> from . . downloaders . downloader_exception import DownloaderException <EOL> from . . clients . client_exception import ClientException <EOL> from . . clients . github_client import GitHubClient <EOL> from . . clients . bitbucket_client import BitBucketClient <EOL> from . . download_manager import downloader , update_url <EOL> from . . versions import version_sort <EOL> class RepositoryProvider ( ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , repo , settings ) : <EOL> self . cache = { } <EOL> self . repo_info = None <EOL> self . schema_version = '<STR_LIT>' <EOL> self . schema_major_version = <NUM_LIT:0> <EOL> self . repo = repo <EOL> self . settings = settings <EOL> self . failed_sources = { } <EOL> self . broken_packages = { } <EOL> self . broken_dependencies = { } <EOL> @ classmethod <EOL> def match_url ( cls , repo ) : <EOL> """<STR_LIT>""" <EOL> return True <EOL> def prefetch ( self ) : <EOL> """<STR_LIT>""" <EOL> [ name for name , info in self . get_packages ( ) ] <EOL> def get_failed_sources ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . failed_sources . items ( ) <EOL> def get_broken_packages ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . broken_packages . items ( ) <EOL> def get_broken_dependencies ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . broken_dependencies . items ( ) <EOL> def fetch ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . repo_info != None : <EOL> return <EOL> self . repo_info = self . fetch_location ( self . repo ) <EOL> for key in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if key not in self . repo_info : <EOL> self . repo_info [ key ] = [ ] <EOL> if '<STR_LIT>' not in self . repo_info : <EOL> return <EOL> if re . match ( '<STR_LIT>' , self . repo , re . I ) is None : <EOL> relative_base = os . path . dirname ( self . repo ) <EOL> is_http = False <EOL> else : <EOL> is_http = True <EOL> includes = self . repo_info . get ( '<STR_LIT>' , [ ] ) <EOL> del self . repo_info [ '<STR_LIT>' ] <EOL> for include in includes : <EOL> if re . match ( '<STR_LIT>' , include ) : <EOL> if is_http : <EOL> include = urljoin ( self . repo , include ) <EOL> else : <EOL> include = os . path . join ( relative_base , include ) <EOL> include = os . path . normpath ( include ) <EOL> include_info = self . fetch_location ( include ) <EOL> included_packages = include_info . get ( '<STR_LIT>' , [ ] ) <EOL> self . repo_info [ '<STR_LIT>' ] . extend ( included_packages ) <EOL> included_dependencies = include_info . get ( '<STR_LIT>' , [ ] ) <EOL> self . repo_info [ '<STR_LIT>' ] . extend ( included_dependencies ) <EOL> def fetch_and_validate ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . repo in self . failed_sources : <EOL> return False <EOL> if self . repo_info is not None : <EOL> return True <EOL> try : <EOL> self . fetch ( ) <EOL> except ( DownloaderException , ProviderException ) as e : <EOL> self . failed_sources [ self . repo ] = e <EOL> self . cache [ '<STR_LIT>' ] = { } <EOL> return False <EOL> def fail ( message ) : <EOL> exception = ProviderException ( message ) <EOL> self . failed_sources [ self . repo ] = exception <EOL> self . cache [ '<STR_LIT>' ] = { } <EOL> return <EOL> schema_error = u'<STR_LIT>' % self . repo <EOL> if '<STR_LIT>' not in self . repo_info : <EOL> error_string = u'<STR_LIT>' % schema_error <EOL> fail ( error_string ) <EOL> return False <EOL> try : <EOL> self . schema_version = self . repo_info . get ( '<STR_LIT>' ) <EOL> if isinstance ( self . schema_version , int ) : <EOL> self . schema_version = float ( self . schema_version ) <EOL> if isinstance ( self . schema_version , float ) : <EOL> self . schema_version = str ( self . schema_version ) <EOL> except ( ValueError ) : <EOL> error_string = u'<STR_LIT>' % schema_error <EOL> fail ( error_string ) <EOL> return False <EOL> if self . schema_version not in [ '<STR_LIT:1.0>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> error_string = u'<STR_LIT>' % schema_error <EOL> fail ( error_string ) <EOL> return False <EOL> version_parts = self . schema_version . split ( '<STR_LIT:.>' ) <EOL> self . schema_major_version = int ( version_parts [ <NUM_LIT:0> ] ) <EOL> if '<STR_LIT>' not in self . repo_info : <EOL> error_string = u'<STR_LIT>' % schema_error <EOL> fail ( error_string ) <EOL> return False <EOL> if isinstance ( self . repo_info [ '<STR_LIT>' ] , dict ) : <EOL> error_string = u'<STR_LIT>' % schema_error <EOL> fail ( error_string ) <EOL> return False <EOL> return True <EOL> def fetch_location ( self , location ) : <EOL> """<STR_LIT>""" <EOL> if re . match ( '<STR_LIT>' , self . repo , re . I ) : <EOL> with downloader ( location , self . settings ) as manager : <EOL> json_string = manager . fetch ( location , '<STR_LIT>' ) <EOL> else : <EOL> if not os . path . exists ( location ) : <EOL> raise ProviderException ( u'<STR_LIT>' % location ) <EOL> if self . settings . get ( '<STR_LIT>' ) : <EOL> console_write ( u'<STR_LIT>' % location , True ) <EOL> with open ( location , '<STR_LIT:rb>' ) as f : <EOL> json_string = f . read ( ) <EOL> try : <EOL> return json . loads ( json_string . decode ( '<STR_LIT:utf-8>' ) ) <EOL> except ( ValueError ) : <EOL> raise ProviderException ( u'<STR_LIT>' % location ) <EOL> def get_dependencies ( self , invalid_sources = None ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT>' in self . cache : <EOL> for key , value in self . cache [ '<STR_LIT>' ] . items ( ) : <EOL> yield ( key , value ) <EOL> return <EOL> if invalid_sources != None and self . repo in invalid_sources : <EOL> raise StopIteration ( ) <EOL> if not self . fetch_and_validate ( ) : <EOL> return <EOL> debug = self . settings . get ( '<STR_LIT>' ) <EOL> github_client = GitHubClient ( self . settings ) <EOL> bitbucket_client = BitBucketClient ( self . settings ) <EOL> if self . schema_major_version < <NUM_LIT:3> : <EOL> self . repo_info [ '<STR_LIT>' ] = [ ] <EOL> output = { } <EOL> for dependency in self . repo_info [ '<STR_LIT>' ] : <EOL> info = { <EOL> '<STR_LIT>' : [ self . repo ] <EOL> } <EOL> for field in [ '<STR_LIT:name>' , '<STR_LIT:description>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if dependency . get ( field ) : <EOL> info [ field ] = dependency . get ( field ) <EOL> if '<STR_LIT:name>' not in info : <EOL> self . failed_sources [ self . repo ] = ProviderException ( u'<STR_LIT>' % self . repo ) <EOL> continue <EOL> releases = dependency . get ( '<STR_LIT>' , [ ] ) <EOL> if releases and not isinstance ( releases , list ) : <EOL> self . broken_dependencies [ info [ '<STR_LIT:name>' ] ] = ProviderException ( u'<STR_LIT>' % ( info [ '<STR_LIT:name>' ] , self . repo ) ) <EOL> continue <EOL> for release in releases : <EOL> if '<STR_LIT>' not in info : <EOL> info [ '<STR_LIT>' ] = [ ] <EOL> download_details = None <EOL> download_info = { } <EOL> for field in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:version>' , '<STR_LIT:url>' , '<STR_LIT>' ] : <EOL> if field in release : <EOL> value = release [ field ] <EOL> if field == '<STR_LIT:url>' : <EOL> value = update_url ( value , debug ) <EOL> if field == '<STR_LIT>' and not isinstance ( release [ '<STR_LIT>' ] , list ) : <EOL> value = [ value ] <EOL> download_info [ field ] = value <EOL> if '<STR_LIT>' not in download_info : <EOL> download_info [ '<STR_LIT>' ] = [ '<STR_LIT:*>' ] <EOL> tags = release . get ( '<STR_LIT>' ) <EOL> branch = release . get ( '<STR_LIT>' ) <EOL> if tags or branch : <EOL> try : <EOL> base = None <EOL> if '<STR_LIT>' in release : <EOL> base = release [ '<STR_LIT>' ] <EOL> elif details : <EOL> base = details <EOL> if not base : <EOL> raise ProviderException ( u'<STR_LIT>' % ( info [ '<STR_LIT:name>' ] , self . repo ) ) <EOL> github_url = False <EOL> bitbucket_url = False <EOL> extra = None <EOL> if tags : <EOL> github_url = github_client . make_tags_url ( base ) <EOL> bitbucket_url = bitbucket_client . make_tags_url ( base ) <EOL> if tags != True : <EOL> extra = tags <EOL> if branch : <EOL> github_url = github_client . make_branch_url ( base , branch ) <EOL> bitbucket_url = bitbucket_client . make_branch_url ( base , branch ) <EOL> if github_url : <EOL> downloads = github_client . download_info ( github_url , extra ) <EOL> url = github_url <EOL> elif bitbucket_url : <EOL> downloads = bitbucket_client . download_info ( bitbucket_url , extra ) <EOL> url = bitbucket_url <EOL> else : <EOL> raise ProviderException ( u'<STR_LIT>' % ( base , info [ '<STR_LIT:name>' ] , self . repo ) ) <EOL> if downloads == False : <EOL> raise ProviderException ( u'<STR_LIT>' % ( url , info [ '<STR_LIT:name>' ] , self . repo ) ) <EOL> for download in downloads : <EOL> del download [ '<STR_LIT:date>' ] <EOL> new_download = download_info . copy ( ) <EOL> new_download . update ( download ) <EOL> info [ '<STR_LIT>' ] . append ( new_download ) <EOL> except ( DownloaderException , ClientException , ProviderException ) as e : <EOL> self . broken_dependencies [ info [ '<STR_LIT:name>' ] ] = e <EOL> continue <EOL> elif download_info : <EOL> if '<STR_LIT:url>' in download_info : <EOL> is_http = urlparse ( download_info [ '<STR_LIT:url>' ] ) . scheme == '<STR_LIT:http>' <EOL> if is_http and '<STR_LIT>' not in download_info : <EOL> self . broken_dependencies [ info [ '<STR_LIT:name>' ] ] = ProviderException ( u'<STR_LIT>' % ( info [ '<STR_LIT:name>' ] , self . repo ) ) <EOL> continue <EOL> info [ '<STR_LIT>' ] . append ( download_info ) <EOL> if info [ '<STR_LIT:name>' ] in self . broken_dependencies : <EOL> continue <EOL> def is_missing_keys ( ) : <EOL> for key in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:description>' , '<STR_LIT>' ] : <EOL> if key not in info : <EOL> self . broken_dependencies [ info [ '<STR_LIT:name>' ] ] = ProviderException ( u'<STR_LIT>' % ( key , info [ '<STR_LIT:name>' ] , self . repo ) ) <EOL> return True <EOL> for release in info . get ( '<STR_LIT>' , [ ] ) : <EOL> for key in [ '<STR_LIT:version>' , '<STR_LIT:url>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if key not in release : <EOL> self . broken_dependencies [ info [ '<STR_LIT:name>' ] ] = ProviderException ( u'<STR_LIT>' % ( key , info [ '<STR_LIT:name>' ] , self . repo ) ) <EOL> return True <EOL> return False <EOL> if is_missing_keys ( ) : <EOL> continue <EOL> info [ '<STR_LIT>' ] = version_sort ( info [ '<STR_LIT>' ] , '<STR_LIT>' , reverse = True ) <EOL> output [ info [ '<STR_LIT:name>' ] ] = info <EOL> yield ( info [ '<STR_LIT:name>' ] , info ) <EOL> self . cache [ '<STR_LIT>' ] = output <EOL> def get_packages ( self , invalid_sources = None ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT>' in self . cache : <EOL> for key , value in self . cache [ '<STR_LIT>' ] . items ( ) : <EOL> yield ( key , value ) <EOL> return <EOL> if invalid_sources != None and self . repo in invalid_sources : <EOL> raise StopIteration ( ) <EOL> if not self . fetch_and_validate ( ) : <EOL> return <EOL> debug = self . settings . get ( '<STR_LIT>' ) <EOL> github_client = GitHubClient ( self . settings ) <EOL> bitbucket_client = BitBucketClient ( self . settings ) <EOL> previous_names = { } <EOL> if self . schema_major_version < <NUM_LIT:2> : <EOL> renamed = self . get_renamed_packages ( ) <EOL> for old_name in renamed : <EOL> new_name = renamed [ old_name ] <EOL> if new_name not in previous_names : <EOL> previous_names [ new_name ] = [ ] <EOL> previous_names [ new_name ] . append ( old_name ) <EOL> output = { } <EOL> for package in self . repo_info [ '<STR_LIT>' ] : <EOL> info = { <EOL> '<STR_LIT>' : [ self . repo ] <EOL> } <EOL> for field in [ '<STR_LIT:name>' , '<STR_LIT:description>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if package . get ( field ) : <EOL> info [ field ] = package . get ( field ) <EOL> if self . schema_major_version >= <NUM_LIT:2> : <EOL> details = package . get ( '<STR_LIT>' ) <EOL> releases = package . get ( '<STR_LIT>' ) <EOL> if details : <EOL> if invalid_sources != None and details in invalid_sources : <EOL> continue <EOL> info [ '<STR_LIT>' ] . append ( details ) <EOL> try : <EOL> github_repo_info = github_client . repo_info ( details ) <EOL> bitbucket_repo_info = bitbucket_client . repo_info ( details ) <EOL> if github_repo_info : <EOL> info = dict ( chain ( github_repo_info . items ( ) , info . items ( ) ) ) <EOL> elif bitbucket_repo_info : <EOL> info = dict ( chain ( bitbucket_repo_info . items ( ) , info . items ( ) ) ) <EOL> else : <EOL> raise ProviderException ( u'<STR_LIT>' % ( details , self . repo ) ) <EOL> except ( DownloaderException , ClientException , ProviderException ) as e : <EOL> if '<STR_LIT:name>' in info : <EOL> self . broken_packages [ info [ '<STR_LIT:name>' ] ] = e <EOL> self . failed_sources [ details ] = e <EOL> continue <EOL> if '<STR_LIT:name>' not in info : <EOL> self . failed_sources [ self . repo ] = ProviderException ( u'<STR_LIT>' % self . repo ) <EOL> continue <EOL> info [ '<STR_LIT>' ] = [ ] <EOL> if self . schema_major_version == <NUM_LIT:2> : <EOL> if not releases and details : <EOL> releases = [ { '<STR_LIT>' : details } ] <EOL> if self . schema_major_version >= <NUM_LIT:2> : <EOL> if not releases : <EOL> e = ProviderException ( u'<STR_LIT>' % ( info [ '<STR_LIT:name>' ] , self . repo ) ) <EOL> self . broken_packages [ info [ '<STR_LIT:name>' ] ] = e <EOL> continue <EOL> if not isinstance ( releases , list ) : <EOL> e = ProviderException ( u'<STR_LIT>' % ( info [ '<STR_LIT:name>' ] , self . repo ) ) <EOL> self . broken_packages [ info [ '<STR_LIT:name>' ] ] = e <EOL> continue <EOL> for release in releases : <EOL> download_details = None <EOL> download_info = { } <EOL> for field in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:version>' , '<STR_LIT:url>' , '<STR_LIT:date>' , '<STR_LIT>' ] : <EOL> if field in release : <EOL> value = release [ field ] <EOL> if field == '<STR_LIT:url>' : <EOL> value = update_url ( value , debug ) <EOL> if field == '<STR_LIT>' and not isinstance ( release [ '<STR_LIT>' ] , list ) : <EOL> value = [ value ] <EOL> download_info [ field ] = value <EOL> if '<STR_LIT>' not in download_info : <EOL> download_info [ '<STR_LIT>' ] = [ '<STR_LIT:*>' ] <EOL> if self . schema_major_version == <NUM_LIT:2> : <EOL> if '<STR_LIT>' not in download_info : <EOL> download_info [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if '<STR_LIT>' in release : <EOL> download_details = release [ '<STR_LIT>' ] <EOL> try : <EOL> github_downloads = github_client . download_info ( download_details ) <EOL> bitbucket_downloads = bitbucket_client . download_info ( download_details ) <EOL> if github_downloads == False or bitbucket_downloads == False : <EOL> raise ProviderException ( u'<STR_LIT>' % ( download_details , info [ '<STR_LIT:name>' ] , self . repo ) ) <EOL> if github_downloads : <EOL> downloads = github_downloads <EOL> elif bitbucket_downloads : <EOL> downloads = bitbucket_downloads <EOL> else : <EOL> raise ProviderException ( u'<STR_LIT>' % ( download_details , info [ '<STR_LIT:name>' ] , self . repo ) ) <EOL> for download in downloads : <EOL> new_download = download_info . copy ( ) <EOL> new_download . update ( download ) <EOL> info [ '<STR_LIT>' ] . append ( new_download ) <EOL> except ( DownloaderException , ClientException , ProviderException ) as e : <EOL> self . broken_packages [ info [ '<STR_LIT:name>' ] ] = e <EOL> elif download_info : <EOL> info [ '<STR_LIT>' ] . append ( download_info ) <EOL> elif self . schema_major_version == <NUM_LIT:3> : <EOL> tags = release . get ( '<STR_LIT>' ) <EOL> branch = release . get ( '<STR_LIT>' ) <EOL> if tags or branch : <EOL> try : <EOL> base = None <EOL> if '<STR_LIT>' in release : <EOL> base = release [ '<STR_LIT>' ] <EOL> elif details : <EOL> base = details <EOL> if not base : <EOL> raise ProviderException ( u'<STR_LIT>' % ( info [ '<STR_LIT:name>' ] , self . repo ) ) <EOL> github_url = False <EOL> bitbucket_url = False <EOL> extra = None <EOL> if tags : <EOL> github_url = github_client . make_tags_url ( base ) <EOL> bitbucket_url = bitbucket_client . make_tags_url ( base ) <EOL> if tags != True : <EOL> extra = tags <EOL> if branch : <EOL> github_url = github_client . make_branch_url ( base , branch ) <EOL> bitbucket_url = bitbucket_client . make_branch_url ( base , branch ) <EOL> if github_url : <EOL> downloads = github_client . download_info ( github_url , extra ) <EOL> url = github_url <EOL> elif bitbucket_url : <EOL> downloads = bitbucket_client . download_info ( bitbucket_url , extra ) <EOL> url = bitbucket_url <EOL> else : <EOL> raise ProviderException ( u'<STR_LIT>' % ( base , info [ '<STR_LIT:name>' ] , self . repo ) ) <EOL> if downloads == False : <EOL> raise ProviderException ( u'<STR_LIT>' % ( url , info [ '<STR_LIT:name>' ] , self . repo ) ) <EOL> for download in downloads : <EOL> new_download = download_info . copy ( ) <EOL> new_download . update ( download ) <EOL> info [ '<STR_LIT>' ] . append ( new_download ) <EOL> except ( DownloaderException , ClientException , ProviderException ) as e : <EOL> self . broken_packages [ info [ '<STR_LIT:name>' ] ] = e <EOL> continue <EOL> elif download_info : <EOL> info [ '<STR_LIT>' ] . append ( download_info ) <EOL> else : <EOL> info [ '<STR_LIT>' ] = platforms_to_releases ( package , debug ) <EOL> info [ '<STR_LIT>' ] = version_sort ( info [ '<STR_LIT>' ] , '<STR_LIT>' , reverse = True ) <EOL> if info [ '<STR_LIT:name>' ] in self . broken_packages : <EOL> continue <EOL> if '<STR_LIT>' not in info : <EOL> self . broken_packages [ info [ '<STR_LIT:name>' ] ] = ProviderException ( u'<STR_LIT>' % ( info [ '<STR_LIT:name>' ] , self . repo ) ) <EOL> continue <EOL> if '<STR_LIT>' not in info : <EOL> self . broken_packages [ info [ '<STR_LIT:name>' ] ] = ProviderException ( u'<STR_LIT>' % ( info [ '<STR_LIT:name>' ] , self . repo ) ) <EOL> continue <EOL> def has_broken_release ( ) : <EOL> for release in info . get ( '<STR_LIT>' , [ ] ) : <EOL> for key in [ '<STR_LIT:version>' , '<STR_LIT:date>' , '<STR_LIT:url>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if key not in release : <EOL> self . broken_packages [ info [ '<STR_LIT:name>' ] ] = ProviderException ( u'<STR_LIT>' % ( key , info [ '<STR_LIT:name>' ] , self . repo ) ) <EOL> return True <EOL> return False <EOL> if has_broken_release ( ) : <EOL> continue <EOL> for field in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if field not in info : <EOL> info [ field ] = [ ] <EOL> if '<STR_LIT>' in info : <EOL> info [ '<STR_LIT>' ] = update_url ( info [ '<STR_LIT>' ] , debug ) <EOL> for field in [ '<STR_LIT:description>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if field not in info : <EOL> info [ field ] = None <EOL> if '<STR_LIT>' not in info : <EOL> info [ '<STR_LIT>' ] = self . repo <EOL> if '<STR_LIT>' in info and '<STR_LIT>' not in info : <EOL> date = '<STR_LIT>' <EOL> for release in info [ '<STR_LIT>' ] : <EOL> if '<STR_LIT:date>' in release and release [ '<STR_LIT:date>' ] > date : <EOL> date = release [ '<STR_LIT:date>' ] <EOL> info [ '<STR_LIT>' ] = date <EOL> if info [ '<STR_LIT:name>' ] in previous_names : <EOL> info [ '<STR_LIT>' ] . extend ( previous_names [ info [ '<STR_LIT:name>' ] ] ) <EOL> output [ info [ '<STR_LIT:name>' ] ] = info <EOL> yield ( info [ '<STR_LIT:name>' ] , info ) <EOL> self . cache [ '<STR_LIT>' ] = output <EOL> def get_sources ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . fetch_and_validate ( ) : <EOL> return [ ] <EOL> output = [ self . repo ] <EOL> if self . schema_major_version >= <NUM_LIT:2> : <EOL> for package in self . repo_info [ '<STR_LIT>' ] : <EOL> details = package . get ( '<STR_LIT>' ) <EOL> if details : <EOL> output . append ( details ) <EOL> return output <EOL> def get_renamed_packages ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . fetch_and_validate ( ) : <EOL> return { } <EOL> if self . schema_major_version < <NUM_LIT:2> : <EOL> return self . repo_info . get ( '<STR_LIT>' , { } ) <EOL> output = { } <EOL> for package in self . repo_info [ '<STR_LIT>' ] : <EOL> if '<STR_LIT>' not in package : <EOL> continue <EOL> previous_names = package [ '<STR_LIT>' ] <EOL> if not isinstance ( previous_names , list ) : <EOL> previous_names = [ previous_names ] <EOL> for previous_name in previous_names : <EOL> output [ previous_name ] = package [ '<STR_LIT:name>' ] <EOL> return output </s>
