Stores `value` in the collections given by `names`. Note that collections are not sets, so it is possible to add a value to a collection several times. This function makes sure that duplicates in `names` are ignored, but it will not check for pre-existing membership of `value` in an
(self, names, value)
| 3903 | self._collections[name].append(value) |
| 3904 | |
| 3905 | def add_to_collections(self, names, value): |
| 3906 | """Stores `value` in the collections given by `names`. |
| 3907 | |
| 3908 | Note that collections are not sets, so it is possible to add a value to |
| 3909 | a collection several times. This function makes sure that duplicates in |
| 3910 | `names` are ignored, but it will not check for pre-existing membership of |
| 3911 | `value` in any of the collections in `names`. |
| 3912 | |
| 3913 | `names` can be any iterable, but if `names` is a string, it is treated as a |
| 3914 | single collection name. |
| 3915 | |
| 3916 | Args: |
| 3917 | names: The keys for the collections to add to. The `GraphKeys` class |
| 3918 | contains many standard names for collections. |
| 3919 | value: The value to add to the collections. |
| 3920 | """ |
| 3921 | # Make sure names are unique, but treat strings as a single collection name |
| 3922 | names = (names,) if isinstance(names, six.string_types) else set(names) |
| 3923 | for name in names: |
| 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`. |