Ejemplo n.º 1
0
 def _convert_deprecated_starting_token(self, deprecated_token):
     """
     This attempts to convert a deprecated starting token into the new
     style.
     """
     if len(deprecated_token) != len(self._input_token):
         raise ValueError("Bad starting token: %s" % self._starting_token)
     return dict(zip(self._input_token, deprecated_token))
Ejemplo n.º 2
0
 def _convert_deprecated_starting_token(self, deprecated_token):
     """
     This attempts to convert a deprecated starting token into the new
     style.
     """
     if len(deprecated_token) != len(self._input_token):
         raise ValueError("Bad starting token: %s" % self._starting_token)
     return dict(zip(self._input_token, deprecated_token))
Ejemplo n.º 3
0
 def _get_next_token(self, parsed):
     if self._more_results is not None:
         if not self._more_results.search(parsed):
             return {}
     next_tokens = {}
     for output_token, input_key in zip(self._output_token, self._input_token):
         next_token = output_token.search(parsed)
         # We do not want to include any empty strings as actual tokens.
         # Treat them as None.
         if next_token:
             next_tokens[input_key] = next_token
         else:
             next_tokens[input_key] = None
     return next_tokens
Ejemplo n.º 4
0
 def _get_next_token(self, parsed):
     if self._more_results is not None:
         if not self._more_results.search(parsed):
             return {}
     next_tokens = {}
     for output_token, input_key in \
             zip(self._output_token, self._input_token):
         next_token = output_token.search(parsed)
         # We do not want to include any empty strings as actual tokens.
         # Treat them as None.
         if next_token:
             next_tokens[input_key] = next_token
         else:
             next_tokens[input_key] = None
     return next_tokens
 def _convert_deprecated_starting_token(self, deprecated_token):
     """
     This attempts to convert a deprecated starting token into the new
     style.
     """
     len_deprecated_token = len(deprecated_token)
     len_input_token = len(self._input_token)
     if len_deprecated_token > len_input_token:
         raise ValueError("Bad starting token: %s" % self._starting_token)
     elif len_deprecated_token < len_input_token:
         log.debug("Old format starting token does not contain all input "
                   "tokens. Setting the rest, in order, as None.")
         for i in range(len_input_token - len_deprecated_token):
             deprecated_token.append(None)
     return dict(zip(self._input_token, deprecated_token))
Ejemplo n.º 6
0
 def _convert_deprecated_starting_token(self, deprecated_token):
     """
     This attempts to convert a deprecated starting token into the new
     style.
     """
     len_deprecated_token = len(deprecated_token)
     len_input_token = len(self._input_token)
     if len_deprecated_token > len_input_token:
         raise ValueError("Bad starting token: %s" % self._starting_token)
     elif len_deprecated_token < len_input_token:
         log.debug("Old format starting token does not contain all input "
                   "tokens. Setting the rest, in order, as None.")
         for i in range(len_input_token - len_deprecated_token):
             deprecated_token.append(None)
     return dict(zip(self._input_token, deprecated_token))
Ejemplo n.º 7
0
 def result_key_iters(self):
     teed_results = tee(self, len(self.result_keys))
     return [
         ResultKeyIterator(i, result_key)
         for i, result_key in zip(teed_results, self.result_keys)
     ]
Ejemplo n.º 8
0
 def result_key_iters(self):
     teed_results = tee(self, len(self.result_keys))
     return [ResultKeyIterator(i, result_key) for i, result_key
             in zip(teed_results, self.result_keys)]
Ejemplo n.º 9
0
 def _inject_token_into_kwargs(self, op_kwargs, next_token):
     for name, token in zip(self._input_token, next_token):
         if token is None or token == 'None':
             continue
         op_kwargs[name] = token