diff --git a/.github/workflows/GenerateReport-Dev.yml b/.github/workflows/GenerateReport-Dev.yml index eddcd94..87b620b 100644 --- a/.github/workflows/GenerateReport-Dev.yml +++ b/.github/workflows/GenerateReport-Dev.yml @@ -1,13 +1,15 @@ name: Generate Report (Dev) on: + schedule: + - cron: '0 0 * * MON,THU' workflow_dispatch: push: branches: - dev paths: - '**.py' - - '.github/workflows/GenerateReport-Dev.yml' + - '.github/workflows/GenerateReport.yml' - '.github/workflows/PythonSetup/**' - '.github/workflows/RcloneSetup/**' - '.env' @@ -22,7 +24,7 @@ permissions: jobs: healthcheck: name: Health Check - runs-on: self-hosted + runs-on: ubuntu-latest environment: WT_WeeklyTriggerEnv steps: - name: Checkout repository @@ -40,6 +42,14 @@ jobs: - name: DEBUG - Print config.env run: grep -E '^(FULL_RELOAD_PACKAGES|BASE_PACKAGE_CSV|REQUIREMENTS_FILE)=' .env || true + - name: Set up rclone + uses: ./.github/workflows/RcloneSetup + with: + rclone_conf_base64: ${{ secrets.RCLONE_CONF_BASE64 }} + + - name: DEBUG - Check rclone connection + run: rclone lsd gdrive:/Geek/PythonPackageManager/WeeklyReports/ + generate-report: name: Generate Weekly Report runs-on: self-hosted @@ -94,4 +104,225 @@ jobs: echo "โŒ Push failed. Someone else may have pushed changes. Please re-run the workflow." exit 1 } - + + create-weekly-release: + name: Create Weekly Report Release + runs-on: ubuntu-latest + environment: WT_WeeklyTriggerEnv + needs: generate-report + if: success() + + steps: + - name: Install GitHub CLI + run: | + sudo apt-get update + sudo apt-get install -y gh + + - name: Checkout latest commit from main + run: | + git init + git remote add origin https://github.com/${{ github.repository }} + git fetch origin dev + git checkout origin/dev + + - name: Find latest report set + id: find_latest + run: | + echo "๐Ÿ“ Scanning for latest report set..." + latest_json=$(find WeeklyReport -type f -name "WeeklyReport_*.json" | \ + sed -E 's/\.json$//' | \ + sort -t '_' -k2 | \ + tail -n 1).json + + if [[ -z "$latest_json" || ! -f "$latest_json" ]]; then + echo "โŒ No valid JSON report found." + exit 1 + fi + + base_name="${latest_json%.json}" + csv_file="${base_name}.csv" + html_file="${base_name}.html" + + echo "๐Ÿ“ Latest base: $base_name" + echo "๐Ÿ“„ CSV: $csv_file" + echo "๐Ÿ“„ HTML: $html_file" + echo "๐Ÿ“„ JSON: $latest_json" + + echo "CSV_PATH=$csv_file" >> $GITHUB_ENV + echo "HTML_PATH=$html_file" >> $GITHUB_ENV + echo "JSON_PATH=$latest_json" >> $GITHUB_ENV + + echo "CSV_FILENAME=$(basename "$csv_file")" >> $GITHUB_ENV + echo "HTML_FILENAME=$(basename "$html_file")" >> $GITHUB_ENV + echo "JSON_FILENAME=$(basename "$latest_json")" >> $GITHUB_ENV + + # ๐Ÿ—“๏ธ Get the Monday of current week + MONDAY_DATE=$(date -d "$(date +%Y-%m-%d -d @$(( $(date +%s) - ($(date +%u) - 1) * 86400 )))" +%Y%m%d) + echo "๐Ÿ“… This week's Monday: $MONDAY_DATE" + + # ๐Ÿ” Find existing tags in this week and determine Ver{x} + existing_tags=$(gh release list --limit 100 --json tagName | jq -r ".[] | .tagName" | grep -E "^weekly-${MONDAY_DATE}-Ver[0-9]+$" || true) + max_ver=$(echo "$existing_tags" | grep -oE 'Ver[0-9]+' | sed 's/Ver//' | sort -n | tail -n 1) + + if [[ -z "$max_ver" ]]; then + new_ver=1 + else + new_ver=$((max_ver + 1)) + fi + + tag="weekly-${MONDAY_DATE}-Ver${new_ver}" + echo "๐Ÿ†• Release tag: $tag" + + echo "RELEASE_TAG=$tag" >> $GITHUB_ENV + echo "release_tag=$tag" >> $GITHUB_OUTPUT + env: + GH_TOKEN: ${{ secrets.GH_PAT }} + + - name: Create GitHub Release + run: | + gh release create "$RELEASE_TAG" \ + "$CSV_PATH#${CSV_FILENAME}" \ + "$HTML_PATH#${HTML_FILENAME}" \ + "$JSON_PATH#${JSON_FILENAME}" \ + --title "Weekly Report - $RELEASE_TAG" \ + --notes "Automated weekly report" + env: + GH_TOKEN: ${{ secrets.GH_PAT }} + + - name: Remove old releases from last week (keep Ver1 and latest) + run: | + # โฑ๏ธ Calculate last Monday date + LAST_MONDAY=$(date -d "last monday" +%Y%m%d) + echo "๐Ÿงน Cleaning up releases from last week: $LAST_MONDAY" + + # ๐Ÿ” Find all tags that fits weekly-LAST_MONDAY-Ver{X} + matching_tags=$(gh release list --limit 100 --json tagName,createdAt | \ + jq -r ".[] | select(.tagName | test(\"^weekly-${LAST_MONDAY}-Ver[0-9]+\")).tagName") + + if [[ -z "$matching_tags" ]]; then + echo "โ„น๏ธ No matching tags found for last week." + exit 0 + fi + + echo "๐Ÿ” All matching tags:" + echo "$matching_tags" + + # Extract all tags + versions=$(echo "$matching_tags" | sed -nE "s/^weekly-${LAST_MONDAY}-Ver([0-9]+)$/\1/p" | sort -n) + + # Get biggest ver + max_ver=$(echo "$versions" | tail -n 1) + echo "๐Ÿ†• Max version: Ver$max_ver" + + for tag in $matching_tags; do + ver=$(echo "$tag" | sed -nE "s/^weekly-${LAST_MONDAY}-Ver([0-9]+)$/\1/p") + + if [[ "$ver" == "1" || "$ver" == "$max_ver" ]]; then + echo "โœ… Keeping $tag" + continue + fi + + echo "๐Ÿ—‘๏ธ Deleting $tag" + gh release delete "$tag" --yes || echo "โš ๏ธ Failed to delete release $tag" + if git ls-remote --tags origin | grep -q "refs/tags/$tag$"; then + echo "๐Ÿ”– Tag $tag exists. Deleting..." + gh api -X DELETE "repos/${{ github.repository }}/git/refs/tags/$tag" || echo "โš ๏ธ Failed to delete tag ref $tag" + else + echo "โ„น๏ธ Tag $tag does not exist. Skipping tag deletion." + fi + done + env: + GH_TOKEN: ${{ secrets.GH_PAT }} + + create-monthly-release: + name: Create Monthly Report Release + runs-on: ubuntu-latest + environment: WT_WeeklyTriggerEnv + needs: generate-report + if: success() + steps: + - name: Install GitHub CLI + run: | + sudo apt-get update + sudo apt-get install -y gh jq + + - name: Checkout latest commit from main + run: | + git init + git remote add origin https://github.com/${{ github.repository }} + git fetch origin dev + git checkout origin/dev + + - name: Find latest monthly report + id: find_latest_monthly + run: | + echo "๐Ÿ” Scanning for latest MonthlyReport..." + latest_file=$(find MonthlyReport -type f -name "MonthlyReport-*.xlsx" | sort | tail -n 1) + + if [[ -z "$latest_file" || ! -f "$latest_file" ]]; then + echo "โŒ No monthly report found." + exit 1 + fi + + echo "โœ… Found: $latest_file" + + filename=$(basename "$latest_file") + year_month=$(echo "$filename" | grep -oP '(?<=MonthlyReport-)[0-9]{6}') + + echo "๐Ÿ“ฆ Scanning existing monthly tags with prefix: monthly-${year_month}-Ver" + + existing_tags=$(gh release list --limit 100 --json tagName | jq -r ".[] | .tagName" | grep -E "^monthly-${year_month}-Ver[0-9]+$" || true) + + max_ver=$(echo "$existing_tags" | grep -oE 'Ver[0-9]+' | sed 's/Ver//' | sort -n | tail -n 1) + + if [[ -z "$max_ver" ]]; then + new_ver=1 + else + new_ver=$((max_ver + 1)) + fi + + tag="monthly-${year_month}-Ver${new_ver}" + echo "๐Ÿ†• New tag: $tag" + + echo "RELEASE_TAG=$tag" >> $GITHUB_ENV + echo "REPORT_FILE=$latest_file" >> $GITHUB_ENV + echo "REPORT_NAME=$filename" >> $GITHUB_ENV + env: + GH_TOKEN: ${{ secrets.GH_PAT }} + + - name: Create GitHub Release + run: | + gh release create "$RELEASE_TAG" \ + "$REPORT_FILE#${REPORT_NAME}" \ + --title "Monthly Report - $RELEASE_TAG" \ + --notes "Automated monthly report" + env: + GH_TOKEN: ${{ secrets.GH_PAT }} + + - name: Remove old releases for the same month + run: | + echo "๐Ÿงน Cleaning up other releases for the same month..." + + current_month_prefix=$(echo "${{ env.RELEASE_TAG }}" | grep -oP 'monthly-\K[0-9]{6}') + + gh release list --limit 100 --json tagName,createdAt | \ + jq -c '.[] | select(.tagName | test("^monthly-'$current_month_prefix'$"))' | \ + while read line; do + tag=$(echo "$line" | jq -r '.tagName') + + if [[ "$tag" == "${{ env.RELEASE_TAG }}" ]]; then + echo "โญ๏ธ Skipping current release: $tag" + continue + fi + + echo "๐Ÿ—‘๏ธ Deleting other release from the same month: $tag" + gh release delete "$tag" --yes || echo "โš ๏ธ Failed to delete release $tag" + if git ls-remote --tags origin | grep -q "refs/tags/$tag$"; then + echo "๐Ÿ”– Tag $tag exists. Deleting..." + gh api -X DELETE "repos/${{ github.repository }}/git/refs/tags/$tag" || echo "โš ๏ธ Failed to delete tag ref $tag" + else + echo "โ„น๏ธ Tag $tag does not exist. Skipping tag deletion." + fi + done + env: + GH_TOKEN: ${{ secrets.GH_PAT }} diff --git a/.github/workflows/GenerateReport.yml b/.github/workflows/GenerateReport.yml index 63c6dc1..43cedba 100644 --- a/.github/workflows/GenerateReport.yml +++ b/.github/workflows/GenerateReport.yml @@ -301,7 +301,12 @@ jobs: echo "๐Ÿ—‘๏ธ Deleting $tag" gh release delete "$tag" --yes || echo "โš ๏ธ Failed to delete release $tag" - gh api -X DELETE "repos/${{ github.repository }}/git/refs/tags/$tag" || echo "โš ๏ธ Failed to delete tag ref $tag" + if git ls-remote --tags origin | grep -q "refs/tags/$tag$"; then + echo "๐Ÿ”– Tag $tag exists. Deleting..." + gh api -X DELETE "repos/${{ github.repository }}/git/refs/tags/$tag" || echo "โš ๏ธ Failed to delete tag ref $tag" + else + echo "โ„น๏ธ Tag $tag does not exist. Skipping tag deletion." + fi done env: GH_TOKEN: ${{ secrets.GH_PAT }} @@ -362,6 +367,14 @@ jobs: env: GH_TOKEN: ${{ secrets.GH_PAT }} + - name: Create GitHub Release + run: | + gh release create "$RELEASE_TAG" \ + "$REPORT_FILE#${REPORT_NAME}" \ + --title "Monthly Report - $RELEASE_TAG" \ + --notes "Automated monthly report" + env: + GH_TOKEN: ${{ secrets.GH_PAT }} - name: Remove old releases for the same month run: | @@ -381,16 +394,12 @@ jobs: echo "๐Ÿ—‘๏ธ Deleting other release from the same month: $tag" gh release delete "$tag" --yes || echo "โš ๏ธ Failed to delete release $tag" - gh api -X DELETE "repos/${{ github.repository }}/git/refs/tags/$tag" || echo "โš ๏ธ Failed to delete tag ref $tag" + if git ls-remote --tags origin | grep -q "refs/tags/$tag$"; then + echo "๐Ÿ”– Tag $tag exists. Deleting..." + gh api -X DELETE "repos/${{ github.repository }}/git/refs/tags/$tag" || echo "โš ๏ธ Failed to delete tag ref $tag" + else + echo "โ„น๏ธ Tag $tag does not exist. Skipping tag deletion." + fi done env: GH_TOKEN: ${{ secrets.GH_PAT }} - - - name: Create GitHub Release - run: | - gh release create "$RELEASE_TAG" \ - "$REPORT_FILE#${REPORT_NAME}" \ - --title "Monthly Report - $RELEASE_TAG" \ - --notes "Automated monthly report" - env: - GH_TOKEN: ${{ secrets.GH_PAT }} diff --git a/MonthlyReport/2025-06/MonthlyReport-202506-04-1116.xlsx b/MonthlyReport/2025-06/MonthlyReport-202506-04-1116.xlsx new file mode 100644 index 0000000..255a132 Binary files /dev/null and b/MonthlyReport/2025-06/MonthlyReport-202506-04-1116.xlsx differ diff --git a/MonthlyReport/2025-06/MonthlyReport-202506-04-1120.xlsx b/MonthlyReport/2025-06/MonthlyReport-202506-04-1120.xlsx new file mode 100644 index 0000000..def7ee0 Binary files /dev/null and b/MonthlyReport/2025-06/MonthlyReport-202506-04-1120.xlsx differ diff --git a/WeeklyReport/2025-06-02/WeeklyReport_20250604_111614.csv b/WeeklyReport/2025-06-02/WeeklyReport_20250604_111614.csv new file mode 100644 index 0000000..ecd9f8d --- /dev/null +++ b/WeeklyReport/2025-06-02/WeeklyReport_20250604_111614.csv @@ -0,0 +1,2 @@ +๏ปฟPackage Name,Package Type,Custodian,Current Version,Dependencies for Current,Newer Versions,Dependencies for Latest,Latest Version,Current Version Vulnerable?,Current Version Vulnerability Details,Upgrade Version Vulnerable?,Upgrade Vulnerability Details,Suggested Upgrade,Upgrade Instruction,Remarks +absl-py,Dependency Package,I&S,2.1.0,,"2.2.0, 2.2.1, 2.2.2, 2.3.0",,2.3.0,No,,No,None,2.3.0,"{'base_package': 'absl-py==2.3.0', 'dependencies': []}", diff --git a/WeeklyReport/2025-06-02/WeeklyReport_20250604_111614.html b/WeeklyReport/2025-06-02/WeeklyReport_20250604_111614.html new file mode 100644 index 0000000..eda40c0 --- /dev/null +++ b/WeeklyReport/2025-06-02/WeeklyReport_20250604_111614.html @@ -0,0 +1,234 @@ + + + + + Weekly Python Package Report +

Report generated at 2025-06-04 11:16:15 +08

+ + + + + + + +

Dependency Upgrade Report

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Package NamePackage TypeCustodianCurrent VersionDependencies for CurrentNewer VersionsDependencies for LatestLatest VersionCurrent Version Vulnerable?Current Version Vulnerability DetailsUpgrade Version Vulnerable?Upgrade Vulnerability DetailsSuggested UpgradeUpgrade InstructionRemarks
Package NamePackage TypeCustodianCurrent VersionDependencies for CurrentNewer VersionsDependencies for LatestLatest VersionCurrent Version Vulnerable?Current Version Vulnerability DetailsUpgrade Version Vulnerable?Upgrade Vulnerability DetailsSuggested UpgradeUpgrade InstructionRemarks
absl-pyDependency PackageI&S2.1.02.2.0, 2.2.1, 2.2.2, 2.3.02.3.0NoNoNone2.3.0{'base_package': 'absl-py==2.3.0', 'dependencies': []}
+ + + + \ No newline at end of file diff --git a/WeeklyReport/2025-06-02/WeeklyReport_20250604_111614.json b/WeeklyReport/2025-06-02/WeeklyReport_20250604_111614.json new file mode 100644 index 0000000..9e573bc --- /dev/null +++ b/WeeklyReport/2025-06-02/WeeklyReport_20250604_111614.json @@ -0,0 +1,22 @@ +[ + { + "Package Name": "absl-py", + "Package Type": "Dependency Package", + "Custodian": "I&S", + "Current Version": "2.1.0", + "Dependencies for Current": "", + "Newer Versions": "2.2.0, 2.2.1, 2.2.2, 2.3.0", + "Dependencies for Latest": "", + "Latest Version": "2.3.0", + "Current Version Vulnerable?": "No", + "Current Version Vulnerability Details": "", + "Upgrade Version Vulnerable?": "No", + "Upgrade Vulnerability Details": "None", + "Suggested Upgrade": "2.3.0", + "Upgrade Instruction": { + "base_package": "absl-py==2.3.0", + "dependencies": [] + }, + "Remarks": "" + } +] \ No newline at end of file diff --git a/WeeklyReport/2025-06-02/WeeklyReport_20250604_112037.csv b/WeeklyReport/2025-06-02/WeeklyReport_20250604_112037.csv new file mode 100644 index 0000000..ecd9f8d --- /dev/null +++ b/WeeklyReport/2025-06-02/WeeklyReport_20250604_112037.csv @@ -0,0 +1,2 @@ +๏ปฟPackage Name,Package Type,Custodian,Current Version,Dependencies for Current,Newer Versions,Dependencies for Latest,Latest Version,Current Version Vulnerable?,Current Version Vulnerability Details,Upgrade Version Vulnerable?,Upgrade Vulnerability Details,Suggested Upgrade,Upgrade Instruction,Remarks +absl-py,Dependency Package,I&S,2.1.0,,"2.2.0, 2.2.1, 2.2.2, 2.3.0",,2.3.0,No,,No,None,2.3.0,"{'base_package': 'absl-py==2.3.0', 'dependencies': []}", diff --git a/WeeklyReport/2025-06-02/WeeklyReport_20250604_112037.html b/WeeklyReport/2025-06-02/WeeklyReport_20250604_112037.html new file mode 100644 index 0000000..9566bfd --- /dev/null +++ b/WeeklyReport/2025-06-02/WeeklyReport_20250604_112037.html @@ -0,0 +1,234 @@ + + + + + Weekly Python Package Report +

Report generated at 2025-06-04 11:20:38 +08

+ + + + + + + +

Dependency Upgrade Report

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Package NamePackage TypeCustodianCurrent VersionDependencies for CurrentNewer VersionsDependencies for LatestLatest VersionCurrent Version Vulnerable?Current Version Vulnerability DetailsUpgrade Version Vulnerable?Upgrade Vulnerability DetailsSuggested UpgradeUpgrade InstructionRemarks
Package NamePackage TypeCustodianCurrent VersionDependencies for CurrentNewer VersionsDependencies for LatestLatest VersionCurrent Version Vulnerable?Current Version Vulnerability DetailsUpgrade Version Vulnerable?Upgrade Vulnerability DetailsSuggested UpgradeUpgrade InstructionRemarks
absl-pyDependency PackageI&S2.1.02.2.0, 2.2.1, 2.2.2, 2.3.02.3.0NoNoNone2.3.0{'base_package': 'absl-py==2.3.0', 'dependencies': []}
+ + + + \ No newline at end of file diff --git a/WeeklyReport/2025-06-02/WeeklyReport_20250604_112037.json b/WeeklyReport/2025-06-02/WeeklyReport_20250604_112037.json new file mode 100644 index 0000000..9e573bc --- /dev/null +++ b/WeeklyReport/2025-06-02/WeeklyReport_20250604_112037.json @@ -0,0 +1,22 @@ +[ + { + "Package Name": "absl-py", + "Package Type": "Dependency Package", + "Custodian": "I&S", + "Current Version": "2.1.0", + "Dependencies for Current": "", + "Newer Versions": "2.2.0, 2.2.1, 2.2.2, 2.3.0", + "Dependencies for Latest": "", + "Latest Version": "2.3.0", + "Current Version Vulnerable?": "No", + "Current Version Vulnerability Details": "", + "Upgrade Version Vulnerable?": "No", + "Upgrade Vulnerability Details": "None", + "Suggested Upgrade": "2.3.0", + "Upgrade Instruction": { + "base_package": "absl-py==2.3.0", + "dependencies": [] + }, + "Remarks": "" + } +] \ No newline at end of file diff --git a/src/requirements_test_list.txt b/src/requirements_test_list.txt new file mode 100644 index 0000000..1369d64 --- /dev/null +++ b/src/requirements_test_list.txt @@ -0,0 +1 @@ +absl-py==2.1.0 \ No newline at end of file diff --git a/utils/ConfigUtils.py b/utils/ConfigUtils.py index 5dfd1e6..fc0f246 100644 --- a/utils/ConfigUtils.py +++ b/utils/ConfigUtils.py @@ -118,20 +118,20 @@ def load_base_packages() -> set: logger.warning(f"Failed to load base package list: {e}") return base_set -def parse_requirements(requirements_file: str) -> dict: +def parse_requirements(RequirementsFile: str) -> dict: """ Parse a requirements.txt file into a dictionary. Supports basic parsing of version constraints like ==, >=, <=, ~=, !=. Args: - requirements_file (str): Path to a pip requirements file. + RequirementsFile (str): Path to a pip requirements file. Returns: dict: Mapping of package names to their specified version strings. """ pkgs = {} - with open(requirements_file, encoding='utf-8') as f: + with open(RequirementsFile, encoding='utf-8') as f: for line in f: line = line.strip() if not line or line.startswith('#'): @@ -140,7 +140,7 @@ def parse_requirements(requirements_file: str) -> dict: m = re.search(r"(==|>=|<=|~=|!=)(.+)", line) ver = m.group(2).strip() if m else 'unknown' pkgs[name] = ver - logger.info(f"Parsed {len(pkgs)} packages from {requirements_file}") + logger.info(f"Parsed {len(pkgs)} packages from {RequirementsFile}") return pkgs def extract_dependencies(info: dict) -> list: diff --git a/utils/CustodianUtils.py b/utils/CustodianUtils.py index cfeae4f..a234c98 100644 --- a/utils/CustodianUtils.py +++ b/utils/CustodianUtils.py @@ -57,15 +57,15 @@ def load_custodian_map(path: str) -> dict: reader = csv.DictReader(f) for row in reader: pkg = row.get("Package Name", "").strip().lower() - custodian = row.get("Custodian", "").strip() - pkg_type = row.get("Package Type", "").strip() + Custodian = row.get("Custodian", "").strip() + PkgType = row.get("Package Type", "").strip() if pkg: - mapping[pkg] = (custodian, pkg_type) + mapping[pkg] = (Custodian, PkgType) except Exception as e: logger.error(f"Failed to load custodian map: {e}") return mapping -def custom_sort_key(row: dict, custom_order: dict) -> tuple: +def custom_sort_key(row: dict, CustomOrder: dict) -> tuple: """ Generate a composite sorting key for a package report row based on custodian and package type. @@ -76,18 +76,18 @@ def custom_sort_key(row: dict, custom_order: dict) -> tuple: Args: row (dict): A dictionary representing a single row in the report. - custom_order (dict): Mapping from custodian name to sort rank (e.g. {"Org1": 0, "Org2": 1}). + CustomOrder (dict): Mapping from custodian name to sort rank (e.g. {"Org1": 0, "Org2": 1}). Returns: - tuple: Sorting key as (custodian_rank, package_type_rank, package_name_lower) + tuple: Sorting key as (CustodianRank, package_type_rank, package_name_lower) """ - custodian = row.get("Custodian", "") - custodian_rank = custom_order.get(custodian, len(custom_order)) + Custodian = row.get("Custodian", "") + CustodianRank = CustomOrder.get(Custodian, len(CustomOrder)) type_order = {"Base Package": 0, "Dependency Package": 1} - pkg_type = row.get("Package Type", "") - pkg_type_rank = type_order.get(pkg_type, 2) + PkgType = row.get("Package Type", "") + PkgTypeRank = type_order.get(PkgType, 2) - pkg_name = row.get("Package Name", "").lower() + PkgName = row.get("Package Name", "").lower() - return (custodian_rank, pkg_type_rank, pkg_name) \ No newline at end of file + return (CustodianRank, PkgTypeRank, PkgName) \ No newline at end of file diff --git a/utils/UpgradeInstruction.py b/utils/UpgradeInstruction.py index 37aa5ad..30b8d7c 100644 --- a/utils/UpgradeInstruction.py +++ b/utils/UpgradeInstruction.py @@ -126,13 +126,13 @@ async def get_safe_dependency_versions(dependencies: list[str]) -> dict[str, str except Exception as e: logger.warning(f"Failed to schedule version check for {dep}: {e}") - safe_versions = await asyncio.gather(*tasks, return_exceptions=True) + SafeVersions = await asyncio.gather(*tasks, return_exceptions=True) # fill in real values - for (pkg_name, safe) in zip(results.keys(), safe_versions): + for (PkgName, safe) in zip(results.keys(), SafeVersions): if isinstance(safe, Exception) or safe in (None, "Up-to-date"): continue - results[pkg_name] = safe + results[PkgName] = safe return results @@ -152,11 +152,11 @@ def generate_upgrade_instruction(base_package: str, target_version: str) -> dict # logger.info(f"{base_package}=={target_version} requires: {requires_dist}") # Use asyncio.run to avoid 'event loop already running' issues - safe_versions = asyncio.run(get_safe_dependency_versions(requires_dist)) + SafeVersions = asyncio.run(get_safe_dependency_versions(requires_dist)) instruction = { "base_package": f"{base_package}=={target_version}", - "dependencies": [f"{k}=={v}" for k, v in safe_versions.items() if v] + "dependencies": [f"{k}=={v}" for k, v in SafeVersions.items() if v] } return instruction