def visit_slice(self, node, parent): """visit a Slice node by returning a fresh instance of it""" newnode = new.Slice() _lineno_parent(node, newnode, parent) newnode.lower = self.visit(node.lower, newnode) newnode.upper = self.visit(node.upper, newnode) newnode.step = self.visit(node.step, newnode) newnode.set_line_info(newnode.last_child()) return newnode
def visit_sliceobj(self, node, parent, slice=False): """visit a Slice or Sliceobj; transform Sliceobj into a astng.Slice""" newnode = new.Slice() self._set_infos(node, newnode, parent) if slice: subs = [node.lower, node.upper, None] else: subs = node.nodes if len(subs) == 2: subs.append(None) newnode.lower = self.visit(_filter_none(subs[0]), newnode) newnode.upper = self.visit(_filter_none(subs[1]), newnode) newnode.step = self.visit(_filter_none(subs[2]), newnode) return newnode