Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save GraylinKim/469013 to your computer and use it in GitHub Desktop.
Save GraylinKim/469013 to your computer and use it in GitHub Desktop.
for post in self.objs.get('posts',[]):
def makeRef(name,value):
for obj in self.objs.get(name,[]):
if obj.slug == value:
tag.posts.append(post)
post.tags[i] = tag
return True
warning = "%s '%s' referenced but not defined."
self.log.warning(warning % (name[:-1].capitalize(),value))
return False
post.tags = [tag for tag in post.tags if makeRef('tags',tag)]
post.feeds = [feed for feed in post.feeds if makeRef('feeds',feed)]
@GraylinKim
Copy link
Author

Line 26: Warning should warn instead of undefined feed referenced.
Lines 9 and 24: can be followed by continue since match has already been found

Since both if blocks need early escape and are virtually identical, we could factor out the code.

@GraylinKim
Copy link
Author

Oops, I'm missing a 'return False'

@GraylinKim
Copy link
Author

So this hasn't been tested because I don't have the dependencies and haven't checked out the Firmant testing framework recently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment