| """Data handling for NexForge Tokenizer.""" | |
| import os | |
| from pathlib import Path | |
| from typing import Optional | |
| def get_data_path() -> Path: | |
| """Get the path to the package data directory.""" | |
| return Path(__file__).parent | |
| def get_sample_data_path() -> Optional[Path]: | |
| """Get the path to the sample Python code file.""" | |
| data_path = get_data_path() / "python_code_sample.txt" | |
| return data_path if data_path.exists() else None | |
| def load_sample_data() -> Optional[str]: | |
| """Load and return the sample Python code as a string.""" | |
| sample_path = get_sample_data_path() | |
| if sample_path is None: | |
| return None | |
| return sample_path.read_text(encoding='utf-8') | |