Ejemplo n.º 1
0
 def _make_pattern(self):
     params = self.pyfunction.get_param_names()
     body = self._get_body()
     body = restructure.replace(body, "return", "pass")
     wildcards = list(params)
     wildcards.extend(self._find_temps())
     if self._does_return():
         if self._is_expression():
             replacement = "${%s}" % self._rope_returned
         else:
             replacement = "%s = ${%s}" % (self._rope_result, self._rope_returned)
         body = restructure.replace(body, "return ${%s}" % self._rope_returned, replacement)
         wildcards.append(self._rope_result)
     return similarfinder.make_pattern(body, wildcards)
Ejemplo n.º 2
0
 def _make_pattern(self):
     params = self.pyfunction.get_param_names()
     body = self._get_body()
     body = restructure.replace(body, "return", "pass")
     wildcards = list(params)
     wildcards.extend(self._find_temps())
     if self._does_return():
         if self._is_expression():
             replacement = "${%s}" % self._rope_returned
         else:
             replacement = "%s = ${%s}" % (self._rope_result,
                                           self._rope_returned)
         body = restructure.replace(body,
                                    "return ${%s}" % self._rope_returned,
                                    replacement)
         wildcards.append(self._rope_result)
     return similarfinder.make_pattern(body, wildcards)
Ejemplo n.º 3
0
 def _does_return(self):
     body = self._get_body()
     removed_return = restructure.replace(body, "return ${result}", "")
     return removed_return != body
Ejemplo n.º 4
0
 def _does_return(self):
     body = self._get_body()
     removed_return = restructure.replace(body, 'return ${result}', '')
     return removed_return != body