Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds a shortcut to check if an object contains a tag #329

Merged
merged 2 commits into from Apr 24, 2020

Conversation

jsh2134
Copy link
Contributor

@jsh2134 jsh2134 commented Apr 24, 2020

Tags are case insensitive. Adds a helper method to the Object resource to check if a resource contains a tag.

This is a common bit of code that gets written all over the place.

if file.is_tagged("Special"):
      do_special_things()
else:
    pass

@jsh2134 jsh2134 requested a review from davecap April 24, 2020 14:26
@@ -354,33 +354,33 @@ def is_folder(self):
def is_file(self):
return self.object_type == 'file'

def tag(self, tags, remove=False, dry_run=False, apply_save=False):
"""Add or remove tags on an object"""
def is_tagged(self, tag):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about has_tag? :neckbeard:

@jsh2134 jsh2134 merged commit 363b0cc into master Apr 24, 2020
@jsh2134 jsh2134 deleted the add-is-tagged-command branch April 24, 2020 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants