The Graph is a structured collection of Node, Link, LinkType, and Detail objects.
More...
|
| def | __init__ (self, name, filename, url, username, key) |
| | This is the constructor for the Graph class. More...
|
| |
| def | queue (self, query, callback) |
| | All queries should be processed through this function to ensure that they process in order. More...
|
| |
| def | prep (self, query) |
| | Turns a query dictionary into a valid URL. More...
|
| |
| def | add_detail |
| | This adds a Detail to the Graph. More...
|
| |
| def | add_link |
| | This adds a Link to the Graph. More...
|
| |
| def | add_link_type |
| | Adds a LinkType to the Graph. More...
|
| |
| def | add_node |
| | Adds a Node to the Graph. More...
|
| |
| def | detail (self, uid) |
| | Returns a Detail by its UID. More...
|
| |
| def | detail_list (self) |
| | Returns a list of Detail objects in the Graph. More...
|
| |
| def | details (self) |
| | Returns a dictionary of Detail objects keyed by uid. More...
|
| |
| def | draw |
| | Calculates a layout for the Graph and returns new positions for all Node and Detail objects. More...
|
| |
| def | height (self) |
| | Returns the height of the Graph. More...
|
| |
| def | link (self, uid) |
| | Returns a Link by uid. More...
|
| |
| def | link_list (self) |
| | Returns a list of Link objects in the Graph. More...
|
| |
| def | links (self) |
| | Returns a uid-keyed dictionary of Link objects in the Graph. More...
|
| |
| def | link_type (self, name) |
| | Returns a LinkType object by name. More...
|
| |
| def | link_types (self) |
| | Returns a name-keyed dictionary of LinkType objects. More...
|
| |
| def | max_x (self) |
| | Returns the maximum x value of all Node objects in the Graph. More...
|
| |
| def | max_y (self) |
| | Returns the maximum y value of all Node objects in the Graph. More...
|
| |
| def | min_x (self) |
| | Returns the minimum x value of all Node objects in the Graph. More...
|
| |
| def | min_y (self) |
| | Returns the minimum y value of all Node objects in the Graph. More...
|
| |
| def | node (self, uid) |
| | Returns a Node by uid. More...
|
| |
| def | node_list (self) |
| | Returns a list of all Node objects in the Graph. More...
|
| |
| def | nodes (self) |
| | Returns a uid-keyed dictionary of Node objects. More...
|
| |
| def | publish |
| | Creates a perma-link for a public viewer of the graph. More...
|
| |
| def | remove_detail |
| | Removes a Detail from the Graph. More...
|
| |
| def | remove_link |
| | Removes a Link from the Graph. More...
|
| |
| def | remove_node |
| | Removes a Node from the Graph. More...
|
| |
| def | width (self) |
| | Returns the width of the Graph. More...
|
| |
The Graph is a structured collection of Node, Link, LinkType, and Detail objects.
Most actions are performed through the Graph class.
| def psynth.psynth.Graph.__init__ |
( |
|
self, |
|
|
|
name, |
|
|
|
filename, |
|
|
|
url, |
|
|
|
username, |
|
|
|
key |
|
) |
| |
This is the constructor for the Graph class.
It should not be accessed directly, but instead through the create_graph and load_graph functions.
- Parameters
-
| name | str :: The displayed name of a Graph. |
| filename | str :: A global unique filename of a Graph. |
| url | str :: The base URL of your Psynth server. e.g. https://psynth.psymphonic.com/ |
| username | str :: Your Psynth username |
| key | str :: Your Psynth API key. |
3 url=
'https://psynth.psymphonic.com/',
4 username=
'me@company.com',
3 url=
'https://psynth.psymphonic.com/',
4 username=
'me@company.com',
| def psynth.psynth.Graph.add_detail |
( |
|
self, |
|
|
|
detail, |
|
|
|
callback = None, |
|
|
|
update = True |
|
) |
| |
This adds a Detail to the Graph.
It is easier to add Detail objects directly to Node and Link objects.
- Parameters
-
| detail | Detail :: A Detail object to add to the Graph. |
| callback | function :: A function to perform on the response of the query. |
| update | bool :: Whether or not to immediately enqueue the query. |
1 g.add_detail(my_detail, callback=my_function)
| def psynth.psynth.Graph.add_link |
( |
|
self, |
|
|
|
link, |
|
|
|
callback = None, |
|
|
|
update = True |
|
) |
| |
This adds a Link to the Graph.
- Parameters
-
| link | Link :: A Link to add to the Graph. |
| callback | function :: A function to perform on the response to the query. |
| update | bool :: Whether or not to immediately enqueue the query. |
1 g.add_link(my_link, callback=my_function)
| def psynth.psynth.Graph.add_link_type |
( |
|
self, |
|
|
|
link_type, |
|
|
|
callback = None, |
|
|
|
update = True |
|
) |
| |
Adds a LinkType to the Graph.
Must be added before Link objects of that type can be created.
- Parameters
-
| link_type | LinkType :: A LinkType to add to the Graph |
| callback | function :: A function to perform on the response to the query. |
| update | bool :: Whether or not to immediately enqueue the query. |
1 g.add_link_type(my_link_type, callback=my_function)
| def psynth.psynth.Graph.add_node |
( |
|
self, |
|
|
|
node, |
|
|
|
callback = None, |
|
|
|
update = True |
|
) |
| |
Adds a Node to the Graph.
- Parameters
-
| node | Node :: The Node to add to the Graph. |
| callback | function :: An optional function to handle the server's response to the query. |
| update | Whether or not to immediately enqueue the query. |
1 g.add_node(my_node, callback=my_function)
| def psynth.psynth.Graph.detail |
( |
|
self, |
|
|
|
uid |
|
) |
| |
Returns a Detail by its UID.
- Parameters
-
| uid | str :: The uid of the Detail to return. |
- Returns
- detail: Detail ::
1 my_detail = g.detail(unique_id)
| def psynth.psynth.Graph.detail_list |
( |
|
self | ) |
|
Returns a list of Detail objects in the Graph.
- Returns
- details: list :: A list of Detail objects.
1 for d
in g.detail_list():
| def psynth.psynth.Graph.details |
( |
|
self | ) |
|
Returns a dictionary of Detail objects keyed by uid.
- Returns
- details: dict :: A uid-keyed dictionary of Detail objects.
2 print g.details()[d].anchor().name
| def psynth.psynth.Graph.draw |
( |
|
self, |
|
|
|
callback = None |
|
) |
| |
Calculates a layout for the Graph and returns new positions for all Node and Detail objects.
- Parameters
-
| callback | function :: An optional function to handle the server's response to the query. |
1 for i
in range(0, 100):
2 n = Node(name=
'Node '+str(i))
| def psynth.psynth.Graph.height |
( |
|
self | ) |
|
Returns the height of the Graph.
- Returns
- height: float ::
| def psynth.psynth.Graph.link |
( |
|
self, |
|
|
|
uid |
|
) |
| |
Returns a Link by uid.
- Parameters
-
| uid | str :: The uid of the Link to return. |
- Returns
- link: Link ::
1 my_link = g.link(unique_id)
| def psynth.psynth.Graph.link_list |
( |
|
self | ) |
|
Returns a list of Link objects in the Graph.
- Returns
- links: list :: A list of Link objects.
1 for link
in g.link_list():
| def psynth.psynth.Graph.link_type |
( |
|
self, |
|
|
|
name |
|
) |
| |
Returns a LinkType object by name.
- Parameters
-
| name | str :: The name of the LinkType to return. |
- Returns
- link_type: LinkType ::
1 lt = g.link_type(
'Money')
| def psynth.psynth.Graph.link_types |
( |
|
self | ) |
|
Returns a name-keyed dictionary of LinkType objects.
- Returns
- link_types: dict :: A name-keyed dictionary of LinkType objects.
1 for lt
in g.link_types():
2 print len(g.link_types[lt].links())
| def psynth.psynth.Graph.links |
( |
|
self | ) |
|
Returns a uid-keyed dictionary of Link objects in the Graph.
- Returns
- links: dict :: A uid-keyed dictionary of Link objects.
2 print g.links()[uid].name
| def psynth.psynth.Graph.max_x |
( |
|
self | ) |
|
Returns the maximum x value of all Node objects in the Graph.
- Returns
- x: float ::
1 n = Node(x=g.max_x()+50)
| def psynth.psynth.Graph.max_y |
( |
|
self | ) |
|
Returns the maximum y value of all Node objects in the Graph.
- Returns
- y: float ::
1 n = Node(y=g.max_y()-50)
| def psynth.psynth.Graph.min_x |
( |
|
self | ) |
|
Returns the minimum x value of all Node objects in the Graph.
- Returns
- x: float ::
1 n = Node(x=g.min_x()+50)
| def psynth.psynth.Graph.min_y |
( |
|
self | ) |
|
Returns the minimum y value of all Node objects in the Graph.
- Returns
- y: float ::
1 n = Node(x=g.min_y()+50)
| def psynth.psynth.Graph.node |
( |
|
self, |
|
|
|
uid |
|
) |
| |
Returns a Node by uid.
- Parameters
-
| uid | str :: The uid of the Node to be returned. |
- Returns
- node: Node ::
| def psynth.psynth.Graph.node_list |
( |
|
self | ) |
|
Returns a list of all Node objects in the Graph.
- Returns
- nodes: list :: A list of Node objects.
1 for n
in g.node_list():
| def psynth.psynth.Graph.nodes |
( |
|
self | ) |
|
Returns a uid-keyed dictionary of Node objects.
- Returns
- nodes: dict :: A uid-keyed dictionary of Node objects.
2 print g.nodes()[n].name
| def psynth.psynth.Graph.prep |
( |
|
self, |
|
|
|
query |
|
) |
| |
Turns a query dictionary into a valid URL.
Mostly used internally.
- Parameters
-
| query | dict :: A query dictionary. |
- Returns
- url: str :: A valid URL
1 c = requests.get(g.prep(query))
| def psynth.psynth.Graph.publish |
( |
|
self, |
|
|
|
callback = None |
|
) |
| |
Creates a perma-link for a public viewer of the graph.
- Parameters
-
| callback | function :: An optional function to handle the server's response to the query. |
| def psynth.psynth.Graph.queue |
( |
|
self, |
|
|
|
query, |
|
|
|
callback |
|
) |
| |
All queries should be processed through this function to ensure that they process in order.
Mostly used internally.
- Parameters
-
| query | dict :: A dictionary object that contains query parameters. |
| callback | function :: A function that should be performed on the response from the query. |
3 g.queue({
'query':
'drawgraph'}, point_handler)
| def psynth.psynth.Graph.remove_detail |
( |
|
self, |
|
|
|
detail, |
|
|
|
callback = None, |
|
|
|
update = True |
|
) |
| |
Removes a Detail from the Graph.
- Parameters
-
| detail | Detail :: The Detail to remove. |
| callback | function :: An optional function to handle the server's response to the query. |
| update | bool :: Whether or not to immediately enqueue the query. |
1 g.remove_detail(my_detail, callback=my_function)
| def psynth.psynth.Graph.remove_link |
( |
|
self, |
|
|
|
link, |
|
|
|
callback = None, |
|
|
|
update = True |
|
) |
| |
Removes a Link from the Graph.
- Parameters
-
| link | Link The Link to remove. |
| callback | function :: An optional function to handle the server's response to the query. |
| update | bool :: Whether or not to immediately enqueue the query. |
1 g.remove_link(my_link, callback=my_function)
| def psynth.psynth.Graph.remove_node |
( |
|
self, |
|
|
|
node, |
|
|
|
callback = None, |
|
|
|
update = True |
|
) |
| |
Removes a Node from the Graph.
- Parameters
-
| node | Node :: The Node to remove. |
| callback | function :: An optional function to handle the server's response to the query. |
| update | bool :: Whether or not to immediately enqueue the query. |
1 g.remove_node(my_node, callback=my_function)
| def psynth.psynth.Graph.width |
( |
|
self | ) |
|
Returns the width of the Graph.
- Returns
- width: float ::
| psynth.psynth.Graph.filename |
str :: The global unique filename of the Graph.
str :: Your Psynth API Key.
str :: The display name of the Graph.
str :: The base URL for your psynth server.
e.g. "https://psynth.psymphonic.com/"
| psynth.psynth.Graph.username |
str :: Your Psynth username.
The documentation for this class was generated from the following file:
- /Users/psymac0/GitHub/python_psynth/psynth/psynth.py