Skip to content

Commit

Permalink
Merge pull request #24 from jsdiaz/master
Browse files Browse the repository at this point in the history
Fix warning display for raw when charList is not 6.
  • Loading branch information
ShaneSutro authored Jun 17, 2022
2 parents 646422e + c92a371 commit 5f6f328
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions vestaboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,29 @@ def raw(self, charList: list, pad=None):
for j, char in enumerate(row):
if not isinstance(char, int):
raise ValueError(f'Nested lists must contain numbers only - check row {i} char {j} (0 indexed)')
if len(charList) > 6:
if len(charList) == 6:
pass
elif len(charList) > 6:
# warnings.warn doesn't work with f strings
warning_message = f'The Vestaboard API accepts only 6 lines of characters; you\'ve passed in {len(charList)}. Only the first 6 will be shown.'
warnings.warn(warning_message)
del charList[6:]
elif pad == 'below':
for i in range(filler_needed):
charList.append(base_filler)
elif pad == 'above':
for i in range(filler_needed):
charList.insert(0, base_filler)
else:
if pad == None:
# warnings.warn doesn't work with f strings
warning_message = f'you provided a list with length {len(charList)}, which has been centered on the board by default. Either provide a list with length 6, or set the "pad" option to suppress this warning.'
warnings.warn(warning_message)
while len(charList) < 6:
charList.append(base_filler)
if len(charList) < 6:
elif len(charList) < 6:
if pad == 'below':
for i in range(filler_needed):
charList.append(base_filler)
elif pad == 'above':
for i in range(filler_needed):
charList.insert(0, base_filler)
else:
if pad == None:
# warnings.warn doesn't work with f strings
warning_message = f'you provided a list with length {len(charList)}, which has been centered on the board by default. Either provide a list with length 6, or set the "pad" option to suppress this warning.'
warnings.warn(warning_message)
while len(charList) < 6:
charList.append(base_filler)
if len(charList) < 6:
charList.insert(0, base_filler)
headers = {
"X-Vestaboard-Api-Key" : self.apiKey,
"X-Vestaboard-Api-Secret" : self.apiSecret
Expand Down Expand Up @@ -136,4 +139,4 @@ def get_subscriptions(self, save=True):
def get_creds():
with open('./credentials.txt', 'r') as cred:
creds = cred.read().splitlines()
return creds
return creds

0 comments on commit 5f6f328

Please sign in to comment.