95 lines
2.9 KiB
Python
95 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Example usage of the Pokemon Data Downloader
|
|
|
|
This script demonstrates how to use the pokemon_downloader.py tool
|
|
to download different types of Pokemon data from the PokeAPI.
|
|
"""
|
|
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
def run_command(cmd, description):
|
|
"""Run a command and print the description."""
|
|
print(f"\n{'='*60}")
|
|
print(f"Running: {description}")
|
|
print(f"Command: {' '.join(cmd)}")
|
|
print(f"{'='*60}")
|
|
|
|
result = subprocess.run(cmd, capture_output=True, text=True)
|
|
if result.returncode == 0:
|
|
print("✓ Success!")
|
|
if result.stdout:
|
|
print("Output:", result.stdout)
|
|
else:
|
|
print("✗ Failed!")
|
|
if result.stderr:
|
|
print("Error:", result.stderr)
|
|
sys.exit(1)
|
|
|
|
def main():
|
|
"""Demonstrate various usage examples of the Pokemon downloader."""
|
|
|
|
print("Pokemon Data Downloader - Usage Examples")
|
|
print("=========================================")
|
|
|
|
# Ensure we're in the right directory
|
|
if not Path("tools/data/pokemon_downloader.py").exists():
|
|
print("Error: Please run this script from the project root directory")
|
|
sys.exit(1)
|
|
|
|
# Example 1: Download type effectiveness for Generation I
|
|
run_command([
|
|
"python", "tools/data/pokemon_downloader.py",
|
|
"--generations", "generation-i",
|
|
"--data-types", "types"
|
|
], "Download type effectiveness for Generation I")
|
|
|
|
# Example 2: Download Pokemon data for multiple generations
|
|
run_command([
|
|
"python", "tools/data/pokemon_downloader.py",
|
|
"--generations", "generation-i,generation-ii",
|
|
"--data-types", "pokemon"
|
|
], "Download Pokemon data for Generations I and II")
|
|
|
|
# Example 3: Download moves data for Generation I
|
|
run_command([
|
|
"python", "tools/data/pokemon_downloader.py",
|
|
"--generations", "generation-i",
|
|
"--data-types", "moves"
|
|
], "Download moves data for Generation I")
|
|
|
|
# Example 4: Download all data types for one generation
|
|
run_command([
|
|
"python", "tools/data/pokemon_downloader.py",
|
|
"--generations", "generation-i",
|
|
"--all-data-types"
|
|
], "Download all data types for Generation I")
|
|
|
|
# Example 5: Download specific data to custom directory
|
|
custom_dir = "my_pokemon_data"
|
|
run_command([
|
|
"python", "tools/data/pokemon_downloader.py",
|
|
"--generations", "generation-i",
|
|
"--data-types", "types",
|
|
"--output-dir", custom_dir
|
|
], f"Download type data to custom directory: {custom_dir}")
|
|
|
|
# Show help
|
|
print(f"\n{'='*60}")
|
|
print("Available command line options:")
|
|
print(f"{'='*60}")
|
|
subprocess.run([
|
|
"python", "tools/data/pokemon_downloader.py", "--help"
|
|
])
|
|
|
|
print(f"\n{'='*60}")
|
|
print("Examples completed successfully!")
|
|
print("Check the 'data' directory for downloaded files.")
|
|
print(f"{'='*60}")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|