remove my own details from repo. use config
This commit is contained in:
		
							parent
							
								
									03a65a2244
								
							
						
					
					
						commit
						9fe3937d88
					
				@ -11,7 +11,8 @@ class Config:
 | 
			
		||||
        Args:
 | 
			
		||||
            config_path (str): Path to the TOML configuration file
 | 
			
		||||
        """
 | 
			
		||||
        self.project_root = Path(__file__).resolve().parent
 | 
			
		||||
        config_dir = Path(__file__).resolve().parent
 | 
			
		||||
        self.project_root = config_dir.parent
 | 
			
		||||
        self.config_path = self.project_root / config_file
 | 
			
		||||
        self._load_config()
 | 
			
		||||
 | 
			
		||||
@ -28,8 +29,6 @@ class Config:
 | 
			
		||||
        self.api_key_file = self.project_root.joinpath(
 | 
			
		||||
            "keys", config_data["api"]["key_file"])
 | 
			
		||||
        self.host = config_data["api"]["host"]
 | 
			
		||||
 | 
			
		||||
        # Load API key
 | 
			
		||||
        self._load_api_key()
 | 
			
		||||
 | 
			
		||||
    def _load_api_key(self):
 | 
			
		||||
@ -37,8 +36,8 @@ class Config:
 | 
			
		||||
        if not self.api_key_file.exists():
 | 
			
		||||
            raise FileNotFoundError(f"API key file not found: {self.api_key_file}")
 | 
			
		||||
 | 
			
		||||
        with open(self.api_key_file, 'r') as key_file:
 | 
			
		||||
            self.api_key = key_file.read().strip()
 | 
			
		||||
        with (open(self.api_key_file, 'r') as key_file):
 | 
			
		||||
            self.api_key = key_file.read().strip().replace('\n', '').replace('\r', '')
 | 
			
		||||
 | 
			
		||||
    def get_headers(self):
 | 
			
		||||
        """Return headers for API requests"""
 | 
			
		||||
 | 
			
		||||
@ -1,15 +1,12 @@
 | 
			
		||||
import requests
 | 
			
		||||
 | 
			
		||||
from config.configuration import Config
 | 
			
		||||
 | 
			
		||||
host = 'forum.lunduke.com'
 | 
			
		||||
username = 'gmgauthier'
 | 
			
		||||
url = f"https://{host}/posts.json"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
with open('../keys/cli_key.txt', 'r') as key:
 | 
			
		||||
    api_key = key.read()
 | 
			
		||||
api_key = api_key.replace('\n', '').replace('\r', '')
 | 
			
		||||
cfg = Config()
 | 
			
		||||
 | 
			
		||||
username = cfg.username
 | 
			
		||||
url = cfg.get_api_url(endpoint='/site.json')
 | 
			
		||||
api_key = cfg.api_key
 | 
			
		||||
 | 
			
		||||
headers={
 | 
			
		||||
    "api_key": api_key,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user