Public Member Functions | Public Attributes | List of all members
wirecell.pgraph.main.Node Class Reference
Inheritance diagram for wirecell.pgraph.main.Node:

Public Member Functions

def __init__ (self, tn, attrs)
 
def display_name (self)
 
def add_port (self, end, ident)
 
def dot_name (self, port=None)
 
def dot_label (self)
 

Public Attributes

 tn
 
 type
 
 name
 
 ports
 
 attrs
 

Detailed Description

Definition at line 22 of file main.py.

Constructor & Destructor Documentation

def wirecell.pgraph.main.Node.__init__ (   self,
  tn,
  attrs 
)

Definition at line 23 of file main.py.

23  def __init__(self, tn, **attrs):
24  if not attrs:
25  print ("Node(%s) with no attributes"%tn)
26 
27  self.tn = tn
28  tn = tn.split(":")
29  self.type = tn[0]
30  try:
31  self.name = tn[1]
32  except IndexError:
33  self.name = ""
34  self.ports = defaultdict(set);
35  self.attrs = attrs
36 
def __init__(self, tn, attrs)
Definition: main.py:23

Member Function Documentation

def wirecell.pgraph.main.Node.add_port (   self,
  end,
  ident 
)
Add a port of end "head" or "tail" and ident (number).

Definition at line 43 of file main.py.

43  def add_port(self, end, ident):
44  '''
45  Add a port of end "head" or "tail" and ident (number).
46  '''
47  self.ports[end].add(ident)
48 
Coord add(Coord c1, Coord c2)
Definition: restypedef.cpp:23
def add_port(self, end, ident)
Definition: main.py:43
def wirecell.pgraph.main.Node.display_name (   self)

Definition at line 38 of file main.py.

38  def display_name(self):
39  if self.name:
40  return "[%s]"%self.name
41  return "(unnamed)"
42 
def display_name(self)
Definition: main.py:38
def wirecell.pgraph.main.Node.dot_label (   self)

Definition at line 52 of file main.py.

52  def dot_label(self):
53  ret = list()
54  if "head" in self.ports:
55  head = "{%s}" % ("|".join(["<in%d>%d"%(num,num) for num in sorted(self.ports["head"])]),)
56  ret.append(head)
57 
58  body = [self.type, self.display_name]
59  for k,v in sorted(self.attrs.items()):
60  if isinstance(v,list):
61  v = "list(%d)"%len(v)
62  if isinstance(v,dict):
63  v = "dict(%d)"%len(v)
64  one = "%s = %s" % (k,v)
65  body.append(one)
66  body = r"\n".join(body)
67  body = r"{%s}" % body
68  ret.append(body)
69 
70  if "tail" in self.ports:
71  tail = "{%s}" % ("|".join(["<out%d>%d"%(num,num) for num in sorted(self.ports["tail"])]),)
72  ret.append(tail)
73 
74  return "{%s}" % ("|".join(ret),)
75 
76 
def display_name(self)
Definition: main.py:38
def dot_label(self)
Definition: main.py:52
def wirecell.pgraph.main.Node.dot_name (   self,
  port = None 
)

Definition at line 49 of file main.py.

49  def dot_name(self, port=None):
50  return self.tn.replace(":","_")
51 
def dot_name(self, port=None)
Definition: main.py:49

Member Data Documentation

wirecell.pgraph.main.Node.attrs

Definition at line 35 of file main.py.

wirecell.pgraph.main.Node.name

Definition at line 31 of file main.py.

wirecell.pgraph.main.Node.ports

Definition at line 34 of file main.py.

wirecell.pgraph.main.Node.tn

Definition at line 27 of file main.py.

wirecell.pgraph.main.Node.type

Definition at line 29 of file main.py.


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