def _set_i_aug(self, ctx, stmt): """ inject bool 'i_augment' to top statement for model being augmented""" i_target_node = None if hasattr(stmt, 'i_target_node'): i_target_node = stmt.i_target_node else: i_target_node = statements.find_target_node(ctx, stmt, is_augment=True) if i_target_node is not None: if hasattr(stmt.top , 'i_aug_targets'): stmt.top.i_aug_targets.add(i_target_node.top) else: stmt.top.i_aug_targets = set([i_target_node.top]) i_target_node.top.is_augmented_module = True
def _set_i_aug(self, ctx, stmt): """ inject bool 'i_augment' to top statement for model being augmented""" i_target_node = None if hasattr(stmt, 'i_target_node'): i_target_node = stmt.i_target_node else: i_target_node = statements.find_target_node(ctx, stmt, is_augment=True) if i_target_node is not None: if hasattr(stmt.top , 'i_aug_targets'): stmt.top.i_aug_targets.add(i_target_node.top) else: stmt.top.i_aug_targets = set([i_target_node.top]) i_target_node.top.is_augmented_module = True
def emit_stmt(self, mod, stmt, fd): # find good UML roots if stmt.keyword == 'container': self.emit_container(mod, stmt, fd) for s in stmt.substmts: self.emit_child_stmt(stmt, s, fd) elif stmt.keyword == 'augment' and (not self.ctx_filterfile): # HERE a = stmt.arg if self.ctx_truncate_augments: a = '...' + a[a.rfind('/'):] if not self.ctx_inline_augments: fd.write('class \"%s\" as %s << (A,CadetBlue) augment>>\n' % (a, self.full_path(stmt))) # ugly, the augmented elemented is suffixed with _ in emit_header # fd.write('_%s <-- %s : augment \n' %(self.full_path(stmt), self.full_path(stmt))) # also, since we are the root, add the module as parent if (not (self.full_path(stmt)) in self.augmentpaths) and (not self.ctx_inline_augments): fd.write('%s *-- %s \n' % (self.full_path(mod), self.full_path(stmt))) self.augmentpaths.append(self.full_path(stmt)) # MEF if stmt.arg.find(':') == -1: prefix = self.thismod_prefix else: prefix = stmt.arg[1:stmt.arg.find(':')] node = find_target_node(self._ctx, stmt, True) if node is not None and prefix in self.module_prefixes and not self.ctx_inline_augments: # sys.stderr.write("Found augment target : %s , %s \n" %(stmt.arg, self.full_path(node))) self.augments.append( self.full_path(stmt) + '-->' + self.full_path(node) + ' : augments' + '\n') else: # sys.stderr.write("Not Found augment target : %s \n" %(stmt.arg)) pass if self.ctx_inline_augments and node is not None: # Emit augment target, in case that module was given as input this results in duplicate, but plantUML do not care # The False flag stops emit_child from continuing iterating further down the tree self.emit_child_stmt(node.parent, node, fd, False) for s in stmt.substmts: s.parent = node self.emit_child_stmt(node, s, fd) else: for s in stmt.substmts: self.emit_child_stmt(stmt, s, fd) elif stmt.keyword == 'list': self.emit_list(mod, stmt, fd) for s in stmt.substmts: self.emit_child_stmt(stmt, s, fd) elif stmt.keyword == 'grouping' and not self._ctx.opts.uml_inline: self.emit_grouping(mod, stmt, fd, True) elif stmt.keyword == 'choice': if (not self.ctx_filterfile): fd.write('class \"%s\" as %s <<choice>> \n' % (self.full_display_path(stmt), self.full_path(stmt))) fd.write('%s .. %s : choice \n' % (self.full_path(mod), self.full_path(stmt))) # sys.stderr.write('in choice %s \n', self.full_path(mod)) for children in stmt.substmts: self.emit_child_stmt(stmt, children, fd) elif stmt.keyword == 'case': if (not self.ctx_filterfile): fd.write('class \"%s\" as %s \n' % (self.full_display_path(stmt), self.full_path(stmt))) fd.write('%s .. %s : choice\n' % (self.full_path(mod), self.full_path(stmt))) # sys.stderr.write('in case %s \n', full_path(mod)) for children in mod.substmts: self.emit_child_stmt(stmt, children, fd) elif stmt.keyword == 'identity': self.emit_identity(mod, stmt, fd) if (not self.ctx_classesonly) and (not self.ctx_filterfile): if stmt.keyword == 'typedef': self.emit_typedef(mod, stmt, fd) elif stmt.keyword == 'rpc': self.emit_action(mod, stmt, fd) elif stmt.keyword == 'notification': self.emit_notif(mod, stmt, fd) elif stmt.keyword == 'feature': self.emit_feature(mod, stmt, fd) elif stmt.keyword == 'deviation': self.emit_feature(mod, stmt, fd)
def emit_stmt(self, mod, stmt, fd): # find good UML roots if stmt.keyword == 'container': self.emit_container(mod, stmt, fd) for s in stmt.substmts: self.emit_child_stmt(stmt, s, fd) elif stmt.keyword == 'augment' and (not self.ctx_filterfile): # HERE a = stmt.arg if self.ctx_truncate_augments: a = '...' + a[a.rfind('/'):] if not self.ctx_inline_augments: fd.write('class \"%s\" as %s << (A,CadetBlue) augment>>\n' %(a, self.full_path(stmt))) # ugly, the augmented elemented is suffixed with _ in emit_header # fd.write('_%s <-- %s : augment \n' %(self.full_path(stmt), self.full_path(stmt))) # also, since we are the root, add the module as parent if (not (self.full_path(stmt)) in self.augmentpaths) and (not self.ctx_inline_augments): fd.write('%s *-- %s \n' %(self.full_path(mod), self.full_path(stmt))) self.augmentpaths.append(self.full_path(stmt)) # MEF if stmt.arg.find(':') == -1: prefix = self.thismod_prefix else: prefix = stmt.arg[1:stmt.arg.find(':')] node = find_target_node(self._ctx, stmt, True) if node is not None and prefix in self.module_prefixes and not self.ctx_inline_augments: # sys.stderr.write("Found augment target : %s , %s \n" %(stmt.arg, self.full_path(node))) self.augments.append(self.full_path(stmt) + '-->' + self.full_path(node) + ' : augments' + '\n') else: # sys.stderr.write("Not Found augment target : %s \n" %(stmt.arg)) pass if self.ctx_inline_augments and node is not None: # Emit augment target, in case that module was given as input this results in duplicate, but plantUML do not care # The False flag stops emit_child from continuing iterating further down the tree self.emit_child_stmt(node.parent, node, fd, False) for s in stmt.substmts: s.parent = node self.emit_child_stmt(node, s, fd) else: for s in stmt.substmts: self.emit_child_stmt(stmt, s, fd) elif stmt.keyword == 'list': self.emit_list(mod, stmt, fd) for s in stmt.substmts: self.emit_child_stmt(stmt, s, fd) elif stmt.keyword == 'grouping' and not self._ctx.opts.uml_inline: self.emit_grouping(mod, stmt, fd, True) elif stmt.keyword == 'choice': if (not self.ctx_filterfile): fd.write('class \"%s\" as %s <<choice>> \n' % (self.full_display_path(stmt), self.full_path(stmt))) fd.write('%s .. %s : choice \n' % (self.full_path(mod), self.full_path(stmt))) # sys.stderr.write('in choice %s \n', self.full_path(mod)) for children in stmt.substmts: self.emit_child_stmt(stmt, children, fd) elif stmt.keyword == 'case': if (not self.ctx_filterfile): fd.write('class \"%s\" as %s \n' %(self.full_display_path(stmt), self.full_path(stmt))) fd.write('%s .. %s : choice\n' % (self.full_path(mod), self.full_path(stmt))) # sys.stderr.write('in case %s \n', full_path(mod)) for children in mod.substmts: self.emit_child_stmt(stmt, children, fd) elif stmt.keyword == 'identity': self.emit_identity(mod, stmt, fd) if (not self.ctx_classesonly) and (not self.ctx_filterfile): if stmt.keyword == 'typedef': self.emit_typedef(mod, stmt,fd) elif stmt.keyword == 'rpc': self.emit_action(mod, stmt,fd) elif stmt.keyword == 'notification': self.emit_notif(mod, stmt,fd) elif stmt.keyword == 'feature': self.emit_feature(mod,stmt, fd) elif stmt.keyword == 'deviation': self.emit_feature(mod,stmt, fd)