Parse CRAN package metadata
Project description
PyCran
Overview 👀
Yet another metadata parser for R source packages and R metadata information
Package: ABACUS
Version: 1.0.0
Depends: R (>= 3.1.0)
Imports: ggplot2 (>= 3.1.0), shiny (>= 1.3.1),
Suggests: rmarkdown (>= 1.13), knitr (>= 1.22)
License: GPL-3
MD5sum: 50c54c4da09307cb95a70aaaa54b9fbd
NeedsCompilation: no
For more see: https://cran.r-project.org/src/contrib/PACKAGES
PyCran lets us parse raw metadata and get it as dictionary, you can:
- Encode metadata dictionary to raw format,
- Decode raw metadata and receive it as dictionary,
- Load from tar archive with R library sources.
Installation 💾
$ pip install pycran
Usage 🚀
Decode
from pycran import decode
raw_metadata = """
Package: ABACUS
Version: 1.0.0
Depends: R (>= 3.1.0)
Imports: ggplot2 (>= 3.1.0), shiny (>= 1.3.1),
Suggests: rmarkdown (>= 1.13), knitr (>= 1.22)
License: GPL-3
MD5sum: 50c54c4da09307cb95a70aaaa54b9fbd
NeedsCompilation: no
"""
assert decode(raw_metadata) == {
"Package": "ABACUS",
"Version": "1.0.0",
"Depends": "R (>= 3.1.0)",
"Imports": "ggplot2 (>= 3.1.0), shiny (>= 1.3.1),",
"Suggests": "rmarkdown (>= 1.13), knitr (>= 1.22)",
"License": "GPL-3",
"MD5sum": "50c54c4da09307cb95a70aaaa54b9fbd",
"NeedsCompilation": "no",
}
Encode
from pycran import encode
metadata = {
"Package": "ABACUS",
"Version": "1.0.0",
"Depends": "R (>= 3.1.0)",
"Imports": "ggplot2 (>= 3.1.0), shiny (>= 1.3.1),",
"Suggests": "rmarkdown (>= 1.13), knitr (>= 1.22)",
"License": "GPL-3",
"MD5sum": "50c54c4da09307cb95a70aaaa54b9fbd",
"NeedsCompilation": "no",
}
assert encode(metadata)
Load from R source archive
from pycran import from_file
# you can pass path to archive
from_file("PATH/TO/PACKAGE/ABACUS_1.0.0.tar.gz")
# or you can pass tarfile object
import tarfile
from_file(tarfile.open("PATH/TO/PACKAGE/ABACUS_1.0.0.tar.gz"))
Parse raw metadata
In cases when you need to parse metadata for multiple
packages you can pass the data to pycran.parse
function
from pycran import parse
# somehow you download the contents of https://cran.r-project.org/src/contrib/PACKAGES
package_list = requests.get(https://cran.r-project.org/src/contrib/PACKAGES).text()
# And parse it as a result you will get a generator which you can iterate
parse(package_list)
Enjoy!
✨ 🍰 ✨
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pycran-0.1.0.tar.gz
(982.2 kB
view details)
Built Distribution
File details
Details for the file pycran-0.1.0.tar.gz
.
File metadata
- Download URL: pycran-0.1.0.tar.gz
- Upload date:
- Size: 982.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.23.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b833811542a3cc656425dcc93832867c745b99d2d8e9f1983e00a33c64cb9ab0 |
|
MD5 | 1a5b5e8f7e2a3091a84a2d32d18b0084 |
|
BLAKE2b-256 | 8bed91891ae579e78501b6c411487071705fb80bc3c9870d0ee68db3c4aad372 |
File details
Details for the file pycran-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pycran-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.23.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0371149674bf2b5698e0e761ed343a24209013733e949cde45add1217dfc3c14 |
|
MD5 | be866a33a3226a4860a2a476e479d92c |
|
BLAKE2b-256 | e3cc809c75f2528111aa68a1062cb7272676029437fdcbbc116b616e3d31eb16 |