Skip to content

Commit

Permalink
Tweak Open VSX entry
Browse files Browse the repository at this point in the history
- Fix parser to use standard json processing facility
- Fix handling optional fields (download, description
- Fix package link types and add another link (recipe/manifest)
- Improbe name handling, handle display name properly
- Move repository entry into modules/ fix type, update minpackages,
  enable shadow
  • Loading branch information
AMDmi3 committed Sep 23, 2024
1 parent dc7bd64 commit 00ca224
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 32 deletions.
14 changes: 14 additions & 0 deletions repology/packagemaker/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ class NameType:

CHROMEBREW_NAME: ClassVar[int] = 330

OPENVSX_DISPLAYNAME: ClassVar[int] = 340
OPENVSX_NAMESPACE_SLASH_NAME: ClassVar[int] = 341
OPENVSX_NAMESPACE_DOT_NAME: ClassVar[int] = 342

# Note that packages reside in subdirs such as packages/,
# root-packages/, x11-packages/ and it may be that srcname
# should include directory as well. However these are names
Expand Down Expand Up @@ -547,6 +551,16 @@ class MappedNames:
visiblename=NameType.CHROMEBREW_NAME,
projectname_seed=NameType.CHROMEBREW_NAME,
),
# OpenVSX
_NameMapping(
# assuming srcname according to URLs on open-vsx.org
srcname=NameType.OPENVSX_NAMESPACE_SLASH_NAME,
# assuming binname according to https://stackoverflow.com/questions/34286515/how-to-install-visual-studio-code-extensions-from-command-line,
binname=NameType.OPENVSX_NAMESPACE_DOT_NAME,
trackname=NameType.OPENVSX_NAMESPACE_DOT_NAME,
visiblename=NameType.OPENVSX_DISPLAYNAME,
projectname_seed=NameType.OPENVSX_NAMESPACE_DOT_NAME,
),
]


Expand Down
25 changes: 15 additions & 10 deletions repology/parsers/parsers/openvsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,27 @@
from repology.package import LinkType
from repology.packagemaker import NameType, PackageFactory, PackageMaker
from repology.parsers import Parser
from repology.parsers.json import iter_json_list


class OpenVSXParser(Parser):
def iter_parse(self, path: str, factory: PackageFactory) -> Iterable[PackageMaker]:
with open(path, 'r') as extdatafile:
extension_data = json.load(extdatafile)
raw_extensions = extension_data['extensions']

for extension in raw_extensions:
for extension in iter_json_list(path, ('extensions', None)):
with factory.begin() as pkg:
# TODO: More metadata is available, it's just harder to fetch and will require its own fetcher, in all likelihood
pkg.add_name('vscode-extension:{namespace}-{name}'.format(**extension), NameType.GENERIC_SRC_NAME)
namespace = extension['namespace']
name = extension['name']
pkg.add_name(f'{namespace}.{name}', NameType.OPENVSX_NAMESPACE_DOT_NAME)
pkg.add_name(f'{namespace}/{name}', NameType.OPENVSX_NAMESPACE_SLASH_NAME)
pkg.add_name(extension.get('displayName', name), NameType.OPENVSX_DISPLAYNAME)
pkg.set_version(extension['version'])
pkg.set_summary(extension['description'])
pkg.add_maintainers('{namespace}@openvsx'.format(**extension))
pkg.add_links(LinkType.UPSTREAM_HOMEPAGE, 'https://open-vsx.org/extension/{namespace}/{name}'.format(**extension))
pkg.add_links(LinkType.UPSTREAM_DOWNLOAD, extension['files']['download'])
pkg.set_summary(extension.get('description'))
pkg.add_maintainers(f'{namespace}@openvsx')

if not extension['files']:
continue

pkg.add_links(LinkType.PROJECT_DOWNLOAD, extension['files']['download'])
pkg.add_links(LinkType.PACKAGE_RECIPE_RAW, extension['files']['download'].rsplit('/', 1)[0] + '/package.json')

yield pkg
28 changes: 28 additions & 0 deletions repos.d/modules/openvsx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
###########################################################################
# OpenVSX
###########################################################################
# NOTE: API returns more data for individual packages, including upstream
# url. Unfortunately, we cannot fetch individual API output for every package
# Also if ?size=10000 breaks at some point, we'll have to disable this
- name: openvsx
type: modules
desc: Open VSX
family: openvsx
ruleset: openvsx
minpackages: 3500
sources:
- name: search.json
fetcher:
class: FileFetcher
url: https://open-vsx.org/api/-/search?size=10000
allow_zero_size: false
parser:
class: OpenVSXParser
shadow: true
repolinks:
- desc: Open VSX registry
url: https://open-vsx.org/
packagelinks:
- type: PROJECT_HOMEPAGE
url: 'https://open-vsx.org/extension/{srcname}'
groups: [ all, production ]
22 changes: 0 additions & 22 deletions repos.d/openvsx.yaml

This file was deleted.

0 comments on commit 00ca224

Please sign in to comment.