{"id":15371330,"url":"https://github.com/sultaniman/pycran","last_synced_at":"2025-03-27T21:44:09.544Z","repository":{"id":62579638,"uuid":"247689648","full_name":"sultaniman/pycran","owner":"sultaniman","description":"CRAN R package metadata parser","archived":false,"fork":false,"pushed_at":"2020-11-30T17:42:29.000Z","size":1910,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-02T00:17:24.228Z","etag":null,"topics":["cran-r","metadata-parser","parser","python","r"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sultaniman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-16T11:53:17.000Z","updated_at":"2021-03-28T22:21:54.000Z","dependencies_parsed_at":"2022-11-03T21:01:00.389Z","dependency_job_id":null,"html_url":"https://github.com/sultaniman/pycran","commit_stats":null,"previous_names":["imanhodjaev/pycran"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sultaniman%2Fpycran","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sultaniman%2Fpycran/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sultaniman%2Fpycran/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sultaniman%2Fpycran/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sultaniman","download_url":"https://codeload.github.com/sultaniman/pycran/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245931707,"owners_count":20695958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cran-r","metadata-parser","parser","python","r"],"created_at":"2024-10-01T13:46:27.333Z","updated_at":"2025-03-27T21:44:09.502Z","avatar_url":"https://github.com/sultaniman.png","language":"Python","readme":"[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pycran?label=Python\u0026style=for-the-badge)](https://pypi.org/project/pycran/)\n![Build Status](https://img.shields.io/travis/com/imanhodjaev/pycran/master?style=for-the-badge)\n![Maintainability](https://img.shields.io/codeclimate/maintainability/imanhodjaev/pycran?style=for-the-badge\u0026color=44d298)\n![Codecov](https://img.shields.io/codecov/c/github/imanhodjaev/pycran/master?style=for-the-badge)\n![PyPI - License](https://img.shields.io/pypi/l/pycran?color=ff69b4\u0026style=for-the-badge)\n\n\u003cp align=\"center\"\u003e\n  \u003ch1 align=\"center\"\u003ePyCran\u003c/h1\u003e\n\u003c/p\u003e\n\n## Overview 👀\nYet another metadata parser for `R` source packages and `R` metadata information\n\n```ini\nPackage: ABACUS\nVersion: 1.0.0\nDepends: R (\u003e= 3.1.0)\nImports: ggplot2 (\u003e= 3.1.0), shiny (\u003e= 1.3.1),\nSuggests: rmarkdown (\u003e= 1.13), knitr (\u003e= 1.22)\nLicense: GPL-3\nMD5sum: 50c54c4da09307cb95a70aaaa54b9fbd\nNeedsCompilation: no\n```\n\nFor more see: https://cran.r-project.org/src/contrib/PACKAGES\n\nPyCran lets us parse raw metadata and get it as dictionary, you can:\n\n1. Encode metadata dictionary to raw format,\n2. Decode raw metadata and receive it as dictionary,\n3. Load from tar archive with `R` library sources.\n\n\n## Installation 💾\n\n```sh\n$ pip install pycran\n```\n\n## Usage 🚀\n\n### Decode\n```python\nimport pycran\n\nraw_metadata = \"\"\"\nPackage: ABACUS\nVersion: 1.0.0\nDepends: R (\u003e= 3.1.0)\nImports: ggplot2 (\u003e= 3.1.0), shiny (\u003e= 1.3.1),\nSuggests: rmarkdown (\u003e= 1.13), knitr (\u003e= 1.22)\nLicense: GPL-3\nMD5sum: 50c54c4da09307cb95a70aaaa54b9fbd\nNeedsCompilation: no\n\"\"\"\n\nassert pycran.decode(raw_metadata) == {\n    \"Package\": \"ABACUS\",\n    \"Version\": \"1.0.0\",\n    \"Depends\": \"R (\u003e= 3.1.0)\",\n    \"Imports\": \"ggplot2 (\u003e= 3.1.0), shiny (\u003e= 1.3.1),\",\n    \"Suggests\": \"rmarkdown (\u003e= 1.13), knitr (\u003e= 1.22)\",\n    \"License\": \"GPL-3\",\n    \"MD5sum\": \"50c54c4da09307cb95a70aaaa54b9fbd\",\n    \"NeedsCompilation\": \"no\",\n}\n```\n\n### Encode\n\n```python\nimport pycran\n\nmetadata = {\n    \"Package\": \"ABACUS\",\n    \"Version\": \"1.0.0\",\n    \"Depends\": \"R (\u003e= 3.1.0)\",\n    \"Imports\": \"ggplot2 (\u003e= 3.1.0), shiny (\u003e= 1.3.1),\",\n    \"Suggests\": \"rmarkdown (\u003e= 1.13), knitr (\u003e= 1.22)\",\n    \"License\": \"GPL-3\",\n    \"MD5sum\": \"50c54c4da09307cb95a70aaaa54b9fbd\",\n    \"NeedsCompilation\": \"no\",\n}\n\nexpected = \"\"\"\nPackage: ABACUS\nVersion: 1.0.0\nDepends: R (\u003e= 3.1.0)\nImports: ggplot2 (\u003e= 3.1.0), shiny (\u003e= 1.3.1),\nSuggests: rmarkdown (\u003e= 1.13), knitr (\u003e= 1.22)\nLicense: GPL-3\nMD5sum: 50c54c4da09307cb95a70aaaa54b9fbd\nNeedsCompilation: no\n\"\"\"\n\nassert pycran.encode(metadata) == expected\n```\n\n### Load from R source archive\n\n```python\nimport pycran\n\n# you can pass path to archive\npycran.from_file(\"PATH/TO/PACKAGE/ABACUS_1.0.0.tar.gz\")\n\n# or you can pass tarfile object\nimport tarfile\n\npycran.from_file(tarfile.open(\"PATH/TO/PACKAGE/ABACUS_1.0.0.tar.gz\"))\n```\n\n### Parse raw metadata\n\nIn cases when you need to parse metadata for multiple\npackages you can pass the data to `pycran.parse` function\n\n```python\nimport pycran\n\n# somehow you download the contents of https://cran.r-project.org/src/contrib/PACKAGES\npackage_list = requests.get(https://cran.r-project.org/src/contrib/PACKAGES).text()\n\n# And parse it as a result you will get a generator which you can iterate\npycran.parse(package_list)\n```\n\n\u003ch2 align=\"center\"\u003eEnjoy!\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003c/h2\u003e\n\u003cp align=\"center\"\u003e\n        ✨ 🍰 ✨\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\n\u003c/p\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsultaniman%2Fpycran","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsultaniman%2Fpycran","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsultaniman%2Fpycran/lists"}