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
import pycran
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 pycran.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
import pycran
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",
}
expected = """
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 pycran.encode(metadata) == expected
Load from R source archive
import pycran
# you can pass path to archive
pycran.from_file("PATH/TO/PACKAGE/ABACUS_1.0.0.tar.gz")
# or you can pass tarfile object
import tarfile
pycran.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
import pycran
# 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
pycran.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.2.tar.gz
(985.2 kB
view details)
Built Distribution
File details
Details for the file pycran-0.1.2.tar.gz
.
File metadata
- Download URL: pycran-0.1.2.tar.gz
- Upload date:
- Size: 985.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.23.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28504e83abf1d8c1ed375ffad1c3c97760a4c1a36ba65e16227914eeaf69e4f6 |
|
MD5 | 404e66fc1e8ad99e56a8c368621ec430 |
|
BLAKE2b-256 | 0f70c877cbfa0157eece301fdb497fa1793a2336d1c802c8f64846955a17c4e3 |
File details
Details for the file pycran-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: pycran-0.1.2-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.23.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2434fa3fcab3f9c19f9dfc10b77db08a896ba802d553b2cf45cf57bf1948a0f6 |
|
MD5 | cdbd83cf257acb89b85798c564b3e6e7 |
|
BLAKE2b-256 | 158dd25712b69bc6dad8298aa6a89e4711869a59bed65b6f2fe47b4ef59cb467 |