rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
oracle.set_value(image_fd.urn, pyaff4.AFF4_STORED, zip_fd.urn)
oracle.set_value(image_fd.urn, pyaff4.AFF4_STORED, zip_urn)
def image(output_URI, options, fds): """ Copy the file like objects specified in the fds list into an output volume specified by its URI. """ out_fd = oracle.open(output_URI, 'w') ## A file urn was specified if isinstance(out_fd, pyaff4.FileLikeObject): out_fd.cache_return() ## Make a volume object zip_fd = oracle.cre...
def parse(self, filename): self.module.headers += ' self.module.files.append(filename)
def parse_filenames(self, filenames): for f in filenames: self._parse(f) log("Second pass: Consolidating definitions") for f in filenames: self._parse(f) def _parse(self, filename): if filename not in self.module.files: self.module.headers += ' self.module.files.append(filename)
def parse(self, filename): self.module.headers += '#include "%s"\n' % filename self.module.files.append(filename) fd = open(filename) self.parse_fd(fd)
fd.seek(0) self.parse_fd(fd)
fd.close()
def parse(self, filename): self.module.headers += '#include "%s"\n' % filename self.module.files.append(filename) fd = open(filename) self.parse_fd(fd)
Py_INCREF(((Object)wrapped_%(name)s->base)->extension);
Py_INCREF((PyObject *)((Object)wrapped_%(name)s->base)->extension);
def assign(self, call, method, target=None): method.error_set = True; args = dict(name = target or self.name, call = call, type = self.type, incref=INCREF)
def update(self,with,updateToWild=True):
def update(self,with1,updateToWild=True):
def update(self,with,updateToWild=True): """Replace RPN attributes of an instance with RPN attributes from another values not in list of allowed parm keys are ignored also update to wildcard (-1 or '') values unless updateToWild=False
if isinstance(with,RPNParm): for name in with.__dict__.keys():
if isinstance(with1,RPNParm): for name in with1.__dict__.keys():
def update(self,with,updateToWild=True): """Replace RPN attributes of an instance with RPN attributes from another values not in list of allowed parm keys are ignored also update to wildcard (-1 or '') values unless updateToWild=False
or with.__dict__[name] != allowedKeysVals[name]): self.__dict__[name]=with.__dict__[name]
or with1.__dict__[name] != allowedKeysVals[name]): self.__dict__[name]=with1.__dict__[name]
def update(self,with,updateToWild=True): """Replace RPN attributes of an instance with RPN attributes from another values not in list of allowed parm keys are ignored also update to wildcard (-1 or '') values unless updateToWild=False
elif type(with) == type({}): for name in with.keys():
elif type(with1) == type({}): for name in with1.keys():
def update(self,with,updateToWild=True): """Replace RPN attributes of an instance with RPN attributes from another values not in list of allowed parm keys are ignored also update to wildcard (-1 or '') values unless updateToWild=False
or with[name] != allowedKeysVals[name]): setattr(self,name,with[name])
or with1[name] != allowedKeysVals[name]): setattr(self,name,with1[name])
def update(self,with,updateToWild=True): """Replace RPN attributes of an instance with RPN attributes from another values not in list of allowed parm keys are ignored also update to wildcard (-1 or '') values unless updateToWild=False
def update_cond(self,with): """Short form for RPNParm.update(with,False) """ self.update(with,False) def update_by_dict(self,with): """[Deprecated] Equivalent to RPNParm.update(with) """ self.update(with) def update_by_dict_from(self,frm,with):
def update_cond(self,with1): """Short form for RPNParm.update(with1,False) """ self.update(with1,False) def update_by_dict(self,with1): """[Deprecated] Equivalent to RPNParm.update(with1) """ self.update(with1) def update_by_dict_from(self,frm,with1):
def update_cond(self,with): """Short form for RPNParm.update(with,False) """ self.update(with,False)
for name in with.keys():
for name in with1.keys():
def update_by_dict_from(self,frm,with): """TODO: documentation """ for name in with.keys(): if name in self.__dict__.keys(): setattr(self,name,frm.__dict__[name])
xy = (x, edge.node1.xy[1])
xy = (x, edge.node2.xy[1])
def _prepareEdges(self): for edge in self.screen.edges: m = self.metrix.edge(edge) dir = m.direction() if dir == 'right': r = range(edge.node1.xy[0] + 1, edge.node2.xy[0]) for x in r: xy = (x, edge.node1.xy[1]) nodes = [x for x in self.screen.nodes if x.xy == xy] if len(nodes) > 0: edge.skipped = 1 elif dir == 'right-d...
if edge.node1.group: uniq[edge.node1.group] = 1 else: uniq[edge.node1] = 1
uniq[edge.node1] = 1
def getChildren(self, node): node_id = ScreenNode.getId(node)
children = uniq.keys()
children = [] for node in uniq.keys(): if node.group: children.append(node.group) else: children.append(node)
def getChildren(self, node): node_id = ScreenNode.getId(node)
if value.upper() == 'LR':
if self.subdiagram and value.upper() == 'LR':
def setAttributes(self, attrs): for attr in attrs: value = re.sub('^"?(.*?)"?$', '\\1', attr.value)
if self.subdiagram == True:
if self.subdiagram:
def setAttributes(self, attrs): for attr in attrs: value = re.sub('^"?(.*?)"?$', '\\1', attr.value)
top = topCenter; bottom = bottomCenter; right = rightCenter; left = leftCenter;
top = topCenter bottom = bottomCenter right = rightCenter left = leftCenter
def rightCenter(self): m = self.metrix x, y = self.topLeft() return XY(x + m.nodeWidth, y + m.nodeHeight / 2)
self.rectangle([metrix.topLeft(), metrix.bottomRight()], outline=self.fill, fill=node.color) else: self.rectangle([metrix.topLeft(), metrix.bottomRight()], outline=self.fill)
self.rectangle(box, outline=self.fill, fill=node.color) else: self.rectangle(box, outline=self.fill)
def screennode(self, node, **kwargs): ttfont = kwargs.get('font')
if self.uniqNodes.in(title):
if title in self.uniqNodes:
def getScreenNode(self, title, xy): if self.uniqNodes.in(title): is_new = 0 node = self.uniqNodes[title] else: is_new = 1 node = ScreenNode(title) node.xy = xy self.uniqNodes[title] = node
scale_bias = 4
def truetypeText(self, xy, string, **kwargs): scale_bias = 4 fill = kwargs.get('fill') font = kwargs.get('font') fontsize = kwargs.get('fontsize', 11)
ttfont = self.setupFont(font, fontsize * scale_bias)
ttfont = self.setupFont(font, fontsize)
def truetypeText(self, xy, string, **kwargs): scale_bias = 4 fill = kwargs.get('fill') font = kwargs.get('font') fontsize = kwargs.get('fontsize', 11)
image = Image.new('RGBA', size)
image = Image.new('1', size, color='
def truetypeText(self, xy, string, **kwargs): scale_bias = 4 fill = kwargs.get('fill') font = kwargs.get('font') fontsize = kwargs.get('fontsize', 11)
draw.text((0, 0), string, fill=fill, font=ttfont)
draw.text((0, 0), string, fill='
def truetypeText(self, xy, string, **kwargs): scale_bias = 4 fill = kwargs.get('fill') font = kwargs.get('font') fontsize = kwargs.get('fontsize', 11)
basesize = (size[0] / scale_bias, size[1] / scale_bias) text_image = image.resize(basesize, Image.ANTIALIAS) self.image.paste(text_image, xy, text_image)
self.image.paste(image, xy)
def truetypeText(self, xy, string, **kwargs): scale_bias = 4 fill = kwargs.get('fill') font = kwargs.get('font') fontsize = kwargs.get('fontsize', 11)
if node.id in drawn:
if node.id in drawn or parent == node:
def setNodeWidth(self, parent, node, drawn=[]): if node.id in drawn: return
height = self.setNodeHeight(childnode, height, references)
def setNodeHeight(self, node, height, references=[]): node.xy = (node.xy[0], height) if node.id in self.linkForward: for child_id in self.getChildrenIds(node): if not child_id in references: childnode = self.getScreenNode(child_id) references.append(child_id) height = self.setNodeHeight(childnode, height, references) e...
height += 1
if not node.id in references: height += 1
def setNodeHeight(self, node, height, references=[]): node.xy = (node.xy[0], height) if node.id in self.linkForward: for child_id in self.getChildrenIds(node): if not child_id in references: childnode = self.getScreenNode(child_id) references.append(child_id) height = self.setNodeHeight(childnode, height, references) e...
height += self.setNodeHeight(node, height)
height = self.setNodeHeight(node, height)
def buildNodeList(self, tree): for stmt in tree.stmts: if isinstance(stmt, diagparser.Node): node = self.getScreenNode(stmt.id) node.setAttributes(stmt.attrs) elif isinstance(stmt, diagparser.Edge): while len(stmt.nodes) >= 2: self.getScreenEdge(stmt.nodes.pop(0), stmt.nodes[0]) else: raise
if isinstance(node, NodeGroup):
if isinstance(node, NodeGroup) and not self.separate:
def buildNodeList(self, tree): nodeGroups = {} for stmt in tree.stmts: if isinstance(stmt, diagparser.Node): node = self.getDiagramNode(stmt.id) node.setAttributes(stmt.attrs) elif isinstance(stmt, diagparser.Edge): while len(stmt.nodes) >= 2: edge = self.getDiagramEdge(stmt.nodes.pop(0), stmt.nodes[0]) edge.setAttribu...
print m.box()
def screennode(self, node, **kwargs): ttfont = kwargs.get('font')
self.rankdir = None
def __init__(self): self.nodes = [] self.edges = [] self.color = None self.rankdir = None
self.xy = XY(0, 0)
def __init__(self, id): self.id = id if id: self.label = re.sub('^"?(.*?)"?$', '\\1', id) else: self.label = '' self.xy = XY(0, 0) self.color = (255, 255, 255) self.style = None self.group = None self.numbered = None self.background = None self.width = 1 self.height = 1 self.drawable = 1
self.group = None
def __init__(self, id): self.id = id if id: self.label = re.sub('^"?(.*?)"?$', '\\1', id) else: self.label = '' self.xy = XY(0, 0) self.color = (255, 255, 255) self.style = None self.group = None self.numbered = None self.background = None self.width = 1 self.height = 1 self.drawable = 1
self.drawable = 1
def __init__(self, id): self.id = id if id: self.label = re.sub('^"?(.*?)"?$', '\\1', id) else: self.label = '' self.xy = XY(0, 0) self.color = (255, 255, 255) self.style = None self.group = None self.numbered = None self.background = None self.width = 1 self.height = 1 self.drawable = 1
if other.width: self.width = other.width if other.height: self.height = other.height if other.xy: self.xy = other.xy
def copyAttributes(self, other): if other.label: self.label = other.label if other.width: self.width = other.width if other.height: self.height = other.height if other.xy: self.xy = other.xy if other.color: self.color = other.color if other.style: self.style = other.style if other.numbered: self.numbered = other.number...
elif attr.name == 'background': if os.path.isfile(value): self.background = value else: msg = "WARNING: background image not found: %s\n" % value sys.stderr.write(msg) elif attr.name == 'numbered': self.numbered = value
def setAttributes(self, attrs): for attr in attrs: value = re.sub('^"?(.*?)"?$', '\\1', attr.value) if attr.name == 'label': self.label = value elif attr.name == 'color': self.color = value elif attr.name == 'style': style = value.lower() if style in ('solid', 'dotted', 'dashed'): self.style = style else: msg = "WARNIN...
self.group = None
self.crosspoints = [] self.skipped = 0 self.dir = 'forward'
def __init__(self, node1, node2): self.node1 = node1 self.node2 = node2 self.circular = False self.group = None self.color = None self.style = None self.noweight = None self.skipped = 0 self.crosspoints = [] self.dir = 'forward'
self.skipped = 0 self.crosspoints = [] self.dir = 'forward'
def __init__(self, node1, node2): self.node1 = node1 self.node2 = node2 self.circular = False self.group = None self.color = None self.style = None self.noweight = None self.skipped = 0 self.crosspoints = [] self.dir = 'forward'
if other.dir: self.dir = other.dir if other.style: self.style = other.style
def copyAttributes(self, other): if other.color: self.color = other.color if other.noweight: self.noweight = other.noweight if other.dir: self.dir = other.dir if other.style: self.style = other.style
if attr.name == 'color': self.color = value elif attr.name == 'dir':
if attr.name == 'dir':
def setAttributes(self, attrs): for attr in attrs: value = re.sub('^"?(.*?)"?$', '\\1', attr.value) if attr.name == 'color': self.color = value elif attr.name == 'dir': dir = value.lower() if dir in ('back', 'both', 'none', 'forward'): self.dir = dir else: msg = "WARNING: unknown edge dir: %s\n" % dir sys.stderr.write(...
elif attr.name == 'style': style = value.lower() if style in ('solid', 'dotted', 'dashed'): self.style = style else: msg = "WARNING: unknown edge style: %s\n" % style sys.stderr.write(msg)
def setAttributes(self, attrs): for attr in attrs: value = re.sub('^"?(.*?)"?$', '\\1', attr.value) if attr.name == 'color': self.color = value elif attr.name == 'dir': dir = value.lower() if dir in ('back', 'both', 'none', 'forward'): self.dir = dir else: msg = "WARNING: unknown edge dir: %s\n" % dir sys.stderr.write(...
nodelist.height = height
nodelist.height = height - self.cellSize * 2
def screennodelist(self, nodelist, **kwargs): height = 0
nodes = [x.id for x in tree.stmts if isinstance(x, diagparser.Node)]
def picknodes(tree, list): for node in tree.stmts: if isinstance(node, diagparser.Node): list.append(node.id) elif isinstance(node, diagparser.SubGraph): picknodes(node, list) return list nodes = picknodes(tree, [])
def buildNodeGroup(self, group, tree): nodes = [x.id for x in tree.stmts if isinstance(x, diagparser.Node)] for edge in self.uniqLinks.values(): node1_id = edge.node1.id node2_id = edge.node2.id
if font is None: ImageDraw.ImageDraw.text(self, xy, string, fill=fill, font=ttfont)
if ttfont is None: if scale == 1: ImageDraw.ImageDraw.text(self, xy, string, fill=fill) else: size = self.textsize(string) image = Image.new('RGBA', size) draw = ImageDraw.Draw(image) draw.text((0, 0), string, fill=fill) del draw basesize = (size[0] * 2, size[1] * 2) text_image = image.resize(basesize, Image.ANTIALIAS...
def truetypeText(self, xy, string, **kwargs): fill = kwargs.get('fill') font = kwargs.get('font') fontsize = kwargs.get('fontsize', 11) ttfont = self.setupFont(font, fontsize)
fill = kwargs.get('fill')
def text(self, box, string, **kwargs): font = kwargs.get('font') fontsize = kwargs.get('fontsize', 11) fill = kwargs.get('fill') ttfont = self.setupFont(font, fontsize)
x = int(math.ceil((size[0] - textsize[0]) / 2.0))
if ttfont: x = int(math.ceil((size[0] - textsize[0]) / 2.0)) else: x = int(math.ceil((size[0] - textsize[0] * scale) / 2.0))
def text(self, box, string, **kwargs): font = kwargs.get('font') fontsize = kwargs.get('fontsize', 11) fill = kwargs.get('fill') ttfont = self.setupFont(font, fontsize)
self.truetypeText(draw_xy, string, fill=fill,
self.truetypeText(draw_xy, string, fill=fill, scale=scale,
def text(self, box, string, **kwargs): font = kwargs.get('font') fontsize = kwargs.get('fontsize', 11) fill = kwargs.get('fill') ttfont = self.setupFont(font, fontsize)
fill=self.fill, font=self.font, fontsize=fontsize, lineSpacing=lineSpacing)
fill=self.fill, scale=self._scale, font=self.font, fontsize=fontsize, lineSpacing=lineSpacing)
def screennode(self, node, **kwargs): m = self.metrix.node(node)
font=self.font, fontsize=fontsize)
scale=self._scale, font=self.font, fontsize=fontsize)
def screennode(self, node, **kwargs): m = self.metrix.node(node)
self.label = other.label self.width = other.width self.height = other.height self.xy = other.xy self.color = other.color self.numbered = other.numbered self.background = other.background
if other.label: self.label = other.label if other.width: self.width = other.width if other.height: self.height = other.height if other.xy: self.xy = other.xy if other.color: self.color = other.color if other.numbered: self.numbered = other.numbered if other.background: self.background = other.background
def copyAttributes(self, other): self.label = other.label self.width = other.width self.height = other.height self.xy = other.xy self.color = other.color self.numbered = other.numbered self.background = other.background
height += size[1] + lineSpacing
height += textsize[1] + lineSpacing
def text(self, box, string, **kwargs): ttfont = kwargs.get('font') lineSpacing = kwargs.get('lineSpacing', 2) size = (box[2] - box[0], box[3] - box[1])
if not node.id in references:
if not node.id in refs:
def setNodeHeight(self, node, height, refs=[]): node.xy = (node.xy[0], height) if node.id in self.linkForward: for child_id in self.getChildrenIds(node): if not child_id in refs: childnode = self.getScreenNode(child_id)
self.rows += 1
def buildNodeList(self, parent, list, columns=0): for node in list: if isinstance(node, dict): for key in node.keys(): screennode, is_new = self.getScreenNode(key, (columns, self.rows))
if is_new: self.rows += 1
self.rows += 1
def buildNodeList(self, parent, list, columns=0): for node in list: if isinstance(node, dict): for key in node.keys(): screennode, is_new = self.getScreenNode(key, (columns, self.rows))
self.rows -= 1
def buildNodeList(self, parent, list, columns=0): for node in list: if isinstance(node, dict): for key in node.keys(): screennode, is_new = self.getScreenNode(key, (columns, self.rows))
nodelist.width = self.nodeWidth
if width < node._width(): width = node._width() nodelist.width = width
def screennodelist(self, nodelist, **kwargs): height = 0
self.rectangle([draw_xy, bottom_right], outline=self.fill)
self.rectangle([top_left, bottom_right], outline=self.fill)
def screennode(self, node, **kwargs): ttfont = kwargs.get('font')
f.write(str(self.text))
f.write(self.text.encode('utf-8'))
def toXml(self,level,f): f.write('\t'*level) f.write('<'+self.type) for attkey in self.attributes.keys(): f.write(' '+_escape(str(attkey))+'='+_quoteattr(str(self.attributes[attkey]))) if self.namespace: f.write(' xmlns="'+ _escape(str(self.namespace))+'" ') if hasattr(self, 'namespaces') and self.namespaces: for ns in...
if other.label:
if other.label and other.id != other.label:
def copyAttributes(self, other): if other.xy: self.xy = other.xy if other.label: self.label = other.label if other.color: self.color = other.color if other.style: self.style = other.style if other.numbered: self.numbered = other.numbered if other.background: self.background = other.background if other.description: self...
self.pageMargin = self.cellSize * kwargs.get('pageMargin', 3)
def __init__(self, diagram, **kwargs): self.cellSize = kwargs.get('cellSize', 8) self.nodePadding = kwargs.get('nodePadding', 4) self.lineSpacing = kwargs.get('lineSpacing', 2) self.shadowOffsetY = kwargs.get('shadowOffsetY', 6) self.shadowOffsetX = kwargs.get('shadowOffsetX', 3) self.fontSize = kwargs.get('fontSize', ...
return XY(xy.x + self.pageMargin, xy.y + self.pageMargin)
return XY(xy.x + self.pageMargin.x, xy.y + self.pageMargin.y)
def pageSize(self, nodelist): x = 0 y = 0 for node in nodelist: if x <= node.xy.x: x = node.xy.x if y <= node.xy.y: y = node.xy.y
self.x = metrix.pageMargin + \
self.x = metrix.pageMargin.x + \
def __init__(self, node, metrix): self.metrix = metrix self.width = node.width self.height = node.height
self.y = metrix.pageMargin + \
self.y = metrix.pageMargin.y + \
def __init__(self, node, metrix): self.metrix = metrix self.width = node.width self.height = node.height
children = []
parents = []
def getChildren(self, node): node_id = DiagramNode.getId(node)
children.append(node.group) else: children.append(node) children.sort(lambda x, y: cmp(x.order, y.order)) return children
parents.append(node.group) else: parents.append(node) parents.sort(lambda x, y: cmp(x.order, y.order)) return parents
def getChildren(self, node): node_id = DiagramNode.getId(node)
if isinstance(node, NodeGroup) and node.nodes: idx = min(self.nodeOrder.index(n) for n in node.nodes) if idx < self.nodeOrder.index(node): self.nodeOrder.remove(node) self.nodeOrder.insert(idx + 1, node)
if isinstance(node, NodeGroup): nodes = [n for n in node.nodes if n in self.nodeOrder] if nodes: idx = min(self.nodeOrder.index(n) for n in nodes) if idx < self.nodeOrder.index(node): self.nodeOrder.remove(node) self.nodeOrder.insert(idx + 1, node)
def adjustNodeOrder(self): for node in self.nodeOrder: parents = self.getParents(node) if len(set(parents)) > 1: for i in range(1, len(parents)): idx1 = self.nodeOrder.index(parents[i - 1]) idx2 = self.nodeOrder.index(parents[i]) if idx1 < idx2: self.nodeOrder.remove(parents[i]) self.nodeOrder.insert(idx1 + 1, parents[...
if isinstance(child, NodeGroup): child.fixiate_group_coordinates()
def fixiate_group_coordinates(self): for child in self.nodes: if child.group: child.xy = XY(self.xy.x + child.xy.x, self.xy.y + child.xy.y)
if y: self.append((x, y))
if y is None: self.append(x)
def add(self, x, y=None): if y: self.append((x, y)) else: self.append(x)
self.append(x)
self.append(XY(x, y))
def add(self, x, y=None): if y: self.append((x, y)) else: self.append(x)
p = XY(crosspoint.x - self.cellSize / 2, crosspoint.y)
p = XY(crosspoint.x - jump_width, crosspoint.y)
def lineTo(self, x, y=None): if y is None: elem = x else: elem = XY(x, y)
p = XY(crosspoint.x + self.cellSize / 2, crosspoint.y)
p = XY(crosspoint.x + jump_width, crosspoint.y)
def lineTo(self, x, y=None): if y is None: elem = x else: elem = XY(x, y)
" foo;\n"
" A;\n"
def test_single_node_diagram(): # empty diagram str = ("diagram {\n" " foo;\n" "}\n") tree = parse(tokenize(str)) nodelist, edgelist = ScreenNodeBuilder.build(tree) assert len(nodelist) == 1 assert len(edgelist) == 0 assert nodelist[0].label == 'foo' assert nodelist[0].xy == (0, 0)
assert nodelist[0].label == 'foo'
assert nodelist[0].label == 'A'
def test_single_node_diagram(): # empty diagram str = ("diagram {\n" " foo;\n" "}\n") tree = parse(tokenize(str)) nodelist, edgelist = ScreenNodeBuilder.build(tree) assert len(nodelist) == 1 assert len(edgelist) == 0 assert nodelist[0].label == 'foo' assert nodelist[0].xy == (0, 0)
" foo -> bar;\n"
" A -> B;\n"
def test_single_edge_diagram(): # empty diagram str = ("diagram {\n" " foo -> bar;\n" "}\n") tree = parse(tokenize(str)) nodelist, edgelist = ScreenNodeBuilder.build(tree) assert len(nodelist) == 2 assert len(edgelist) == 1 assert nodelist[0].label == 'foo' assert nodelist[0].xy == (0, 0) assert nodelist[1].label == ...
assert nodelist[0].label == 'foo' assert nodelist[0].xy == (0, 0) assert nodelist[1].label == 'bar' assert nodelist[1].xy == (1, 0) assert edgelist[0].node1.id == 'foo' assert edgelist[0].node2.id == 'bar'
assert nodelist[0].label == 'A' assert nodelist[1].label == 'B' assert_pos = {'A': (0, 0), 'B': (1, 0)} assert_label = {'A': 'A', 'B': 'B'} for node in nodelist: assert node.xy == assert_pos[node.id] assert node.label == assert_label[node.id]
def test_single_edge_diagram(): # empty diagram str = ("diagram {\n" " foo -> bar;\n" "}\n") tree = parse(tokenize(str)) nodelist, edgelist = ScreenNodeBuilder.build(tree) assert len(nodelist) == 2 assert len(edgelist) == 1 assert nodelist[0].label == 'foo' assert nodelist[0].xy == (0, 0) assert nodelist[1].label == ...
" foo -> bar -> baz;\n"
" A -> B -> C;\n"
def test_two_edges_diagram(): # empty diagram str = ("diagram {\n" " foo -> bar -> baz;\n" "}\n") tree = parse(tokenize(str)) nodelist, edgelist = ScreenNodeBuilder.build(tree) assert len(nodelist) == 3 assert len(edgelist) == 2 assert_pos = {'foo': (0, 0), 'bar': (1, 0), 'baz': (2, 0)} for node in nodelist: assert ...
assert_pos = {'foo': (0, 0), 'bar': (1, 0), 'baz': (2, 0)}
assert_pos = {'A': (0, 0), 'B': (1, 0), 'C': (2, 0)}
def test_two_edges_diagram(): # empty diagram str = ("diagram {\n" " foo -> bar -> baz;\n" "}\n") tree = parse(tokenize(str)) nodelist, edgelist = ScreenNodeBuilder.build(tree) assert len(nodelist) == 3 assert len(edgelist) == 2 assert_pos = {'foo': (0, 0), 'bar': (1, 0), 'baz': (2, 0)} for node in nodelist: assert ...
" foo -> bar -> baz [color = red]\n" " hoge -> fuga [dir = none]\n" "}\n") tree = parse(tokenize(str)) nodelist, edgelist = ScreenNodeBuilder.build(tree) assert_pos = {'foo': (0, 0), 'bar': (1, 0), 'baz': (2, 0), 'hoge': (0, 1), 'fuga': (1, 1)}
" A -> B -> C [color = red]\n" " D -> E [dir = none]\n" "}\n") tree = parse(tokenize(str)) nodelist, edgelist = ScreenNodeBuilder.build(tree) assert_pos = {'A': (0, 0), 'B': (1, 0), 'C': (2, 0), 'D': (0, 1), 'E': (1, 1)}
def test_edge_attribute(): # empty diagram str = ("diagram {\n" " foo -> bar -> baz [color = red]\n" " hoge -> fuga [dir = none]\n" "}\n") tree = parse(tokenize(str)) nodelist, edgelist = ScreenNodeBuilder.build(tree) assert_pos = {'foo': (0, 0), 'bar': (1, 0), 'baz': (2, 0), 'hoge': (0, 1), 'fuga': (1, 1)} for node...
if edge.node1.id == 'hoge':
if edge.node1.id == 'D':
def test_edge_attribute(): # empty diagram str = ("diagram {\n" " foo -> bar -> baz [color = red]\n" " hoge -> fuga [dir = none]\n" "}\n") tree = parse(tokenize(str)) nodelist, edgelist = ScreenNodeBuilder.build(tree) assert_pos = {'foo': (0, 0), 'bar': (1, 0), 'baz': (2, 0), 'hoge': (0, 1), 'fuga': (1, 1)} for node...
print style
def line(self, xy, **kwargs): fill = kwargs.get('fill') style = kwargs.get('style')
elif node1.x == node2.y: if node1.y < node2.y:
elif node1.x == node2.x: if node1.y > node2.y:
def direction(self): node1 = self.metrix.node(self.edge.node1) node2 = self.metrix.node(self.edge.node2)
self.append(x)
elem = x
def add(self, x, y=None): if y is None: self.append(x) else: self.append(XY(x, y))
self.append(XY(x, y))
elem = XY(x, y) if len(self) == 0: self.append(elem) elif self[-1] != elem: self.append(elem)
def add(self, x, y=None): if y is None: self.append(x) else: self.append(XY(x, y))
self.spanWidth = kwargs.get('spanWidth', 5) self.spanHeight = kwargs.get('spanHeight', 2)
self.spanColumns = kwargs.get('spanColumns', 5) self.spanRows = kwargs.get('spanRows', 2)
def __init__(self, im, mode=None, **kwargs): self.nodeColumns = kwargs.get('nodeColumns', 8) self.nodeRows = kwargs.get('nodeRows', 4) self.lineSpacing = kwargs.get('lineSpacing', 2) self.nodePadding = kwargs.get('nodePadding', 2) self.cellSize = kwargs.get('cellSize', 16) self.spanWidth = kwargs.get('spanWidth', 5) se...
size = self.textsize(truncated, font=ttfont) if size[0] <= size[0]:
metrics = self.textsize(truncated, font=ttfont) if metrics[0] <= size[0]:
def _getFoldedText(self, size, string, **kwargs): ttfont = kwargs.get('font') lineSpacing = kwargs.get('lineSpacing', 2) lines = []
def __init__(self, scale, **kwargs):
def __init__(self, diagram, scale, **kwargs):
def __init__(self, scale, **kwargs): self.scale_ratio = scale self.metrix = DiagramMetrix(**kwargs)
self.metrix = DiagramMetrix(**kwargs)
self.metrix = DiagramMetrix(diagram, **kwargs)
def __init__(self, scale, **kwargs): self.scale_ratio = scale self.metrix = DiagramMetrix(**kwargs)
height = max(x.xy.y for x in self.nodeOrder) + 1
height = max(xy.y for xy in self.coordinates) + 1
def buildNodeList(self, tree): nodeGroups = {} for stmt in tree.stmts: if isinstance(stmt, diagparser.Node): node = self.getDiagramNode(stmt.id) node.setAttributes(stmt.attrs) elif isinstance(stmt, diagparser.Edge): while len(stmt.nodes) >= 2: edge = self.getDiagramEdge(stmt.nodes.pop(0), stmt.nodes[0]) edge.setAttribu...
node2.top().y - span.y / 2) shaft.lineTo(node2.top().x, node2.top().y - span.y / 2)
node2.top().y - span.y / 2 + span.y / 8) shaft.lineTo(node2.top().x, node2.top().y - span.y / 2 + span.y / 8)
def shaft(self): span = XY(self.metrix.spanWidth, self.metrix.spanHeight) dir = self.direction()
shaft.lineTo(node1.bottom().x, node2.top().y - span.y / 2) shaft.lineTo(node2.top().x, node2.top().y - span.y / 2) shaft.lineTo(node2.top()) elif dir == 'down': if self.edge.skipped: shaft.moveTo(node1.right()) shaft.lineTo(node1.right().x + span.x / 2, node1.right().y) shaft.lineTo(node1.right().x + span.x / 2,
shaft.lineTo(node1.bottom().x,
def shaft(self): span = XY(self.metrix.spanWidth, self.metrix.spanHeight) dir = self.direction()
raise AttributeError, "Unknown node attribute: %s.%s" % (self.id, attr.name)
msg = "Unknown node attribute: %s.%s" % (self.id, attr.name) raise AttributeError, msg
def setAttributes(self, attrs): for attr in attrs: value = re.sub('^"?(.*?)"?$', '\\1', attr.value) if attr.name == 'label': self.label = value elif attr.name == 'color': self.color = value else: raise AttributeError, "Unknown node attribute: %s.%s" % (self.id, attr.name)
def setNodeHeight(self, node, height, references=[]):
def setNodeHeight(self, node, height, refs=[]):
def setNodeHeight(self, node, height, references=[]): node.xy = (node.xy[0], height) if node.id in self.linkForward: for child_id in self.getChildrenIds(node): if not child_id in references: childnode = self.getScreenNode(child_id)
if not child_id in references:
if not child_id in refs:
def setNodeHeight(self, node, height, references=[]): node.xy = (node.xy[0], height) if node.id in self.linkForward: for child_id in self.getChildrenIds(node): if not child_id in references: childnode = self.getScreenNode(child_id)
height = self.setNodeHeight(childnode, height, references)
height = self.setNodeHeight(childnode, height, refs)
def setNodeHeight(self, node, height, references=[]): node.xy = (node.xy[0], height) if node.id in self.linkForward: for child_id in self.getChildrenIds(node): if not child_id in references: childnode = self.getScreenNode(child_id)
references.append(child_id)
refs.append(child_id)
def setNodeHeight(self, node, height, references=[]): node.xy = (node.xy[0], height) if node.id in self.linkForward: for child_id in self.getChildrenIds(node): if not child_id in references: childnode = self.getScreenNode(child_id)
value = re.sub('^"?(.*?)"?$', '\\1', attr.value)
value = re.sub('(\A"|"\Z)', '', attr.value, re.M)
def setAttributes(self, attrs): for attr in attrs: value = re.sub('^"?(.*?)"?$', '\\1', attr.value)
self.label = re.sub('^"?(.*?)"?$', '\\1', id)
self.label = re.sub('(\A"|"\Z)', '', id, re.M)
def __init__(self, id): self.id = id self.xy = XY(0, 0) self.group = None self.drawable = 1
value = re.sub('^"?(.*?)"?$', '\\1', attr.value)
value = re.sub('(\A"|"\Z)', '', attr.value, re.M)
def setAttributes(self, attrs): for attr in attrs: value = re.sub('^"?(.*?)"?$', '\\1', attr.value) if attr.name == 'label': self.label = value elif attr.name == 'color': self.color = value elif attr.name == 'style': style = value.lower() if style in ('solid', 'dotted', 'dashed'): self.style = style else: msg = "WARNIN...
value = re.sub('^"?(.*?)"?$', '\\1', attr.value)
value = re.sub('(\A"|"\Z)', '', attr.value, re.M)
def setAttributes(self, attrs): for attr in attrs: value = re.sub('^"?(.*?)"?$', '\\1', attr.value) if attr.name == 'label': self.label = value elif attr.name == 'dir': dir = value.lower() if dir in ('back', 'both', 'none', 'forward'): self.dir = dir else: msg = "WARNING: unknown edge dir: %s\n" % dir sys.stderr.write(...
if not is_tail and is_ref and self.isCircularRef(node_id, child):
if is_ref and self.isCircularRef(node_id, child):
def setNodeWidth(self, node=None): node_id = ScreenNode.getId(node)