recup sources
This commit is contained in:
parent
86622a19ea
commit
65fe2a35f9
155 changed files with 50969 additions and 0 deletions
70
wiki_compare/test_json.py
Normal file
70
wiki_compare/test_json.py
Normal file
|
@ -0,0 +1,70 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
test_json.py
|
||||
|
||||
This script tests writing a JSON file with some test data.
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
# Test data
|
||||
test_data = {
|
||||
"last_updated": datetime.now().isoformat(),
|
||||
"recent_changes": [
|
||||
{
|
||||
"page_name": "Test Page 1",
|
||||
"page_url": "https://example.com/test1",
|
||||
"timestamp": "12:34",
|
||||
"user": "Test User 1",
|
||||
"comment": "Test comment 1",
|
||||
"change_size": "+123"
|
||||
},
|
||||
{
|
||||
"page_name": "Test Page 2",
|
||||
"page_url": "https://example.com/test2",
|
||||
"timestamp": "23:45",
|
||||
"user": "Test User 2",
|
||||
"comment": "Test comment 2",
|
||||
"change_size": "-456"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
# Output file
|
||||
output_file = "test_recent_changes.json"
|
||||
|
||||
# Write the data to the file
|
||||
print(f"Writing test data to {output_file}")
|
||||
with open(output_file, 'w', encoding='utf-8') as f:
|
||||
json.dump(test_data, f, indent=2, ensure_ascii=False)
|
||||
|
||||
# Check if the file was created
|
||||
if os.path.exists(output_file):
|
||||
file_size = os.path.getsize(output_file)
|
||||
print(f"File {output_file} created, size: {file_size} bytes")
|
||||
|
||||
# Read the content of the file to verify
|
||||
with open(output_file, 'r', encoding='utf-8') as f:
|
||||
file_content = f.read()
|
||||
print(f"File content: {file_content}")
|
||||
else:
|
||||
print(f"Failed to create file {output_file}")
|
||||
|
||||
# Copy the file to the public directory
|
||||
public_file = os.path.join(os.path.dirname(os.path.dirname(output_file)), 'public', os.path.basename(output_file))
|
||||
print(f"Copying {output_file} to {public_file}")
|
||||
import shutil
|
||||
shutil.copy2(output_file, public_file)
|
||||
|
||||
# Check if the public file was created
|
||||
if os.path.exists(public_file):
|
||||
public_size = os.path.getsize(public_file)
|
||||
print(f"Public file {public_file} created, size: {public_size} bytes")
|
||||
else:
|
||||
print(f"Failed to create public file {public_file}")
|
||||
|
||||
print("Script completed successfully")
|
Loading…
Add table
Add a link
Reference in a new issue