From 0799d7d8fc12f5c38fd00d8a7ceb3bb0a636959c Mon Sep 17 00:00:00 2001 From: Slyher Date: Sat, 8 Mar 2025 09:52:29 +0100 Subject: [PATCH 01/12] extracting lump of code responsible for copping files --- qsl.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/qsl.py b/qsl.py index 7e29a13..0aa753c 100644 --- a/qsl.py +++ b/qsl.py @@ -1,6 +1,14 @@ import adif_io import os + +def copy_files(current_path) -> str: + os.system("cp ./tex/qslf.pdf " + current_path) + os.system("cp ./img/qsl_r.jpg "+current_path) + os.system("cp ./tex/qsl.tex " + current_path) + os.system("cp ./tex/qsl_r.tex " + current_path) + return current_path + "/qsl_r.tex" + filename="hf23wtte.log.adi" dist_directory = os.path.join(os.getcwd(), "dist") @@ -11,11 +19,7 @@ os.mkdir(current_path) if "EMAIL" in qso: os.system("echo " +qso["EMAIL"]+ " >> "+ current_path + "/mail") - os.system("cp ./tex/qslf.pdf " + current_path) - os.system("cp ./img/qsl_r.jpg "+current_path) - os.system("cp ./tex/qsl.tex " + current_path) - os.system("cp ./tex/qsl_r.tex " + current_path) - qsl_r_file = current_path + "/qsl_r.tex" + qsl_r_file = copy_files(current_path) if "RST_SENT" not in qso: qso["RST_SENT"] = "-" with open(qsl_r_file, "r") as f: @@ -26,3 +30,4 @@ f.write(contents) f.close() os.system("./qsl.sh " + qso["CALL"]+qso["TIME_ON"]) + \ No newline at end of file From 832ae88f131a3d56720a10d1bd48d02c365f3951 Mon Sep 17 00:00:00 2001 From: Slyher Date: Sat, 8 Mar 2025 10:03:57 +0100 Subject: [PATCH 02/12] extracting method responsible for creating working directory for qso --- qsl.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qsl.py b/qsl.py index 0aa753c..83c06bd 100644 --- a/qsl.py +++ b/qsl.py @@ -9,14 +9,18 @@ def copy_files(current_path) -> str: os.system("cp ./tex/qsl_r.tex " + current_path) return current_path + "/qsl_r.tex" +def create_working_directory_for_qso(qso -> dict) -> str: + current_path = os.path.join(dist_directory, qso["CALL"].replace("/","-") + qso["TIME_ON"]) + os.mkdir(current_path) + return current_path + filename="hf23wtte.log.adi" dist_directory = os.path.join(os.getcwd(), "dist") qsos, headers = adif_io.read_from_file(filename) for qso in qsos: - current_path = os.path.join(dist_directory, qso["CALL"].replace("/","-") + qso["TIME_ON"]) - os.mkdir(current_path) + current_path = create_working_directory_for_qso(qso) if "EMAIL" in qso: os.system("echo " +qso["EMAIL"]+ " >> "+ current_path + "/mail") qsl_r_file = copy_files(current_path) From 586430ab305f551afc2b7af9d4a8240d92f3ee21 Mon Sep 17 00:00:00 2001 From: Slyher Date: Sat, 8 Mar 2025 10:20:18 +0100 Subject: [PATCH 03/12] extracting code responsible for creating file with email address --- qsl.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qsl.py b/qsl.py index 83c06bd..03fa670 100644 --- a/qsl.py +++ b/qsl.py @@ -14,6 +14,9 @@ def create_working_directory_for_qso(qso -> dict) -> str: os.mkdir(current_path) return current_path +def create_email_file_for_qso(email- > str, current_path -> str): + os.system("echo " +email+ " >> "+ current_path + "/mail") + filename="hf23wtte.log.adi" dist_directory = os.path.join(os.getcwd(), "dist") @@ -22,7 +25,7 @@ def create_working_directory_for_qso(qso -> dict) -> str: for qso in qsos: current_path = create_working_directory_for_qso(qso) if "EMAIL" in qso: - os.system("echo " +qso["EMAIL"]+ " >> "+ current_path + "/mail") + create_email_file_for_qso( qso["EMAIL"], current_path) qsl_r_file = copy_files(current_path) if "RST_SENT" not in qso: qso["RST_SENT"] = "-" From ab8c23cffec9af9cc1a963e2ae1d2f23fcf1fdd6 Mon Sep 17 00:00:00 2001 From: Slyher Date: Sat, 8 Mar 2025 12:42:36 +0100 Subject: [PATCH 04/12] extract qsl update code to function --- qsl.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qsl.py b/qsl.py index 03fa670..37ba93c 100644 --- a/qsl.py +++ b/qsl.py @@ -17,6 +17,9 @@ def create_working_directory_for_qso(qso -> dict) -> str: def create_email_file_for_qso(email- > str, current_path -> str): os.system("echo " +email+ " >> "+ current_path + "/mail") +def update_qsl_content(qso -> dict) -> str: + return contents.replace("[CALL]",qso["CALL"].replace("/","{\slash}")).replace("[TIME]",qso["TIME_ON"][:2]+":"+qso["TIME_ON"][2:]).replace("[FREQ]",qso["FREQ"]).replace("[MODE]",qso["MODE"]).replace("[RST-RECV]",qso["RST_SENT"]) + filename="hf23wtte.log.adi" dist_directory = os.path.join(os.getcwd(), "dist") @@ -30,8 +33,7 @@ def create_email_file_for_qso(email- > str, current_path -> str): if "RST_SENT" not in qso: qso["RST_SENT"] = "-" with open(qsl_r_file, "r") as f: - contents = f.read() - contents = contents.replace("[CALL]",qso["CALL"].replace("/","{\slash}")).replace("[TIME]",qso["TIME_ON"][:2]+":"+qso["TIME_ON"][2:]).replace("[FREQ]",qso["FREQ"]).replace("[MODE]",qso["MODE"]).replace("[RST-RECV]",qso["RST_SENT"]) + contents =update_qsl_content(f.read()) f.close() f = open(qsl_r_file, "w") f.write(contents) From 8e909a39241cdde10c16ff16081daaaa627f01e6 Mon Sep 17 00:00:00 2001 From: Slyher Date: Sat, 8 Mar 2025 12:55:44 +0100 Subject: [PATCH 05/12] extract code responsible for writing the qsl for qso to a file --- qsl.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/qsl.py b/qsl.py index 37ba93c..d9437a8 100644 --- a/qsl.py +++ b/qsl.py @@ -20,6 +20,11 @@ def create_email_file_for_qso(email- > str, current_path -> str): def update_qsl_content(qso -> dict) -> str: return contents.replace("[CALL]",qso["CALL"].replace("/","{\slash}")).replace("[TIME]",qso["TIME_ON"][:2]+":"+qso["TIME_ON"][2:]).replace("[FREQ]",qso["FREQ"]).replace("[MODE]",qso["MODE"]).replace("[RST-RECV]",qso["RST_SENT"]) +def write_qsl_for_qso(content->str, qsl_r_file_name -> str): + f = open(qsl_r_file_name, "w") + f.write(content) + f.close() + filename="hf23wtte.log.adi" dist_directory = os.path.join(os.getcwd(), "dist") @@ -29,14 +34,12 @@ def update_qsl_content(qso -> dict) -> str: current_path = create_working_directory_for_qso(qso) if "EMAIL" in qso: create_email_file_for_qso( qso["EMAIL"], current_path) - qsl_r_file = copy_files(current_path) + qsl_r_file_name = copy_files(current_path) if "RST_SENT" not in qso: qso["RST_SENT"] = "-" - with open(qsl_r_file, "r") as f: - contents =update_qsl_content(f.read()) - f.close() - f = open(qsl_r_file, "w") - f.write(contents) + with open(qsl_r_file_name, "r") as f: + content = update_qsl_content(f.read()) f.close() + write_qsl_for_qso(content, qsl_r_file_name) os.system("./qsl.sh " + qso["CALL"]+qso["TIME_ON"]) \ No newline at end of file From 5384742931c6c052ce6f2e72499fef5ea68b846a Mon Sep 17 00:00:00 2001 From: Slyher Date: Sat, 8 Mar 2025 13:11:42 +0100 Subject: [PATCH 06/12] extracting code responsible for generating qsl via latex - little refactoring --- qsl.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/qsl.py b/qsl.py index d9437a8..d303ca1 100644 --- a/qsl.py +++ b/qsl.py @@ -10,28 +10,32 @@ def copy_files(current_path) -> str: return current_path + "/qsl_r.tex" def create_working_directory_for_qso(qso -> dict) -> str: + qsl_directory = qso["CALL"].replace("/","-") + qso["TIME_ON"] current_path = os.path.join(dist_directory, qso["CALL"].replace("/","-") + qso["TIME_ON"]) os.mkdir(current_path) - return current_path + return [current_path, qsl_directory] def create_email_file_for_qso(email- > str, current_path -> str): os.system("echo " +email+ " >> "+ current_path + "/mail") -def update_qsl_content(qso -> dict) -> str: - return contents.replace("[CALL]",qso["CALL"].replace("/","{\slash}")).replace("[TIME]",qso["TIME_ON"][:2]+":"+qso["TIME_ON"][2:]).replace("[FREQ]",qso["FREQ"]).replace("[MODE]",qso["MODE"]).replace("[RST-RECV]",qso["RST_SENT"]) +def update_qsl_content(qso -> dict,content -> str) -> str: + return content.replace("[CALL]",qso["CALL"].replace("/","{\slash}")).replace("[TIME]",qso["TIME_ON"][:2]+":"+qso["TIME_ON"][2:]).replace("[FREQ]",qso["FREQ"]).replace("[MODE]",qso["MODE"]).replace("[RST-RECV]",qso["RST_SENT"]) def write_qsl_for_qso(content->str, qsl_r_file_name -> str): f = open(qsl_r_file_name, "w") f.write(content) f.close() - + +def generate_qsl_with_latex(qsl_directory): + os.system("./qsl.sh " + qsl_directory) + filename="hf23wtte.log.adi" dist_directory = os.path.join(os.getcwd(), "dist") qsos, headers = adif_io.read_from_file(filename) for qso in qsos: - current_path = create_working_directory_for_qso(qso) + current_path, qsl_directory = create_working_directory_for_qso(qso) if "EMAIL" in qso: create_email_file_for_qso( qso["EMAIL"], current_path) qsl_r_file_name = copy_files(current_path) @@ -41,5 +45,5 @@ def write_qsl_for_qso(content->str, qsl_r_file_name -> str): content = update_qsl_content(f.read()) f.close() write_qsl_for_qso(content, qsl_r_file_name) - os.system("./qsl.sh " + qso["CALL"]+qso["TIME_ON"]) + generate_qsl_with_latex(qsl_directory) \ No newline at end of file From 883267ec75d5fbf070d52ab02077b66bed81c841 Mon Sep 17 00:00:00 2001 From: Slyher Date: Sat, 8 Mar 2025 13:38:15 +0100 Subject: [PATCH 07/12] extracted code responsible for managing qsl generation --- qsl.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/qsl.py b/qsl.py index d303ca1..1f011ae 100644 --- a/qsl.py +++ b/qsl.py @@ -28,22 +28,29 @@ def write_qsl_for_qso(content->str, qsl_r_file_name -> str): def generate_qsl_with_latex(qsl_directory): os.system("./qsl.sh " + qsl_directory) - -filename="hf23wtte.log.adi" -dist_directory = os.path.join(os.getcwd(), "dist") -qsos, headers = adif_io.read_from_file(filename) - -for qso in qsos: +def preparing_environment_for_generating_qsl_with_qso(qso -> dict): current_path, qsl_directory = create_working_directory_for_qso(qso) if "EMAIL" in qso: create_email_file_for_qso( qso["EMAIL"], current_path) qsl_r_file_name = copy_files(current_path) if "RST_SENT" not in qso: qso["RST_SENT"] = "-" + return [qso,qsl_r_file_name, qsl_directory] + +def generate_qsl_with_qso(qso -> dict): + qso,qsl_r_file_name, qsl_directory = preparing_environment_for_generating_qsl_with_qso(qso) with open(qsl_r_file_name, "r") as f: content = update_qsl_content(f.read()) f.close() write_qsl_for_qso(content, qsl_r_file_name) generate_qsl_with_latex(qsl_directory) + +filename="hf23wtte.log.adi" +dist_directory = os.path.join(os.getcwd(), "dist") + +qsos, headers = adif_io.read_from_file(filename) + +for qso in qsos: + generate_qsl_with_qso(qso) \ No newline at end of file From 8c8431cb6e98485e7b0f965853bdbc8db61fe300 Mon Sep 17 00:00:00 2001 From: Slyher Date: Sun, 9 Mar 2025 11:27:08 +0100 Subject: [PATCH 08/12] reformating a little bit --- qsl.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qsl.py b/qsl.py index 1f011ae..beab857 100644 --- a/qsl.py +++ b/qsl.py @@ -18,10 +18,10 @@ def create_working_directory_for_qso(qso -> dict) -> str: def create_email_file_for_qso(email- > str, current_path -> str): os.system("echo " +email+ " >> "+ current_path + "/mail") -def update_qsl_content(qso -> dict,content -> str) -> str: +def update_qsl_content(qso -> dict, content -> str) -> str: return content.replace("[CALL]",qso["CALL"].replace("/","{\slash}")).replace("[TIME]",qso["TIME_ON"][:2]+":"+qso["TIME_ON"][2:]).replace("[FREQ]",qso["FREQ"]).replace("[MODE]",qso["MODE"]).replace("[RST-RECV]",qso["RST_SENT"]) -def write_qsl_for_qso(content->str, qsl_r_file_name -> str): +def write_qsl_template_for_qso(content -> str, qsl_r_file_name -> str): f = open(qsl_r_file_name, "w") f.write(content) f.close() @@ -43,7 +43,7 @@ def generate_qsl_with_qso(qso -> dict): with open(qsl_r_file_name, "r") as f: content = update_qsl_content(f.read()) f.close() - write_qsl_for_qso(content, qsl_r_file_name) + write_qsl_template_for_qso(content, qsl_r_file_name) generate_qsl_with_latex(qsl_directory) filename="hf23wtte.log.adi" From 6ce5eee02130724e4d365b071ceb1ac564bbf478 Mon Sep 17 00:00:00 2001 From: Slyher Date: Thu, 27 Mar 2025 22:11:07 +0100 Subject: [PATCH 09/12] implementinh autopep8 and code review changes --- qsl.py | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/qsl.py b/qsl.py index beab857..686fc8f 100644 --- a/qsl.py +++ b/qsl.py @@ -4,53 +4,66 @@ def copy_files(current_path) -> str: os.system("cp ./tex/qslf.pdf " + current_path) - os.system("cp ./img/qsl_r.jpg "+current_path) + os.system("cp ./img/qsl_r.jpg " + current_path) os.system("cp ./tex/qsl.tex " + current_path) os.system("cp ./tex/qsl_r.tex " + current_path) return current_path + "/qsl_r.tex" + def create_working_directory_for_qso(qso -> dict) -> str: - qsl_directory = qso["CALL"].replace("/","-") + qso["TIME_ON"] - current_path = os.path.join(dist_directory, qso["CALL"].replace("/","-") + qso["TIME_ON"]) + qsl_directory = qso["CALL"].replace("/", "-") + qso["TIME_ON"] + current_path = os.path.join( + dist_directory, qso["CALL"].replace( + "/", "-") + qso["TIME_ON"]) os.mkdir(current_path) return [current_path, qsl_directory] -def create_email_file_for_qso(email- > str, current_path -> str): - os.system("echo " +email+ " >> "+ current_path + "/mail") - + +def create_email_file_for_qso(email - > str, current_path -> str): + os.system("echo " + email + " >> " + current_path + "/mail") + + def update_qsl_content(qso -> dict, content -> str) -> str: - return content.replace("[CALL]",qso["CALL"].replace("/","{\slash}")).replace("[TIME]",qso["TIME_ON"][:2]+":"+qso["TIME_ON"][2:]).replace("[FREQ]",qso["FREQ"]).replace("[MODE]",qso["MODE"]).replace("[RST-RECV]",qso["RST_SENT"]) - + qso_call = qso["CALL"].replace("/", "{\\slash}") + qso_time = qso["TIME_ON"][:2] + ":" + qso["TIME_ON"][2:] + return content.replace("[CALL]", qso_call).replace("[TIME]", qso_time).replace( + "[FREQ]", qso["FREQ"]).replace("[MODE]", qso["MODE"]).replace("[RST-RECV]", qso["RST_SENT"]) + + def write_qsl_template_for_qso(content -> str, qsl_r_file_name -> str): f = open(qsl_r_file_name, "w") f.write(content) f.close() + def generate_qsl_with_latex(qsl_directory): os.system("./qsl.sh " + qsl_directory) + def preparing_environment_for_generating_qsl_with_qso(qso -> dict): current_path, qsl_directory = create_working_directory_for_qso(qso) if "EMAIL" in qso: - create_email_file_for_qso( qso["EMAIL"], current_path) + create_email_file_for_qso(qso["EMAIL"], current_path) qsl_r_file_name = copy_files(current_path) if "RST_SENT" not in qso: qso["RST_SENT"] = "-" - return [qso,qsl_r_file_name, qsl_directory] + return [qso, qsl_r_file_name, qsl_directory] + def generate_qsl_with_qso(qso -> dict): - qso,qsl_r_file_name, qsl_directory = preparing_environment_for_generating_qsl_with_qso(qso) + qso, qsl_r_file_name, qsl_directory = preparing_environment_for_generating_qsl_with_qso( + qso) with open(qsl_r_file_name, "r") as f: content = update_qsl_content(f.read()) f.close() write_qsl_template_for_qso(content, qsl_r_file_name) generate_qsl_with_latex(qsl_directory) - -filename="hf23wtte.log.adi" + + +filename = "hf23wtte.log.adi" dist_directory = os.path.join(os.getcwd(), "dist") qsos, headers = adif_io.read_from_file(filename) for qso in qsos: generate_qsl_with_qso(qso) - \ No newline at end of file From c0286e9c3331b4b2901bbb632feb8b636b60a36c Mon Sep 17 00:00:00 2001 From: Slyher Date: Thu, 27 Mar 2025 22:45:11 +0100 Subject: [PATCH 10/12] Adding documentation to functions small code review updates --- qsl.py | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 94 insertions(+), 3 deletions(-) diff --git a/qsl.py b/qsl.py index 686fc8f..203dcb3 100644 --- a/qsl.py +++ b/qsl.py @@ -3,6 +3,16 @@ def copy_files(current_path) -> str: + """ + The function `copy_files` copies specific files to a specified directory and returns the path to a + specific file. + + :param current_path: The `copy_files` function takes the `current_path` as a parameter, which is the + destination path where the files will be copied. The function copies four files (`qslf.pdf`, + `qsl_r.jpg`, `qsl.tex`, `qsl_r.tex`) from their respective source + :return: The function `copy_files` is returning the path to the copied file "qsl_r.tex" within the + specified `current_path`. The returned value will be in the format `current_path + "/qsl_r.tex"`. + """ os.system("cp ./tex/qslf.pdf " + current_path) os.system("cp ./img/qsl_r.jpg " + current_path) os.system("cp ./tex/qsl.tex " + current_path) @@ -11,6 +21,16 @@ def copy_files(current_path) -> str: def create_working_directory_for_qso(qso -> dict) -> str: + """ + This function creates a working directory for a QSO (amateur radio contact) based on the call sign + and time of the contact. + + :param dict: The function `create_working_directory_for_qso` takes a dictionary `qso` as input and + creates a working directory based on the values in the dictionary. The dictionary `qso` likely + contains information related to a radio communication contact, such as the call sign and time of the + contact + :return: A list containing the current path and the QSL directory name is being returned. + """ qsl_directory = qso["CALL"].replace("/", "-") + qso["TIME_ON"] current_path = os.path.join( dist_directory, qso["CALL"].replace( @@ -20,27 +40,92 @@ def create_working_directory_for_qso(qso -> dict) -> str: def create_email_file_for_qso(email - > str, current_path -> str): + """ + The function `create_email_file_for_qso` appends an email address to a file named "mail" in the + specified directory. + + :param email: The `email` parameter is a string that represents the email address that you want to + write to a file + :param current_path: The `current_path` parameter is a string that represents the path to the + directory where you want to create the email file. This path should be the location where you want + to store the email file named "mail" + """ os.system("echo " + email + " >> " + current_path + "/mail") def update_qsl_content(qso -> dict, content -> str) -> str: + """ + The function `update_qsl_content` updates a given content string with specific values from a QSO + dictionary. + + :param dict: The `update_qsl_content` function takes two parameters: + :param content: The `content` parameter is a string that contains placeholders such as `[CALL]`, + `[TIME]`, `[FREQ]`, `[MODE]`, and `[RST-RECV]`. The function `update_qsl_content` takes a dictionary + `qso` and a string `content` + :return: The function `update_qsl_content` is returning a string with placeholders `[CALL]`, + `[TIME]`, `[FREQ]`, `[MODE]`, and `[RST-RECV]` replaced by corresponding values from the `qso` + dictionary. + """ qso_call = qso["CALL"].replace("/", "{\\slash}") qso_time = qso["TIME_ON"][:2] + ":" + qso["TIME_ON"][2:] - return content.replace("[CALL]", qso_call).replace("[TIME]", qso_time).replace( - "[FREQ]", qso["FREQ"]).replace("[MODE]", qso["MODE"]).replace("[RST-RECV]", qso["RST_SENT"]) + qso_freq = qso["FREQ"] + qso_mode = qso["MODE"] + + return content.replace( + "[CALL]", + qso_call).replace( + "[TIME]", + qso_time).replace( + "[FREQ]", + qso_freq).replace( + "[MODE]", + qso_mode).replace( + "[RST-RECV]", + qso["RST_SENT"]) def write_qsl_template_for_qso(content -> str, qsl_r_file_name -> str): + """ + The function `write_qsl_template_for_qso` writes the provided content to a file with the specified + file name. + + :param content: The `content` parameter in the `write_qsl_template_for_qso` function is a string + that represents the content you want to write to a file. This content could be a template for a QSL + (confirmation of a two-way radio communication) that you want to save to a file + :param qsl_r_file_name: The `qsl_r_file_name` parameter is the name of the file where you want to + write the content. It should be a string representing the file name or the path to the file where + you want to save the content + """ f = open(qsl_r_file_name, "w") f.write(content) f.close() def generate_qsl_with_latex(qsl_directory): + """ + The function `generate_qsl_with_latex` executes a shell script `qsl.sh` with the provided directory + as an argument. + + :param qsl_directory: The `qsl_directory` parameter in the `generate_qsl_with_latex` function + represents the directory where the QSL (QSL cards) files are located. This function seems to be + calling a shell script named `qsl.sh` with the provided directory as an argument to generate QSL + """ os.system("./qsl.sh " + qsl_directory) def preparing_environment_for_generating_qsl_with_qso(qso -> dict): + """ + The function prepares the environment for generating QSL with QSO by creating a working directory, + copying files, and handling email information. + + :param dict: The function `preparing_environment_for_generating_qsl_with_qso` takes a dictionary + `qso` as input and performs the following tasks: + :return: The function `preparing_environment_for_generating_qsl_with_qso` is returning a list + containing the following items: + 1. The QSO dictionary with any modifications made during the preparation process. + 2. The filename of the copied QSL files. + 3. The directory where the QSL files are stored. + """ current_path, qsl_directory = create_working_directory_for_qso(qso) if "EMAIL" in qso: create_email_file_for_qso(qso["EMAIL"], current_path) @@ -51,6 +136,12 @@ def preparing_environment_for_generating_qsl_with_qso(qso -> dict): def generate_qsl_with_qso(qso -> dict): + """ + The function generates a QSL card using a QSO dictionary and LaTeX templates. + + :param dict: The `generate_qsl_with_qso` function seems to be a part of a larger script or program + related to generating QSL cards for amateur radio contacts + """ qso, qsl_r_file_name, qsl_directory = preparing_environment_for_generating_qsl_with_qso( qso) with open(qsl_r_file_name, "r") as f: @@ -63,7 +154,7 @@ def generate_qsl_with_qso(qso -> dict): filename = "hf23wtte.log.adi" dist_directory = os.path.join(os.getcwd(), "dist") -qsos, headers = adif_io.read_from_file(filename) +qsos = adif_io.read_from_file(filename)[0] for qso in qsos: generate_qsl_with_qso(qso) From 13caeb520acc885be522ec27704677e527cea346 Mon Sep 17 00:00:00 2001 From: Slyher Date: Fri, 28 Mar 2025 00:30:29 +0100 Subject: [PATCH 11/12] Minimizing code by reusing existing variable qsl_directory --- qsl.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/qsl.py b/qsl.py index 203dcb3..b95343e 100644 --- a/qsl.py +++ b/qsl.py @@ -32,9 +32,7 @@ def create_working_directory_for_qso(qso -> dict) -> str: :return: A list containing the current path and the QSL directory name is being returned. """ qsl_directory = qso["CALL"].replace("/", "-") + qso["TIME_ON"] - current_path = os.path.join( - dist_directory, qso["CALL"].replace( - "/", "-") + qso["TIME_ON"]) + current_path = os.path.join(dist_directory, qsl_directory) os.mkdir(current_path) return [current_path, qsl_directory] From 045428223c249434d419e45b76f6fb6b02156ceb Mon Sep 17 00:00:00 2001 From: Slyher Date: Fri, 28 Mar 2025 00:33:34 +0100 Subject: [PATCH 12/12] removing unnecessary file close --- qsl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qsl.py b/qsl.py index b95343e..06e8c9b 100644 --- a/qsl.py +++ b/qsl.py @@ -144,7 +144,7 @@ def generate_qsl_with_qso(qso -> dict): qso) with open(qsl_r_file_name, "r") as f: content = update_qsl_content(f.read()) - f.close() + write_qsl_template_for_qso(content, qsl_r_file_name) generate_qsl_with_latex(qsl_directory)