def _requested_name(self, name, action=None, func=None):
if name is not None:<EOL><INDENT>if name in self._used_names:<EOL><INDENT>n = <NUM_LIT:2><EOL>while True:<EOL><INDENT>pn = name + '<STR_LIT:_>' + str(n)<EOL>if pn not in self._used_names:<EOL><INDENT>self._used_names.add(pn)<EOL>return pn<EOL><DEDENT>n += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>self._used_names.add(name)<EOL>return name<EOL><DEDENT><DEDENT>if func is not None:<EOL><INDENT>if hasattr(func, '<STR_LIT>'):<EOL><INDENT>name = func.__name__<EOL>if name == '<STR_LIT>':<EOL><INDENT>name = action + '<STR_LIT>'<EOL><DEDENT><DEDENT>elif hasattr(func, '<STR_LIT>'):<EOL><INDENT>name = func.__class__.__name__<EOL><DEDENT><DEDENT>if name is None:<EOL><INDENT>if action is not None:<EOL><INDENT>name = action<EOL><DEDENT>else:<EOL><INDENT>name = self.name<EOL><DEDENT><DEDENT>return self._requested_name(name)<EOL>
Create a unique name for an operator or a stream.