Debugsession N1
This commit is contained in:
parent
dfe6500141
commit
ce1d8c770c
@ -126,12 +126,15 @@ class SupplierSearchDelegate(QStyledItemDelegate):
|
|||||||
"""Loads the list of known suppliers from the JSON config file."""
|
"""Loads the list of known suppliers from the JSON config file."""
|
||||||
try:
|
try:
|
||||||
with open(SUPPLIERS_CONFIG_PATH, 'r') as f:
|
with open(SUPPLIERS_CONFIG_PATH, 'r') as f:
|
||||||
suppliers = json.load(f)
|
suppliers_data = json.load(f) # Renamed variable for clarity
|
||||||
if isinstance(suppliers, list):
|
if isinstance(suppliers_data, list):
|
||||||
# Ensure all items are strings
|
# Ensure all items are strings
|
||||||
return sorted([str(s) for s in suppliers if isinstance(s, str)])
|
return sorted([str(s) for s in suppliers_data if isinstance(s, str)])
|
||||||
else:
|
elif isinstance(suppliers_data, dict): # ADDED: Handle dictionary case
|
||||||
log.warning(f"'{SUPPLIERS_CONFIG_PATH}' does not contain a valid list. Starting fresh.")
|
# If it's a dictionary, extract keys as supplier names
|
||||||
|
return sorted([str(key) for key in suppliers_data.keys() if isinstance(key, str)])
|
||||||
|
else: # MODIFIED: Updated warning message
|
||||||
|
log.warning(f"'{SUPPLIERS_CONFIG_PATH}' does not contain a valid list or dictionary of suppliers. Starting fresh.")
|
||||||
return []
|
return []
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
log.info(f"'{SUPPLIERS_CONFIG_PATH}' not found. Starting with an empty supplier list.")
|
log.info(f"'{SUPPLIERS_CONFIG_PATH}' not found. Starting with an empty supplier list.")
|
||||||
|
|||||||
@ -20,7 +20,8 @@ script_dir = Path(__file__).parent
|
|||||||
project_root = script_dir.parent
|
project_root = script_dir.parent
|
||||||
PRESETS_DIR = project_root / "Presets"
|
PRESETS_DIR = project_root / "Presets"
|
||||||
TEMPLATE_PATH = PRESETS_DIR / "_template.json"
|
TEMPLATE_PATH = PRESETS_DIR / "_template.json"
|
||||||
APP_SETTINGS_PATH_LOCAL = project_root / "config" / "app_settings.json"
|
APP_SETTINGS_PATH_LOCAL = project_root / "config" / "app_settings.json" # Retain for other settings if used elsewhere
|
||||||
|
FILE_TYPE_DEFINITIONS_PATH = project_root / "config" / "file_type_definitions.json"
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -63,18 +64,19 @@ class PresetEditorWidget(QWidget):
|
|||||||
"""Loads FILE_TYPE_DEFINITIONS keys from app_settings.json."""
|
"""Loads FILE_TYPE_DEFINITIONS keys from app_settings.json."""
|
||||||
keys = []
|
keys = []
|
||||||
try:
|
try:
|
||||||
if APP_SETTINGS_PATH_LOCAL.is_file():
|
if FILE_TYPE_DEFINITIONS_PATH.is_file():
|
||||||
with open(APP_SETTINGS_PATH_LOCAL, 'r', encoding='utf-8') as f:
|
with open(FILE_TYPE_DEFINITIONS_PATH, 'r', encoding='utf-8') as f:
|
||||||
settings = json.load(f)
|
settings = json.load(f)
|
||||||
|
# The FILE_TYPE_DEFINITIONS key is at the root of file_type_definitions.json
|
||||||
ftd = settings.get("FILE_TYPE_DEFINITIONS", {})
|
ftd = settings.get("FILE_TYPE_DEFINITIONS", {})
|
||||||
keys = list(ftd.keys())
|
keys = list(ftd.keys())
|
||||||
log.debug(f"Successfully loaded {len(keys)} FILE_TYPE_DEFINITIONS keys.")
|
log.debug(f"Successfully loaded {len(keys)} FILE_TYPE_DEFINITIONS keys from {FILE_TYPE_DEFINITIONS_PATH}.")
|
||||||
else:
|
else:
|
||||||
log.error(f"app_settings.json not found at {APP_SETTINGS_PATH_LOCAL} for PresetEditorWidget.")
|
log.error(f"file_type_definitions.json not found at {FILE_TYPE_DEFINITIONS_PATH} for PresetEditorWidget.")
|
||||||
except json.JSONDecodeError as e:
|
except json.JSONDecodeError as e:
|
||||||
log.error(f"Failed to parse app_settings.json in PresetEditorWidget: {e}")
|
log.error(f"Failed to parse file_type_definitions.json in PresetEditorWidget: {e}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error(f"Error loading FILE_TYPE_DEFINITIONS keys in PresetEditorWidget: {e}")
|
log.error(f"Error loading FILE_TYPE_DEFINITIONS keys from {FILE_TYPE_DEFINITIONS_PATH} in PresetEditorWidget: {e}")
|
||||||
return keys
|
return keys
|
||||||
|
|
||||||
def _init_ui(self):
|
def _init_ui(self):
|
||||||
|
|||||||
@ -552,6 +552,13 @@ class UnifiedViewModel(QAbstractItemModel):
|
|||||||
supplier_col_index = self.createIndex(existing_source_row, self.COL_SUPPLIER, existing_source_rule)
|
supplier_col_index = self.createIndex(existing_source_row, self.COL_SUPPLIER, existing_source_rule)
|
||||||
self.dataChanged.emit(supplier_col_index, supplier_col_index, [Qt.DisplayRole, Qt.EditRole])
|
self.dataChanged.emit(supplier_col_index, supplier_col_index, [Qt.DisplayRole, Qt.EditRole])
|
||||||
|
|
||||||
|
# Always update the preset_name from the new_source_rule, as this reflects the latest prediction context
|
||||||
|
if existing_source_rule.preset_name != new_source_rule.preset_name:
|
||||||
|
log.debug(f" Updating preset_name for SourceRule '{source_path}' from '{existing_source_rule.preset_name}' to '{new_source_rule.preset_name}'")
|
||||||
|
existing_source_rule.preset_name = new_source_rule.preset_name
|
||||||
|
# Note: preset_name is not directly displayed in the view, so no dataChanged needed for a specific column,
|
||||||
|
# but if it influenced other display elements, dataChanged would be emitted for those.
|
||||||
|
|
||||||
|
|
||||||
# --- Merge AssetRules ---
|
# --- Merge AssetRules ---
|
||||||
existing_assets_dict = {asset.asset_name: asset for asset in existing_source_rule.assets}
|
existing_assets_dict = {asset.asset_name: asset for asset in existing_source_rule.assets}
|
||||||
|
|||||||
8
main.py
8
main.py
@ -4,6 +4,7 @@ import time
|
|||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import re # Added for checking incrementing token
|
||||||
from concurrent.futures import ProcessPoolExecutor, as_completed
|
from concurrent.futures import ProcessPoolExecutor, as_completed
|
||||||
import subprocess
|
import subprocess
|
||||||
import shutil
|
import shutil
|
||||||
@ -238,9 +239,14 @@ class ProcessingTask(QRunnable):
|
|||||||
# output_dir should already be a Path object
|
# output_dir should already be a Path object
|
||||||
pattern = getattr(config, 'output_directory_pattern', None)
|
pattern = getattr(config, 'output_directory_pattern', None)
|
||||||
if pattern:
|
if pattern:
|
||||||
log.debug(f"Calculating next incrementing value for dir: {output_dir} using pattern: {pattern}")
|
# Only call get_next_incrementing_value if the pattern contains an incrementing token
|
||||||
|
if re.search(r"\[IncrementingValue\]|#+", pattern):
|
||||||
|
log.debug(f"Incrementing token found in pattern '{pattern}'. Calculating next value for dir: {output_dir}")
|
||||||
next_increment_str = get_next_incrementing_value(output_dir, pattern)
|
next_increment_str = get_next_incrementing_value(output_dir, pattern)
|
||||||
log.info(f"Calculated next incrementing value for {output_dir}: {next_increment_str}")
|
log.info(f"Calculated next incrementing value for {output_dir}: {next_increment_str}")
|
||||||
|
else:
|
||||||
|
log.debug(f"No incrementing token found in pattern '{pattern}'. Skipping increment calculation.")
|
||||||
|
next_increment_str = None # Or a default like "00" if downstream expects a string, but None is cleaner if handled.
|
||||||
else:
|
else:
|
||||||
log.warning(f"Cannot calculate incrementing value: 'output_directory_pattern' not found in configuration for preset {config.preset_name}")
|
log.warning(f"Cannot calculate incrementing value: 'output_directory_pattern' not found in configuration for preset {config.preset_name}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
12
monitor.py
12
monitor.py
@ -195,17 +195,25 @@ def _process_archive_task(archive_path: Path, output_dir: Path, processed_dir: P
|
|||||||
# Assuming config object has 'output_directory_pattern' attribute/key
|
# Assuming config object has 'output_directory_pattern' attribute/key
|
||||||
pattern = getattr(config, 'output_directory_pattern', None) # Use getattr for safety
|
pattern = getattr(config, 'output_directory_pattern', None) # Use getattr for safety
|
||||||
if pattern:
|
if pattern:
|
||||||
log.debug(f"[Task:{archive_path.name}] Calculating next incrementing value for dir: {output_dir} using pattern: {pattern}")
|
if re.search(r"\[IncrementingValue\]|#+", pattern):
|
||||||
|
log.debug(f"[Task:{archive_path.name}] Incrementing token found in pattern '{pattern}'. Calculating next value for dir: {output_dir}")
|
||||||
next_increment_str = get_next_incrementing_value(output_dir, pattern)
|
next_increment_str = get_next_incrementing_value(output_dir, pattern)
|
||||||
log.info(f"[Task:{archive_path.name}] Calculated next incrementing value: {next_increment_str}")
|
log.info(f"[Task:{archive_path.name}] Calculated next incrementing value: {next_increment_str}")
|
||||||
|
else:
|
||||||
|
log.debug(f"[Task:{archive_path.name}] No incrementing token found in pattern '{pattern}'. Skipping increment calculation.")
|
||||||
|
next_increment_str = None
|
||||||
else:
|
else:
|
||||||
# Check if config is a dict as fallback (depends on load_config implementation)
|
# Check if config is a dict as fallback (depends on load_config implementation)
|
||||||
if isinstance(config, dict):
|
if isinstance(config, dict):
|
||||||
pattern = config.get('output_directory_pattern')
|
pattern = config.get('output_directory_pattern')
|
||||||
if pattern:
|
if pattern:
|
||||||
log.debug(f"[Task:{archive_path.name}] Calculating next incrementing value for dir: {output_dir} using pattern (from dict): {pattern}")
|
if re.search(r"\[IncrementingValue\]|#+", pattern):
|
||||||
|
log.debug(f"[Task:{archive_path.name}] Incrementing token found in pattern '{pattern}' (from dict). Calculating next value for dir: {output_dir}")
|
||||||
next_increment_str = get_next_incrementing_value(output_dir, pattern)
|
next_increment_str = get_next_incrementing_value(output_dir, pattern)
|
||||||
log.info(f"[Task:{archive_path.name}] Calculated next incrementing value (from dict): {next_increment_str}")
|
log.info(f"[Task:{archive_path.name}] Calculated next incrementing value (from dict): {next_increment_str}")
|
||||||
|
else:
|
||||||
|
log.debug(f"[Task:{archive_path.name}] No incrementing token found in pattern '{pattern}' (from dict). Skipping increment calculation.")
|
||||||
|
next_increment_str = None
|
||||||
else:
|
else:
|
||||||
log.warning(f"[Task:{archive_path.name}] Cannot calculate incrementing value: 'output_directory_pattern' not found in configuration dictionary.")
|
log.warning(f"[Task:{archive_path.name}] Cannot calculate incrementing value: 'output_directory_pattern' not found in configuration dictionary.")
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user