🔍 Code Extractor

class Config

Maturity: 31

Configuration class for SharePoint to FileCloud sync application.

File:
/tf/active/vicechatdev/SPFCsync/config.py
Lines:
9 - 72
Complexity:
moderate

Purpose

Configuration class for SharePoint to FileCloud sync application.

Source Code

class Config:
    """Configuration class for SharePoint to FileCloud sync application."""
    
    # SharePoint Configuration
    SHAREPOINT_SITE_URL = os.getenv('SHAREPOINT_SITE_URL')
    AZURE_CLIENT_ID = os.getenv('AZURE_CLIENT_ID')
    AZURE_CLIENT_SECRET = os.getenv('AZURE_CLIENT_SECRET')
    SHAREPOINT_DOCUMENTS_PATH = os.getenv('SHAREPOINT_DOCUMENTS_PATH', '/Shared Documents')
    
    # FileCloud Configuration
    FILECLOUD_SERVER_URL = os.getenv('FILECLOUD_SERVER_URL')
    FILECLOUD_USERNAME = os.getenv('FILECLOUD_USERNAME')
    FILECLOUD_PASSWORD = os.getenv('FILECLOUD_PASSWORD')
    FILECLOUD_BASE_PATH = os.getenv('FILECLOUD_BASE_PATH', '/SHARED/SharePointSync')
    
    # Sync Configuration
    SYNC_INTERVAL_MINUTES = int(os.getenv('SYNC_INTERVAL_MINUTES', 30))
    LOG_LEVEL = os.getenv('LOG_LEVEL', 'INFO')
    TIMEZONE = ZoneInfo(os.getenv('TIMEZONE', 'Europe/Brussels'))
    SKIP_DIRECT_DOWNLOAD = os.getenv('SKIP_DIRECT_DOWNLOAD', 'false').lower() == 'true'
    CREATE_EMPTY_FOLDERS = os.getenv('CREATE_EMPTY_FOLDERS', 'false').lower() == 'true'
    DATE_COMPARISON_TOLERANCE_SECONDS = int(os.getenv('DATE_COMPARISON_TOLERANCE_SECONDS', 10))
    
    # Logging Configuration
    LOG_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
    LOG_FILE = 'spfc_sync.log'
    
    @classmethod
    def validate_config(cls):
        """Validate that all required configuration values are set."""
        required_configs = [
            ('SHAREPOINT_SITE_URL', cls.SHAREPOINT_SITE_URL),
            ('AZURE_CLIENT_ID', cls.AZURE_CLIENT_ID),
            ('AZURE_CLIENT_SECRET', cls.AZURE_CLIENT_SECRET),
            ('FILECLOUD_SERVER_URL', cls.FILECLOUD_SERVER_URL),
            ('FILECLOUD_USERNAME', cls.FILECLOUD_USERNAME),
            ('FILECLOUD_PASSWORD', cls.FILECLOUD_PASSWORD)
        ]
        
        missing_configs = []
        for config_name, config_value in required_configs:
            if not config_value:
                missing_configs.append(config_name)
        
        if missing_configs:
            raise ValueError(f"Missing required configuration: {', '.join(missing_configs)}")
        
        return True
    
    @classmethod
    def setup_logging(cls):
        """Setup logging configuration."""
        numeric_level = getattr(logging, cls.LOG_LEVEL.upper(), None)
        if not isinstance(numeric_level, int):
            raise ValueError(f'Invalid log level: {cls.LOG_LEVEL}')
        
        logging.basicConfig(
            level=numeric_level,
            format=cls.LOG_FORMAT,
            handlers=[
                logging.FileHandler(cls.LOG_FILE),
                logging.StreamHandler()
            ]
        )

Parameters

Name Type Default Kind
bases - -

Parameter Details

bases: Parameter of type

Return Value

Returns unspecified type

Class Interface

Methods

validate_config(cls)

Purpose: Validate that all required configuration values are set.

Parameters:

  • cls: Parameter

Returns: None

setup_logging(cls)

Purpose: Setup logging configuration.

Parameters:

  • cls: Parameter

Returns: None

Required Imports

import os
from dotenv import load_dotenv
import logging
from zoneinfo import ZoneInfo

Usage Example

# Example usage:
# result = Config(bases)

Tags

class config

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class SharePointFileCloudSync 70.2% similar

    Orchestrates synchronization of documents from SharePoint to FileCloud, managing the complete sync lifecycle including document retrieval, comparison, upload, and folder structure creation.

    From: /tf/active/vicechatdev/SPFCsync/sync_service.py
  • class AppConfiguration 68.0% similar

    AppConfiguration is a minimal entity class representing SharePoint application configuration settings, inheriting from the Entity base class.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/viva/app_configuration.py
  • class SharePointClient 64.7% similar

    A SharePoint client class that provides methods for connecting to SharePoint sites, retrieving documents recursively, downloading file content, and managing document metadata using app-only authentication.

    From: /tf/active/vicechatdev/SPFCsync/sharepoint_client.py
  • class SyncDiagnostics 61.2% similar

    A diagnostic class that analyzes and reports on synchronization issues between SharePoint and FileCloud, identifying missing files and root causes of sync failures.

    From: /tf/active/vicechatdev/SPFCsync/deep_diagnostics.py
  • function main_v9 59.0% similar

    Main entry point for a SharePoint to FileCloud synchronization application that handles command-line arguments, connection testing, and orchestrates single or continuous sync operations.

    From: /tf/active/vicechatdev/SPFCsync/main.py
← Back to Browse