python_psynth
This is the official python package for generating graphs in Psymphonic Psynth
psynth.psynth.Link Class Reference

Links connect Node objects to each other. More...

Public Member Functions

def __init__
 Constructs a Link object. More...
 
def link_type (self)
 Returns the LinkType object that this Link is a member of. More...
 
def add_detail
 Attaches a Detail to this Link. More...
 
def detail_list (self)
 Returns a list of Detail objects which are attached to this Link. More...
 
def details (self)
 Returns a uid-keyed dictionary of Detail objects which are attached to this Link. More...
 
def dictionary (self)
 Returns a dictionary of this Link's properties, as required by the API. More...
 
def origin (self)
 Returns the origin Node. More...
 
def parallel (self)
 Returns a list of Links which are parallel to this Link, meaning that they share two nodes, regardless of direction. More...
 
def terminus (self)
 Returns the terminus Node. More...
 
def update
 Updates the server's registry of this Link. More...
 
def center (self)
 Returns the center point of this Link. More...
 

Public Attributes

 origin_uid
 str :: The global unique id of the origin node. More...
 
 terminus_uid
 str :: The global unique id of the terminus node. More...
 
 type
 str :: The name of the LinkType of this Link
 
 name
 str :: The display name of this Link
 
 value
 int :: The value of this Link, between 1 and the LinkType.max
 
 uid
 str :: The global unique id of this Link
 
 created
 bool :: Whether or not this Link has been created on the server. More...
 

Static Public Attributes

 graph = None
 Graph :: The Graph to which this Link belongs. More...
 

Detailed Description

Links connect Node objects to each other.

They have a LinkType. Detail objects can be attached to them.

Constructor & Destructor Documentation

def psynth.psynth.Link.__init__ (   self,
  origin_uid,
  terminus_uid,
  type,
  name = "Link",
  value = 1,
  uid = None 
)

Constructs a Link object.

Parameters
origin_uidstr :: The uid of the origin Node.
terminus_uidstr :: The uid of the terminus Node.
typestr :: The name of the LinkType that describes this Link.
namestr :: The displayed name of this Link.
valueint :: The value of this Link.
uidstr :: The global unique identifier of this Link.
1 my_link = Link(origin_node.uid, terminus_node.uid, 'Money', value=60)
2 g.add_link(l)

Member Function Documentation

def psynth.psynth.Link.add_detail (   self,
  detail,
  update = True,
  callback = None 
)

Attaches a Detail to this Link.

Parameters
detailDetail :: The Detail to attach to this Link.
updatebool :: Whether or not to immediately enqueue the query.
callbackfunction :: An optional function to handle the server's response to the query.
1 d = Detail(content="http://psymphonic.com", type="link")
2 l.add_detail(d)
def psynth.psynth.Link.center (   self)

Returns the center point of this Link.

Returns
point: dict :: A dictionary {x,y} identifying the center of this Link.
1 if link.center()['x'] > 42:
2  print link.center()['y']
def psynth.psynth.Link.detail_list (   self)

Returns a list of Detail objects which are attached to this Link.

Returns
details: list :: A list of Detail objects which are attached to this Link.
1 for d in n.detail_list():
2  print d.anchor() == n # True
def psynth.psynth.Link.details (   self)

Returns a uid-keyed dictionary of Detail objects which are attached to this Link.

Returns
details: dict :: A uid-keyed dictionary of Detail objects which are attached to this Link.
1 for d in n.details():
2  print n.details()[d].anchor() == n # True
def psynth.psynth.Link.dictionary (   self)

Returns a dictionary of this Link's properties, as required by the API.

Generally used internally to build queries.

Returns
dict: dict :: A dictionary of this Link's properties.
1 q = n.dictionary()
2 q['query'] = 'newnode'
3 g.queue(q)
def psynth.psynth.Link.link_type (   self)

Returns the LinkType object that this Link is a member of.

Returns
link_type: LinkType ::
1 print link.link_type().color
def psynth.psynth.Link.origin (   self)

Returns the origin Node.

Returns
origin: Node ::
1 print link.origin().name
def psynth.psynth.Link.parallel (   self)

Returns a list of Links which are parallel to this Link, meaning that they share two nodes, regardless of direction.

Returns
links: list :: A list of Links which are parallel to this Link.
1 total_value = 0
2 for l2 in l.parallel():
3  total_value += l2
4 print total_value
def psynth.psynth.Link.terminus (   self)

Returns the terminus Node.

Returns
terminus: Node ::
1 print link.terminus().name
def psynth.psynth.Link.update (   self,
  callback = None 
)

Updates the server's registry of this Link.

Parameters
callbackfunction :: An optional function to handle the server's response to the query.
1 l.value += 1
2 l.name = "New Link Name"
3 l.update()

Member Data Documentation

psynth.psynth.Link.created

bool :: Whether or not this Link has been created on the server.

psynth.psynth.Link.graph = None
static

Graph :: The Graph to which this Link belongs.

psynth.psynth.Link.origin_uid

str :: The global unique id of the origin node.

psynth.psynth.Link.terminus_uid

str :: The global unique id of the terminus node.


The documentation for this class was generated from the following file: