Переглянути джерело

Refactor tuple into more understandable dict

Foppe Hemminga 6 роки тому
батько
коміт
c75ea0382e
2 змінених файлів з 8 додано та 7 видалено
  1. 6 6
      main.py
  2. 2 1
      model.py

+ 6 - 6
main.py

@@ -31,19 +31,19 @@ if __name__ == '__main__':
     send_message = False
     # print('if old_status {} != status[1] {}'.format(old_status, status[1]))
     assert type(old_status) is int, f"old_status {old_status} is not an integer: {type(old_status)}"
-    assert type(status[1]) is int, f"status[1] {status[1]} is not an integer: {type(status[1])}"
-    if old_status != status[1]:
+    assert type(status['integer']) is int, f"status['integer'] {status['integer']} is not an integer: {type(status['integer'])}"
+    if old_status != status['integer']:
         write_file_next = True
         send_message = True
     # print('write_file_next: {}'.format(write_file_next))
     if write_file_next:
-        summary = {'text': status[2], 'roman': status[0], 'integer': status[1]}
-        pprint(summary)
-        summary_json = json.dumps(summary, indent=2)
+        # summary = {'text': status["status"], 'roman': status["roman"], 'integer': status["integer"]}
+        pprint(status)
+        summary_json = json.dumps(status, indent=2)
         print(summary_json)
         write_file = open('status.json', 'w')
         write_file.write(summary_json)
         write_file.close()
 
     if send_message:
-        view.send_message(status[1])
+        view.send_message(status["integer"])

+ 2 - 1
model.py

@@ -72,4 +72,5 @@ def get_loot_level():
             this_loot_level = this_status[1][11:].strip()
     # print(this_loot_level)
     this_integer = _from_roman_to_integer(this_loot_level)
-    return this_loot_level,this_integer,this_status
+    this_status_dict = {"integer": this_integer, "roman": this_loot_level, "text": this_status}
+    return this_status_dict