Get a name with the given prefix unique in the current variable scope.
(prefix)
| 2717 | |
| 2718 | |
| 2719 | def _get_unique_variable_scope(prefix): |
| 2720 | """Get a name with the given prefix unique in the current variable scope.""" |
| 2721 | var_scope_store = get_variable_scope_store() |
| 2722 | current_scope = get_variable_scope() |
| 2723 | name = current_scope.name + "/" + prefix if current_scope.name else prefix |
| 2724 | if var_scope_store.variable_scope_count(name) == 0: |
| 2725 | return prefix |
| 2726 | idx = 1 |
| 2727 | while var_scope_store.variable_scope_count(name + ("_%d" % idx)) > 0: |
| 2728 | idx += 1 |
| 2729 | return prefix + ("_%d" % idx) |
| 2730 | |
| 2731 | |
| 2732 | # Named like a function for backwards compatibility with the |
no test coverage detected