Skip to content

Commit

Permalink
AutoMod: handle set_flair lists of < 2 items
Browse files Browse the repository at this point in the history
A definition like `set_flair: ["flair text"]` will currently fail
without displaying an error, since set_flair can currently only handle
either lists of 2+ items or a single string (not inside a list). This
makes it so that a value of a list of < 2 strings will work correctly.
  • Loading branch information
Deimos committed May 4, 2015
1 parent 276ae94 commit 233649c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion r2/r2/lib/automoderator.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,14 @@ def set_values(self, values):
setattr(self, key, None)

# special handling for set_flair
if self.set_flair:
if self.set_flair is not None:
if isinstance(self.set_flair, basestring):
self.set_flair = [self.set_flair, ""]

# handle 0 or 1 item lists
while len(self.set_flair) < 2:
self.set_flair.append("")

self.set_flair = {
"text": self.set_flair[0],
"class": self.set_flair[1],
Expand Down

0 comments on commit 233649c

Please sign in to comment.