Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change filenames/paths to be cross-platform (fixes #26) #27

Merged
merged 3 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions wayback_google_analytics/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
Expand Down
Loading