MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / initialize_csv

Method initialize_csv

shared.py:1485–1518  ·  view source on GitHub ↗

Initialize the network knowledge base CSV file with headers.

(self)

Source from the content-addressed store, hash-verified

1483 py_modules.add(filename[:-3])
1484 py_path = os.path.join(self.actions_dir, filename)
1485 if os.path.getmtime(py_path) > json_mtime:
1486 needs_regen = True
1487
1488 if not needs_regen:
1489 # Timestamps match — but verify no modules are missing
1490 try:
1491 with open(self.actions_file, 'r') as f:
1492 existing = json.load(f)
1493 json_modules = {a.get('b_module') for a in existing}
1494 # Modules that have .py files but no JSON entry may have
1495 # been skipped due to a transient import failure. Some
1496 # .py files are intentionally excluded (helpers without
1497 # b_class/b_status), so only flag if the count differs
1498 # significantly — or specifically if critical modules
1499 # like 'scanning' are absent.
1500 missing = py_modules - json_modules
1501 if missing:
1502 logger.info(f"actions.json missing modules {missing} — regenerating")
1503 needs_regen = True
1504 except Exception as e:
1505 logger.debug(f"Could not validate actions.json contents: {e}")
1506 needs_regen = True
1507
1508 if not needs_regen:
1509 # actions.json is up to date — just load status_list from it
1510 self._load_status_list_from_actions_json()
1511 logger.info("actions.json is up to date — skipped regeneration")
1512 return
1513 except Exception as e:
1514 logger.debug(f"Actions freshness check failed, regenerating: {e}")
1515 # Fall through: regenerate
1516 self.generate_actions_json()
1517
1518 def generate_actions_json(self):
1519 """Generate the actions JSON file, it will be used to store the actions configuration."""
1520 actions_dir = self.actions_dir
1521 actions_config = []

Callers 1

setup_environmentMethod · 0.95

Calls 2

infoMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected