-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conda repos are still not enabled because there's still no way to distinguish python modules
- Loading branch information
Showing
2 changed files
with
32 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (C) 2018-2019 Dmitry Marakasov <[email protected]> | ||
# Copyright (C) 2018-2019,2022 Dmitry Marakasov <[email protected]> | ||
# | ||
# This file is part of repology | ||
# | ||
|
@@ -15,21 +15,41 @@ | |
# You should have received a copy of the GNU General Public License | ||
# along with repology. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import json | ||
from typing import Iterable | ||
|
||
from repology.logger import Logger | ||
from repology.package import LinkType | ||
from repology.packagemaker import NameType, PackageFactory, PackageMaker | ||
from repology.parsers import Parser | ||
from repology.parsers.json import iter_json_dict | ||
|
||
|
||
class CondaRepodataJsonParser(Parser): | ||
def iter_parse(self, path: str, factory: PackageFactory) -> Iterable[PackageMaker]: | ||
with open(path, 'r', encoding='utf-8') as jsonfile: | ||
for pkgfilename, pkgdata in json.load(jsonfile)['packages'].items(): | ||
pkg = factory.begin(pkgfilename) | ||
|
||
for pkgfilename, pkgdata in iter_json_dict(path, ('packages', None)): | ||
with factory.begin(pkgfilename) as pkg: | ||
pkg.add_name(pkgdata['name'], NameType.GENERIC_GEN_NAME) | ||
pkg.set_version(pkgdata['version']) | ||
pkg.add_licenses(pkgdata.get('license', '')) | ||
|
||
yield pkg | ||
|
||
|
||
class CondaChanneldataJsonParser(Parser): | ||
def iter_parse(self, path: str, factory: PackageFactory) -> Iterable[PackageMaker]: | ||
for pkgname, pkgdata in iter_json_dict(path, ('packages', None)): | ||
with factory.begin(pkgname) as pkg: | ||
pkg.add_name(pkgname, NameType.GENERIC_SRC_NAME) | ||
if 'version' not in pkgdata: | ||
pkg.log('version missing', Logger.ERROR) | ||
continue | ||
|
||
pkg.set_version(pkgdata['version']) | ||
pkg.add_licenses(pkgdata.get('license')) | ||
pkg.set_summary(pkgdata.get('summary')) | ||
pkg.add_links(LinkType.UPSTREAM_DOCUMENTATION, pkgdata.get('doc_url'), pkgdata.get('doc_source_url')) | ||
pkg.add_links(LinkType.UPSTREAM_HOMEPAGE, pkgdata.get('home')) | ||
pkg.add_links(LinkType.UPSTREAM_DOWNLOAD, pkgdata.get('source_url')) | ||
pkg.add_links(LinkType.UPSTREAM_HOMEPAGE, pkgdata.get('dev_url')) | ||
|
||
yield pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters