-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_usage.py
More file actions
executable file
·105 lines (78 loc) · 3.02 KB
/
Copy pathexample_usage.py
File metadata and controls
executable file
·105 lines (78 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env python3
"""
Example usage of the Arch Reggie registration checker package.
This script demonstrates the basic usage patterns shown in the README.
"""
import sys
from pathlib import Path
# Add the package to the path for development
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root / "src"))
from reggie import ProcessingConfig, RegistrationProcessor
from reggie.constants import get_default_config
def basic_usage_example():
"""Demonstrate basic usage with default configuration."""
print("=== Basic Usage Example ===")
# Initialize with default configuration (now works with the test CSV format)
processor = RegistrationProcessor()
# Process a CSV file (using test data)
csv_path = "tests/test_data/example_input.csv"
print(
f"Processing: {csv_path}\n"
"Using default configuration:\n"
f" Column names: {processor.config.column_names}\n"
f" Check registrations: {processor.config.check_registrations}\n"
)
results = processor.process_csv(csv_path)
# Save results as JSON
processor.save_json(results, "example_output.json")
print(f"Processed {len(results)} people")
print("Results saved to: example_output.json")
def custom_config_example():
"""Demonstrate usage with custom configuration."""
print("\n=== Custom Configuration Example ===")
# Method 1: Use the convenience function (recommended)
config = ProcessingConfig(
**get_default_config(
check_registrations=False, # Skip web scraping for faster testing
selenium_headless=False, # Show browser window for debugging
selenium_implicit_wait=3, # Faster timeouts
column_names=[
"email",
"name",
"linkedin",
"body",
"number",
"state",
], # Custom column names
)
)
# Method 2: Traditional way (still works)
# config = ProcessingConfig(
# check_registrations=False,
# selenium_headless=False,
# selenium_implicit_wait=3,
# output_format="json",
# )
processor = RegistrationProcessor(config=config)
# Show supported registration bodies
supported_bodies = processor.get_supported_bodies()
print(f"Supported registration bodies: {supported_bodies}")
print("Custom configuration:")
print(f" Check registrations: {config.check_registrations}")
print(f" Selenium headless: {config.selenium_headless}")
print(f" Default column names: {config.column_names}")
def main():
"""Run all examples."""
print("Arch Reggie - Example Usage")
print("=" * 40)
try:
basic_usage_example()
# custom_config_example()
print("\n✅ Examples completed successfully!")
except Exception as e: # noqa: BLE001 - top-level example entry point, print-and-continue
print(f"❌ Error running examples: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
main()