Returns a list of values in the collection with the given `name`. If the collection exists, this returns the list itself, which can be modified in place to change the collection. If the collection does not exist, it is created as an empty list and the list is returned. This is dif
(self, name)
| 3924 | self.add_to_collection(name, value) |
| 3925 | |
| 3926 | def get_collection_ref(self, name): |
| 3927 | """Returns a list of values in the collection with the given `name`. |
| 3928 | |
| 3929 | If the collection exists, this returns the list itself, which can |
| 3930 | be modified in place to change the collection. If the collection does |
| 3931 | not exist, it is created as an empty list and the list is returned. |
| 3932 | |
| 3933 | This is different from `get_collection()` which always returns a copy of |
| 3934 | the collection list if it exists and never creates an empty collection. |
| 3935 | |
| 3936 | Args: |
| 3937 | name: The key for the collection. For example, the `GraphKeys` class |
| 3938 | contains many standard names for collections. |
| 3939 | |
| 3940 | Returns: |
| 3941 | The list of values in the collection with the given `name`, or an empty |
| 3942 | list if no value has been added to that collection. |
| 3943 | """ # pylint: disable=g-doc-exception |
| 3944 | with self._lock: |
| 3945 | coll_list = self._collections.get(name, None) |
| 3946 | if coll_list is None: |
| 3947 | coll_list = [] |
| 3948 | self._collections[name] = coll_list |
| 3949 | return coll_list |
| 3950 | |
| 3951 | def get_collection(self, name, scope=None): |
| 3952 | """Returns a list of values in the collection with the given `name`. |