From 60e5e74ac71406329ca617b5ded30c993274011d Mon Sep 17 00:00:00 2001 From: Malachy Byrne Date: Mon, 10 Apr 2023 20:33:16 +0100 Subject: [PATCH] added Project class and modified university.py to create required directory --- project.py | 19 +++++++++++++++++++ university.py | 5 ++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 project.py diff --git a/project.py b/project.py new file mode 100644 index 0000000..5e76247 --- /dev/null +++ b/project.py @@ -0,0 +1,19 @@ +from dataclasses import dataclass +import pickle + +@dataclass +class Project: + acronym: str + title: str + description: str + amount: int + + +if __name__ == "__main__": + project1 = Project("acronym", "title", "description", 500) + with open("file", "wb+") as file1: + pickle.dump(project1, file1) + with open("file", "rb") as file2: + project2 = pickle.load(file2) + print(project2) + diff --git a/university.py b/university.py index e773593..0b11c25 100644 --- a/university.py +++ b/university.py @@ -1,6 +1,9 @@ import os import pika +if not os.path.exists("approved_projects"): + os.makedirs("approved_projects") + connection = pika.BlockingConnection(pika.ConnectionParameters('localhost', 5672, '/', pika.PlainCredentials("user", "password"))) channel = connection.channel() @@ -26,4 +29,4 @@ try: channel.start_consuming() except KeyboardInterrupt: channel.stop_consuming() - connection.close() \ No newline at end of file + connection.close()