API Reference¶
This section documents all modules and functions in the sw-metadata-bot package.
Analysis Runtime Module¶
Low-level analysis workflow helpers for pipeline orchestration.
- sw_metadata_bot.analysis_runtime.extract_previous_commit(record)[source]¶
Return previous commit id from report records with compatibility fallback.
- sw_metadata_bot.analysis_runtime.resolve_per_repo_paths(analysis_root, repo_url)[source]¶
Compute per-repository output paths within the analysis root.
- sw_metadata_bot.analysis_runtime.copy_previous_repo_artifacts(previous_repo_folder, current_repo_folder)[source]¶
Copy previous snapshot repository artifacts into current snapshot folder.
- sw_metadata_bot.analysis_runtime.load_previous_repo_record(previous_snapshot_root, repo_url)[source]¶
Load previous per-repo record from previous snapshot if available.
- sw_metadata_bot.analysis_runtime.standardize_metacheck_outputs(repo_folder)[source]¶
Normalize metacheck output names to stable per-repo filenames.
- Parameters:
repo_folder (Path)
- Return type:
None
- sw_metadata_bot.analysis_runtime.run_metacheck_for_repo(repo_url, repo_folder, metacheck_command)[source]¶
Run metacheck for a single repository URL into its own folder.
- sw_metadata_bot.analysis_runtime.build_analysis_counters(records)[source]¶
Build analysis counters using the unified report schema.
- sw_metadata_bot.analysis_runtime.build_analysis_run_report(records, *, dry_run, run_root, analysis_summary_file, previous_report)[source]¶
Build run-level report payload from analysis decision records.
- sw_metadata_bot.analysis_runtime.detect_platform_from_repo_url(repo_url)[source]¶
Detect publish platform from repository URL.
- sw_metadata_bot.analysis_runtime.is_previous_issue_open(previous_record)[source]¶
Infer whether previous issue was open from stored metadata only.
- sw_metadata_bot.analysis_runtime.build_record_entry(*, run_root, repo_url, platform, pitfalls_count, warnings_count, analysis_date, metacheck_version, pitfalls_ids, warnings_ids, action, reason_code, findings_signature, current_commit_id, previous_commit_id, previous_issue_url, previous_issue_state, dry_run, issue_persistence, issue_url, file_path, error=None)[source]¶
Build a per-repository analysis record payload.
- Parameters:
run_root (Path)
repo_url (str)
platform (str | None)
pitfalls_count (int)
warnings_count (int)
analysis_date (str)
metacheck_version (str)
action (str)
reason_code (str)
findings_signature (str)
current_commit_id (str | None)
previous_commit_id (str | None)
previous_issue_url (str | None)
previous_issue_state (str | None)
dry_run (bool)
issue_persistence (str)
issue_url (str | None)
file_path (Path)
error (str | None)
- Return type:
- sw_metadata_bot.analysis_runtime.write_analysis_repo_report(repo_folder, record, *, dry_run, run_root, analysis_summary_file, previous_report)[source]¶
Write per-repository analysis report using analysis-stage counters.
Check Parsing Module¶
Shared parsing helpers for RSMetacheck check identifiers.
- sw_metadata_bot.check_parsing.get_check_catalog_id(check)[source]¶
Return full RSMetacheck catalog ID URL for a check when available.
Preferred source is the new schema key
assessesIndicator.@idwhen it points to the RSMetacheck catalog. For backward compatibility, this falls back to the legacypitfallkey.
- sw_metadata_bot.check_parsing.get_short_check_code(check)[source]¶
Return short check code such as P001 or W004.
Commit Lookup Module¶
Repository head commit lookup utilities.
- sw_metadata_bot.commit_lookup.parse_github_repo(repo_url)[source]¶
Parse owner/repo from a GitHub repository URL.
- sw_metadata_bot.commit_lookup.resolve_gitlab_project_path(repo_url)[source]¶
Parse host and project path for GitLab repositories.
- sw_metadata_bot.commit_lookup.is_commit_hash(value)[source]¶
Return True if value looks like a commit hash.
- sw_metadata_bot.commit_lookup.get_github_head_commit(repo_url, token=None)[source]¶
Fetch current head commit from GitHub API.
- sw_metadata_bot.commit_lookup.get_gitlab_head_commit(repo_url, token=None)[source]¶
Fetch current head commit from GitLab API for gitlab* hosts.
Config Utils Module¶
Helpers for the unified configuration file.
- sw_metadata_bot.config_utils.normalize_repo_url(url)[source]¶
Normalize repository URLs for matching and persistence.
- sw_metadata_bot.config_utils.detect_platform(url)[source]¶
Detect publishing platform from repository URL.
Returns
"github"for GitHub URLs,"gitlab"for any GitLab URL, orNonewhen the URL does not match a known platform.
- sw_metadata_bot.config_utils.load_config(config_path)[source]¶
Load and validate a unified configuration file.
- sw_metadata_bot.config_utils.get_repositories(config)[source]¶
Return normalized repositories preserving order and uniqueness.
- sw_metadata_bot.config_utils.get_custom_message(config)[source]¶
Return the configured issue custom message if present.
- sw_metadata_bot.config_utils.get_opt_out_repositories(config)[source]¶
Return normalized repository URLs configured as inline opt-outs.
- sw_metadata_bot.config_utils.append_opt_out_repository(config_path, repo_url)[source]¶
Persist a repository to the inline opt-outs list when not already present.
- sw_metadata_bot.config_utils.resolve_output_root(config, config_path)[source]¶
Return the configured output root, resolving relative paths from project root.
- sw_metadata_bot.config_utils.resolve_run_name(config, config_path)[source]¶
Return the configured run name or a sensible default.
- sw_metadata_bot.config_utils.resolve_snapshot_tag(config, explicit_snapshot_tag)[source]¶
Resolve the snapshot tag from CLI override or config defaults.
- sw_metadata_bot.config_utils.sanitize_repo_name(repo_url)[source]¶
Sanitize repository URL to a safe folder name format.
Uses a generic URL-safe transformation so non-standard URLs still map to deterministic folder names.
Create Issues Module¶
GitHub API Module¶
GitHub API client.
- class sw_metadata_bot.github_api.GitHubAPI(token=None, dry_run=False)[source]¶
Bases:
objectSimple GitHub API client.
- verify_auth()[source]¶
Verify authentication and return detailed information.
- Returns:
Dictionary with authentication details including user, scopes, and permissions.
- Return type:
GitLab API Module¶
GitLab API client.
- class sw_metadata_bot.gitlab_api.GitLabAPI(token=None, dry_run=False)[source]¶
Bases:
objectSimple GitLab API client.
History Module¶
Helpers for loading and querying previous issue reports.
- sw_metadata_bot.history.load_previous_report(report_path)[source]¶
Load report.json and index issue-lifecycle entries by repository URL.
Incremental Module¶
Decision engine for incremental issue lifecycle handling.
- class sw_metadata_bot.incremental.Decision(action, reason)[source]¶
Bases:
objectDecision outcome for a repository in incremental mode.
Main Module¶
CLI entry point for sw-metadata-bot.
MetaCheck Wrapper Module¶
Pipeline Module¶
Pipeline command to run analysis workflows.
Pitfalls Module¶
Pitfalls data loading and parsing.
- sw_metadata_bot.pitfalls.get_repository_url(data)[source]¶
Extract repository URL from pitfalls data.
- sw_metadata_bot.pitfalls.get_metacheck_version(data)[source]¶
Get the version of RSMetacheck used for analysis.
New schema (0.2.1+): Version is in checkingSoftware.softwareVersion Falls back to “unknown” if not found.
Publish Module¶
Publish issues from an existing analysis snapshot.
Token Resolver Module¶
Token resolution helpers for API clients.
Verify Tokens Module¶
Token verification command - check if tokens have correct permissions.