Beispiel #1
0
 def filter(self, ast):
     id_node = None
     try:
         af = IDFilter(id = self.old)
         id_node = af.apply(ast)
     except NodeNotFound:
         # Try to recover looking for No ID name attribute
         af = StrFilter(id = self.old)
         id_node = af.apply(ast)
         return id_node
         # Otherwise , raise exception and stop
     return id_node
Beispiel #2
0
    def filter_iterator(self, ast):
        id_node = None
        af = IDFilter(id = self.old)
#~        print " IDNameMutator iterator ast: " + str(ast) + "Looking for : " + str(self.old.name)
        try:
            for id_node in af.iterate(ast):
#~                print "ID Node : " + str(id_node)
                yield id_node
            else:
                af = StrFilter(id = self.old)
                for id_node in af.iterate(ast):
#~                    print "Str Node  : " + str(id_node)
                    yield id_node
                # Otherwise , raise exception and stop
                raise StopIteration
        except NodeNotFound:
            # Try to recover looking for No ID name attribute
            af = StrFilter(id = self.old)
            for id_node in af.iterate(ast):
                yield id_node
            # Otherwise , raise exception and stop
            raise StopIteration

        print " You shouldn't see this "