Skip to content

Commit

Permalink
Merge pull request #1700 from ericselk2018/dev
Browse files Browse the repository at this point in the history
add support for using * tag to return all devices
  • Loading branch information
toomanybrians authored Jul 7, 2023
2 parents 92d6abc + 9203872 commit 6ee8e4b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ their spare time, unpaid, for the love of pinball!
* James Cardona
* Dave Ensminger <dave@ensadi.com>
* Charles Duncan (nullbuilds)
* Eric Selk <ericselk2018@gmail.com>

MPF is inspired by pyprocgame and skeletongame which were written by:

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
See: http://docs.missionpinball.org/about/contributing_to_mpf.html
See: https://missionpinball.org/about/contributing_to_mpf/
5 changes: 4 additions & 1 deletion mpf/core/device_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,14 @@ def items_tagged(self, tag) -> List["Device"]:
Args:
----
tag: A string of the tag name which specifies what devices are
returned.
returned. A value of "*" returns all devices.
Returns a list of device objects. If no devices are found with that tag, it
will return an empty list.
"""
if tag == "*":
return self.values()

items_in_tag_cache = self._tag_cache.get(tag, None)
if items_in_tag_cache is not None:
return items_in_tag_cache
Expand Down
5 changes: 5 additions & 0 deletions mpf/tests/test_DeviceCollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ def test_tags(self):
self.assertIn(led2, self.machine.lights.items_tagged('tag1'))
self.assertNotIn(led3, self.machine.lights.items_tagged('tag1'))
self.assertNotIn(led4, self.machine.lights.items_tagged('tag1'))

self.assertIn(led1, self.machine.lights.items_tagged('*'))
self.assertIn(led2, self.machine.lights.items_tagged('*'))
self.assertIn(led3, self.machine.lights.items_tagged('*'))
self.assertIn(led4, self.machine.lights.items_tagged('*'))

0 comments on commit 6ee8e4b

Please sign in to comment.