Skip to content

Commit

Permalink
replace != None with is not None
Browse files Browse the repository at this point in the history
  • Loading branch information
olearydj committed Sep 24, 2023
1 parent 05a1c1b commit 64e25a6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/formats/docx.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def write_file(data, outfile):
if 'image' in question:
for img in question['image']:
doc.add_picture(img['href'].replace("%20", " "), width=Mm(100))
if 'text' in question and question['text'] != None:
if 'text' in question and question['text'] is not None:
this_question_text = re.sub('</*tbody>', '', question['text']) # See https://github.com/pqzx/html2docx/issues/1
html_parser.add_html_to_document(this_question_text, doc)
if 'answer' in question:
Expand All @@ -41,7 +41,7 @@ def write_file(data, outfile):
options = []
for option in group['options']:
if option['display']:
if 'text' in answer and option['text'] != None:
if 'text' in answer and option['text'] is not None:
options.append(option['text'])
else:
options.append("---")
Expand All @@ -53,22 +53,22 @@ def write_file(data, outfile):
if 'image' in answer:
for img in answer['image']:
cell_0.add_picture(img['href'].replace("%20", " "), height=Mm(10))
if 'text' in answer and answer['text'] != None:
if 'text' in answer and answer['text'] is not None:
cell_0.text = cell_0.text + ("\n" if cell_0.text != "" else "") + answer['text']
if index == 0:
cell_1 = table.cell(0, 1)
for option in answer['options']:
if 'image' in option:
for img in option['image']:
cell_1.add_picture(img['href'].replace("%20", " "), height=Mm(10))
if 'text' in option and option['text'] != None:
if 'text' in option and option['text'] is not None:
cell_1.text = cell_1.text + ("\n" if cell_1.text != "" else "") + option['text']
elif question['question_type'] == "calculated_question":
if config.calculated_display_var_set_in_text:
doc.add_paragraph(config.blanks_replace_str * config.blanks_answer_n)
else:
for index, answer in enumerate(question['answer']):
if answer['display'] and 'text' in answer and answer['text'] != None:
if answer['display'] and 'text' in answer and answer['text'] is not None:
html_parser.add_html_to_document("<p>" + str(index+1) + ". " + answer['text'] + ": " + config.blanks_replace_str * 20 + "</p>", doc)
else:
for index, answer in enumerate(question['answer']):
Expand All @@ -77,7 +77,7 @@ def write_file(data, outfile):
for img in answer['image']:
html_parser.add_html_to_document("<p>" + str(index+1) + ".</p>", doc)
doc.add_picture(img['href'].replace("%20", " "), height=Mm(10))
if 'text' in answer and answer['text'] != None:
if 'text' in answer and answer['text'] is not None:
html_parser.add_html_to_document("<p>" + str(index+1) + ". </p>" + answer['text'], doc)
else:
doc.add_paragraph(config.blanks_replace_str * config.blanks_answer_n)
Expand Down

0 comments on commit 64e25a6

Please sign in to comment.