def get_editors(tunnel: Tunnel = None): """ Get AttributeDict of SupportedEditors. Builds an AttributeDict of data about each of the support VSCode editor variations on the current system. Keyword Arguments: tunnel {Tunnel} -- An SSH tunnel connection, which is used to make remote requests as part of building the editor information Returns AttributeDict """ return AttributeDict({ 'code': SupportedEditor( command=SupportedEditorCommands.code, editor_id='VSCode', home_dirname='.vscode', remote_alias='stable', tunnel=tunnel, ), 'insiders': SupportedEditor( command=SupportedEditorCommands.insiders, editor_id='VSCode Insiders', home_dirname='.vscode-insiders', remote_alias='insider', tunnel=tunnel, ), 'exploration': SupportedEditor( command=SupportedEditorCommands.exploration, editor_id='VSCode Exploration', home_dirname='.vscode-exploration', remote_alias='exploration', tunnel=tunnel, ), 'codium': SupportedEditor( command=SupportedEditorCommands.codium, editor_id='VSCodium', home_dirname='.vscode-oss', remote_alias='codium', tunnel=tunnel, api_root_url= 'https://api.github.com/repos/VSCodium/vscodium/releases/latest', github_ext_pattern=platform_query(darwin='dmg', windows='exe', linux='AppImage', rpm='rpm', deb='deb')) })
def __init__(self, parsed_marketplace_response, tunnel=None): # abbreviate the parsed response to make it easier to reference. response = parsed_marketplace_response # Keep a reference to the provided tunnel connection. self.tunnel = tunnel # Get references to the extension attributes we need. self.extension_id = response['extensionId'] self.extension_name = response['extensionName'] self.display_name = response['displayName'] self.publisher_name = response['publisher']['publisherName'] self.unique_id = f'{self.publisher_name}.{self.extension_name}' self.description = response['shortDescription'] self.stats = response['statistics'] # Some attributes are nested. We don't need to store these nested # objects directly, but we need them to find the values of other # attributes that we do want to store. version = response['versions'][0] files = version['files'] properties = version['properties'] # TODO: We may not need all this URI information. self.uri = AttributeDict({ 'asset': version['assetUri'], 'asset_fallback': version['fallbackAssetUri'], 'manifest': self._manifest_url(files), 'vsix_package': self._vsix_package_uri(files), }) # The version of the extension, itself. self.version = version['version'] # The code engine specifies the minimum version of VSCode that this # extension is specified to work on. self.code_engine = self._code_engine(properties) # Find out if this is an extension pack. If so, we'll need to download # each of the extensions in the pack whenever this extension downloads. self.extension_pack = self._extension_pack(properties) # Find out if this extension has dependencis. If so, we'll need to # download and install each of the dependencies before we download/ # install this extension. self.extension_dependencies = self._extension_dependencies(properties) super().__init__(unique_id=self.unique_id, download_url=self.uri.vsix_package, tunnel=self.tunnel)
_GITHUB_ROOT_URI = 'https://github.com' # NOTE: Active issue for better handling offline binaries installation # https://github.com/microsoft/vscode-cpptools/issues/5290 # TODO: Check into options for things like: # - platform-specified vsix extensions # - check dependencies via the install.lock file (https://github.com/microsoft/vscode-cpptools/issues/4778#issuecomment-568125545) _NON_MARKETPLACE_EXTENSIONS = AttributeDict({ 'ms-vscode.cpptools': AttributeDict({ 'owner': 'Microsoft', 'repo': 'vscode-cpptools', 'asset_name': platform_query(windows='cpptools-win32.vsix', darwin='cpptools-osx.vsix', linux64='cpptools-linux.vsix', linux32='cpptools-linux32.vsix') }) }) _LOGGER = get_rich_logger(__name__) _REQUEST_CURLER = CurledRequest() class Extension: """Extension base class""" def __init__(self, tunnel=None, **kwargs): self.tunnel = tunnel
_MARKETPLACE_EDITOR_DISTRO_PATTERN = platform_query(windows='win32-x64', win32='win32', darwin='darwin', linux='linux-x64', linux32='linux-ia32', rpm='linux-rpm-64', rpm32='linux-rpm-ia32', deb='linux-deb-x64', deb32='linux-deb-ia32') _LOGGER = get_rich_logger(__name__) _curled = CurledRequest() SupportedEditorCommands = AttributeDict({ 'code': 'code', 'insiders': 'code-insiders', 'exploration': 'code-exploration', 'codium': 'codium', }) class SupportedEditor(AttributeDict): """ Define the attributes of a supported code editor. """ def __init__( self, command, editor_id, remote_alias, home_dirname, tunnel,
ExtensionQueryFilterType = AttributeDict({ # The values are used as tags. All tags are treated as "OR" conditions with # each other. There may be some value put on the number of matched tags # from the query. # 'Tag': 1, # # The Values are an ExtensionName or fragment that is used to match other extension names. # 'DisplayName': 2, # # The Filter is one or more tokens that define what scope to return private extensions for. # 'Private': 3, # # Retrieve a set of extensions based on their id's. The values should be # the extension id's encoded as strings. # 'Id': 4, # # The catgeory is unlike other filters. It is AND'd with the other filters # instead of being a seperate query. # 'Category': 5, # # Certain contribution types may be indexed to allow for query by type. # User defined types can't be indexed at the moment. # 'ContributionType': 6, # # Retrieve an set extension based on the name based identifier. This # differs from the internal id (which is being deprecated). # 'Name': 7, # # The InstallationTarget for an extension defines the target consumer for # the extension. This may be something like VS, VSOnline, or VSCode # 'InstallationTarget': 8, # # Query for featured extensions, no value is allowed when using the query type. # 'Featured': 9, # # The SearchText provided by the user to search for extensions # 'SearchText': 10, # # Query for extensions that are featured in their own category, The # filterValue for this is name of category of extensions. # 'FeaturedInCategory': 11, # # When retrieving extensions from a query, exclude the extensions which are having the given # flags. The value specified for this filter should be a string representing the integer values # of the flags to be excluded. In case of mulitple flags to be specified, a logical OR of the # interger values should be given as value for this filter This should be at most one filter # of this type. This only acts as a restrictive filter after. In case of having a particular # flag in both IncludeWithFlags and ExcludeWithFlags, excludeFlags will remove the included # extensions giving empty result for that flag. # 'ExcludeWithFlags': 12, # # When retrieving extensions from a query, include the extensions which are # having the given flags. The value specified for this filter should be a # string representing the integer values of the flags to be included. In # case of mulitple flags to be specified, a logical OR of the interger # values should be given as value for this filter This should be at most # one filter of this type. This only acts as a restrictive filter after. # In case of having a particular flag in both IncludeWithFlags and # ExcludeWithFlags, excludeFlags will remove the included extensions giving # empty result for that flag. In case of multiple flags given in # IncludeWithFlags in ORed fashion, extensions having any of the given # flags will be included. # 'IncludeWithFlags': 13, # # Fitler the extensions based on the LCID values applicable. Any extensions # which are not having any LCID values will also be filtered. This is # currenlty only supported for VS extensions. # 'Lcid': 14, # # Filter to provide the version of the installation target. This filter # will be used along with InstallationTarget filter. The value should be a # valid version string. Currently supported only if search text is provided # 'InstallationTargetVersion': 15, # # Filter type for specifying a range of installation target version. The # filter will be used along with InstallationTarget filter. The value # should be a pair of well formed version values separated by hyphen(-). # Currently supported only if search text is provided. # 'InstallationTargetVersionRange': 16, # # Filter type for specifying metadata key and value to be used for filtering. # 'VsixMetadata': 17, # # Filter to get extensions published by a publisher having supplied internal name # 'PublisherName': 18, # # Filter to get extensions published by all publishers having supplied display name # 'PublisherDisplayName': 19, # # When retrieving extensions from a query, include the extensions which # have a publisher having the given flags. The value specified for this # filter should be a string representing the integer values of the flags # to be included. In case of mulitple flags to be specified, a logical OR # of the interger values should be given as value for this filter There # should be at most one filter of this type. This only acts as a # restrictive filter after. In case of multiple flags given in # IncludeWithFlags in ORed fashion, extensions having any of the given # flags will be included. # 'IncludeWithPublisherFlags': 20, # # Filter to get extensions shared with particular organization # 'OrganizationSharedWith': 21, })