Skip to main content

Build Status PyPI version

PyGMLParser is a Graph Modeling Language (GML) standalone parser for Python 3.

It is a fork of: icasdri/gml.py


Get it from PyPi by doing:

pip3 install PyGMLParser

Uses Travis CI for continuous integration.

The class documentation is here


The specific updates are:

  • Updated to Python 3
  • Use f-strings
  • Separate files for each class
  • Use packages instead of single file
  • Updated GML format from Tulip .gml files to include the following keywords keyword used by the Python Tulip gml exporter ('GML Export')
    • graphics
    • Line
    • point
  • Use dataclasses for graphics and points
  • Use type hinting and custom typing for readability and maintainability
  • Use Python logging for debugging
  • Introduced a set of small unit tests

The fast and the dirty

from org.hasii.pygmlparser.Parser import Parser
from org.hasii.pygmlparser.Graph import Graph
from org.hasii.pygmlparser.Edge import Edge
from org.hasii.pygmlparser.Node import Node
from org.hasii.pygmlparser.graphics.NodeGraphics import NodeGraphics
from org.hasii.pygmlparser.graphics.EdgeGraphics import EdgeGraphics
from org.hasii.pygmlparser.graphics.Point import Point




# Instantiate a parser, load a file, and parse it!
parser: Parser = Parser()
parser.load_gml('/path/to/aGraph.gml')
parser.parse()

# Retrieve the graph nodes 
nodes: Graph.Nodes = graph.graphNodes  # a map of id -> Node objects

# Retrieve the graph edges
edges: Graph.Edges = graph.graphEdges  # list of Edge objects

# Directly access the node or edge attributes
node: Node = graph.graphNodes[0]
edge: Edge = graph.graphEdges[0]

node.id      # the id of this node
edge.source  # the source id of this edge

node.is_anon  # whether or not this node actually appeared as a node block
              # in the input GML (or if it was inferred, via edge source/targets)
              # _True_ if inferred, False if actually appeared

node.forward_edges   # List of Edge instances whose source is this node
node.backward_edges  # List of Edge instances whose target is this node

# Special attributes on Edges
edge.source_node  # Node object corresponding to edge.source (which is an id)
edge.target_node  # Node object corresponding to edge.target (which is an id)

# Get the Tulip extensions
edgeGraphics: EdgeGraphics = edge.graphics
nodeGraphics: NodeGraphics = node.graphics

# Get the edge line drawing description
line:  Tuple[Point] = edgeGraphics.line

Release files for pygmlparser 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygmlparser 1.0.1
File Size Uploaded
pygmlparser-1.0.1.tar.gz 10.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pygmlparser 1.0.1
File Interpreter ABI Platform
pygmlparser-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 25.4 kB

Release files / pygmlparser-1.0.1.tar.gz

Download URL pygmlparser-1.0.1.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
853ee8a2eba007182522a124bec04f62250c58f84440d3439b27ed544cfe587e
BLAKE2b-256 checksum
How to use checksums
d56f031d17fde572c9bfed474da134dedde9cf9a49e5b9f069dd615a5f5b53c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.9

Release files / pygmlparser-1.0.1-py3-none-any.whl

Download URL pygmlparser-1.0.1-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
16eb104bb26bda771b554456c657d87bb00bee72868b2a7558aaf78d7cdcf38b
BLAKE2b-256 checksum
How to use checksums
a556d643715723729de34ff72633ca9b5745dc8372e6fffea09f70394dcab5ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.9

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page