From 9a73710c9bf958d5069384f12314c696795fcaa8 Mon Sep 17 00:00:00 2001 From: Justin Clark Date: Fri, 16 Feb 2024 18:38:08 -0500 Subject: [PATCH 1/3] Change filenames/paths to be cross-platform - : removed from filename (fixes oserror on windows) - all filepaths generated with os.path now --- wayback_google_analytics/output.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wayback_google_analytics/output.py b/wayback_google_analytics/output.py index 1434bb7..688e192 100644 --- a/wayback_google_analytics/output.py +++ b/wayback_google_analytics/output.py @@ -26,14 +26,14 @@ def init_output(type, output_dir="./output"): os.makedirs(output_dir) # Get current date and time for file name - file_name = datetime.now().strftime("%d-%m-%Y(%H:%M:%S)") + file_name = datetime.now().strftime("%d-%m-%Y(%H-%M-%S)") # Create empty output file if type is not csv and return filename if type not in ["csv"]: with open(os.path.join(f"{output_dir}", f"{file_name}.{type}"), "w") as f: pass - return f"{output_dir}/" + f"{file_name}.{type}" + return os.path.join(output_dir, f"{file_name}.{type}") # If csv, create separate files for urls and codes and return filename with open(os.path.join(f"{output_dir}", f"{file_name}_urls.{type}"), "w") as f: @@ -42,7 +42,7 @@ def init_output(type, output_dir="./output"): with open(os.path.join(f"{output_dir}", f"{file_name}_codes.{type}"), "w") as f: pass - return f"{output_dir}/" + f"{file_name}.{type}" + return os.path.join(output_dir, f"{file_name}.{type}") def write_output(output_file, output_type, results): From 45f5805c368ff58449440cc362ee1bbd542d3f69 Mon Sep 17 00:00:00 2001 From: Justin Clark Date: Fri, 16 Feb 2024 18:41:18 -0500 Subject: [PATCH 2/3] Update version to 0.2.3 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index af4f451..69a9fcb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "wayback-google-analytics" -version = "0.2.2" +version = "0.2.3" description = "A tool for gathering current and historic google analytics ids from multiple websites" authors = ["Justin Clark "] license = "MIT" From 98c6a84d9cddfa6c2f051e4619625bb2d76060fd Mon Sep 17 00:00:00 2001 From: Justin Clark Date: Fri, 16 Feb 2024 18:51:34 -0500 Subject: [PATCH 3/3] Update expected filenames in test_output --- tests/test_output.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_output.py b/tests/test_output.py index 89f0a34..21d5cb8 100644 --- a/tests/test_output.py +++ b/tests/test_output.py @@ -21,7 +21,7 @@ class OutputTestCase(TestCase): def setUp(self): """Create test data""" - self.test_timestamp = "01-01-2023(12:00:00)" + self.test_timestamp = "01-01-2023(12-00-00)" self.test_path = "./test_output" self.valid_types = ["csv", "txt", "json", "xlsx"] if not os.path.exists(self.test_path): @@ -76,7 +76,7 @@ def test_format_archived_codes(self): def test_init_output_valid_types(self, mock_datetime): """Does init_output create a dict with correct keys?""" mock_now = Mock( - return_value=datetime.strptime(self.test_timestamp, "%d-%m-%Y(%H:%M:%S)") + return_value=datetime.strptime(self.test_timestamp, "%d-%m-%Y(%H-%M-%S)") ) mock_datetime.now = mock_now