pgformat
Property Graph Exchange Format (PG) parser and serializer
This package implements parsers and serializers to for labeled property graphs in Property Graph Exchange Format.
Table of Contents
Install
Requires Python 3.8 or above.
pip install pgformat
Usage
The package comes with a simple command line client to convert between serialization forms of Property Graph Exchange format and an API to be used in python code. The command line client by default reads PG Format and emits PG JSONL.
usage: pgformat [-h] [-t {ndjson,json,pg}] [source]
Parse and transform property graphs in PG Format.
positional arguments:
source input file (default: - for standard input)
options:
-h, --help show this help message and exit
-t {ndjson,json,pg}, --to {ndjson,json,pg}
target format
The functionality is a subset of the pgraph command line tool written in NodeJS.
The command line client can also be called via python -m pgformat.
API
The package exports the functions parseGraph, parseStatements, and serializeGraph:
from pgformat import parseGraph, parseStatements, serializeGraph
statements = parseStatements("x\na -> b") # list of statements
graph = parseGraph("a -> b") # full graph
pg = serializeGraph(graph) # back to PG Format
The internal format of graphs and their statements is a data structure of plain lists and arrays for direct conversion to JSON. This may be changed in a future version.
parseGraph
parseGraph(str: str, sort=True, implicitNodes=True) -> dict
Parse a property graph given as string in PG Format. Returns a dict with keys nodes and edges (PG JSON format).
Optional parameter sort sorts nodes and edges by their identifier, and labels by their value. Optional parameter implicitNodes adds nodes for node identifiers referenced in edges only.
parseStatements
parseStatements(str: str, implicitNodes=True, mergeNodes=True, duplicatedEdges=False) -> list
Parse a list of statements given as string in PG Format. Returns a list of node and edge statements in order of appearance (PG JSON format).
Optional parameter mergeNodes applies merging of nodes with same identifiers. Optional parameter duplicatedEdges throws an exception if set to False.
serializeGraph
serializeGraph(graph: dict) -> str
Convert a property graph to PG Format.
License
Licensed under the MIT License.
Metadata
Release files for pgformat 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pgformat-0.2.1.tar.gz | 9.3 kB | Without provenance | Details for pgformat-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pgformat-0.2.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for pgformat-0.2.1-py2.py3-none-any.whl |
Total release size: 17.3 kB
Release files / pgformat-0.2.1.tar.gz
| Download URL | pgformat-0.2.1.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a4bc101a18dcff64d79c65b6c377557098b802ad2442cc25bc5cd55351c809e
|
|
BLAKE2b-256 checksum How to use checksums |
1163b16dc2d4adbbf523e0ba78a0957a8de862f19a98580e06641be5debd57a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Release files / pgformat-0.2.1-py2.py3-none-any.whl
| Download URL | pgformat-0.2.1-py2.py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
cc485b5a8920d446f7525163218250d89def50eb309c2b901e524fb40811b4bd
|
|
BLAKE2b-256 checksum How to use checksums |
49157b6a68f00499dcf36e802e471b802241f703f7ceb9e6bc7eb74b2ca834b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Security for pgformat 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.