diff --git a/backend/parsers/windmill-parser-py-imports/src/lib.rs b/backend/parsers/windmill-parser-py-imports/src/lib.rs index 77324f2384..f0c8a4c41a 100644 --- a/backend/parsers/windmill-parser-py-imports/src/lib.rs +++ b/backend/parsers/windmill-parser-py-imports/src/lib.rs @@ -6,11 +6,13 @@ * LICENSE-AGPL for a copy of the license. */ +mod mapping; + use async_recursion::async_recursion; use itertools::Itertools; use lazy_static::lazy_static; -use phf::phf_map; +use mapping::{FULL_IMPORTS_MAP, SHORT_IMPORTS_MAP}; #[cfg(not(target_arch = "wasm32"))] use regex::Regex; #[cfg(target_arch = "wasm32")] @@ -25,57 +27,18 @@ use windmill_common::{error, worker::PythonAnnotations}; const DEF_MAIN: &str = "def main("; -static PYTHON_IMPORTS_REPLACEMENT: phf::Map<&'static str, &'static str> = phf_map! { - "psycopg2" => "psycopg2-binary", - "psycopg" => "psycopg[binary, pool]", - "yaml" => "pyyaml", - "git" => "GitPython", - "shopify" => "ShopifyAPI", - "seleniumwire" => "selenium-wire", - "openbb-terminal" => "openbb[all]", - "riskfolio" => "riskfolio-lib", - "smb" => "pysmb", - "PIL" => "Pillow", - "googleapiclient" => "google-api-python-client", - "googlecloudbigquery" => "google-cloud-bigquery", - "dateutil" => "python-dateutil", - "mailparser" => "mail-parser", - "mailparser-reply" => "mail-parser-reply", - "gitlab" => "python-gitlab", - "smbclient" => "smbprotocol", - "playhouse" => "peewee", - "dns" => "dnspython", - "msoffcrypto" => "msoffcrypto-tool", - "tabula" => "tabula-py", - "shapefile" => "pyshp", - "sklearn" => "scikit-learn", - "umap" => "umap-learn", - "cv2" => "opencv-python", - "atlassian" => "atlassian-python-api", - "mysql" => "mysql-connector-python", - "tenable" => "pytenable", - "ns1" => "ns1-python", - "pymsql" => "PyMySQL", - "haystack" => "haystack-ai", - "github" => "PyGithub", - "ldap" => "python-ldap", - "opensearchpy" => "opensearch-py", - "lokalise" => "python-lokalise-api", - "msgraph" => "msgraph-sdk", - "pythonjsonlogger" => "python-json-logger", - "socks" => "PySocks", - "taiga" => "python-taiga", - "docx" => "python-docx", -}; - fn replace_import(x: String) -> String { - PYTHON_IMPORTS_REPLACEMENT + SHORT_IMPORTS_MAP .get(&x) .map(|x| x.to_owned()) .unwrap_or(&x) .to_string() } +fn replace_full_import(x: &str) -> Option { + FULL_IMPORTS_MAP.get(x).map(|x| (*x).to_owned()) +} + lazy_static! { static ref RE: Regex = Regex::new(r"^\#\s?(\S+)\s*$").unwrap(); } @@ -99,7 +62,7 @@ fn process_import(module: Option, path: &str, level: usize) -> Vec; + +/// In some cases inferring requirement from import is not possible. +/// That's why we need to map import to requirement ident. +/// These two maps allows us to do so. + +/// import x.y.z +/// ^^^^^ replaces entire x.y.z import with [?] +/// +pub static FULL_IMPORTS_MAP: PyMap = phf_map! { + // import => requirement + "google.cloud.bigquery_storage" => "google-cloud-bigquery-storage", + "google.cloud.bigquery" => "google-cloud-bigquery", + "google.cloud.parametermanager" => "google-cloud-parametermanager", + "google.cloud.oracledatabase" => "google-cloud-oracledatabase", + "google.cloud.deploy" => "google-cloud-deploy", + "google.cloud.pubsub" => "google-cloud-pubsub", + "google.cloud.workflows" => "google-cloud-workflows", + "google.cloud.managedkafka" => "google-cloud-managedkafka", + "google.cloud.iam" => "google-cloud-iam", + "google.cloud.documentai" => "google-cloud-documentai", + "google.cloud.dlp" => "google-cloud-dlp", + "google.cloud.compute" => "google-cloud-compute", + "google.cloud.alloydb" => "google-cloud-alloydb", + "google.cloud.aiplatform" => "google-cloud-aiplatform", + "google.cloud.bigtable" => "google-cloud-bigtable", + "google.cloud.workstations" => "google-cloud-workstations", + "google.cloud.websecurityscanner" => "google-cloud-websecurityscanner", + "google.cloud.webrisk" => "google-cloud-webrisk", + "google.cloud.vmwareengine" => "google-cloud-vmwareengine", + "google.cloud.visionai" => "google-cloud-visionai", + "google.cloud.vision" => "google-cloud-vision", + "google.cloud.videointelligence" => "google-cloud-videointelligence", + "google.cloud.translate" => "google-cloud-translate", + "google.cloud.trace" => "google-cloud-trace", + "google.cloud.tpu" => "google-cloud-tpu", + "google.cloud.texttospeech" => "google-cloud-texttospeech", + "google.cloud.telcoautomation" => "google-cloud-telcoautomation", + "google.cloud.tasks" => "google-cloud-tasks", + "google.cloud.talent" => "google-cloud-talent", + "google.cloud.support" => "google-cloud-support", + "google.cloud.storageinsights" => "google-cloud-storageinsights", + "google.cloud.speech" => "google-cloud-speech", + "google.cloud.shell" => "google-cloud-shell", + "google.cloud.servicehealth" => "google-cloud-servicehealth", + "google.cloud.securitycentermanagement" => "google-cloud-securitycentermanagement", + "google.cloud.securitycenter" => "google-cloud-securitycenter", + "google.cloud.securesourcemanager" => "google-cloud-securesourcemanager", + "google.cloud.scheduler" => "google-cloud-scheduler", + "google.cloud.run" => "google-cloud-run", + "google.cloud.retail" => "google-cloud-retail", + "google.cloud.recommender" => "google-cloud-recommender", + "google.cloud.rapidmigrationassessment" => "google-cloud-rapidmigrationassessment", + "google.cloud.privilegedaccessmanager" => "google-cloud-privilegedaccessmanager", + "google.cloud.policytroubleshooter_iam" => "google-cloud-policytroubleshooter-iam", + "google.cloud.policysimulator" => "google-cloud-policysimulator", + "google.cloud.parallelstore" => "google-cloud-parallelstore", + "google.cloud.optimization" => "google-cloud-optimization", + "google.cloud.notebooks" => "google-cloud-notebooks", + "google.cloud.network_services" => "google-cloud-network-services", + "google.cloud.network_security" => "google-cloud-network-security", + "google.cloud.netapp" => "google-cloud-netapp", + "google.cloud.monitoring" => "google-cloud-monitoring", + "google.cloud.modelarmor" => "google-cloud-modelarmor", + "google.cloud.migrationcenter" => "google-cloud-migrationcenter", + "google.cloud.memorystore" => "google-cloud-memorystore", + "google.cloud.memcache" => "google-cloud-memcache", + "google.cloud.language" => "google-cloud-language", + "google.cloud.kms" => "google-cloud-kms", + "google.cloud.kms_inventory" => "google-cloud-kms-inventory", + "google.cloud.ids" => "google-cloud-ids", + "google.cloud.iap" => "google-cloud-iap", + "google.cloud.gsuiteaddons" => "google-cloud-gsuiteaddons", + "google.cloud.gke_multicloud" => "google-cloud-gke-multicloud", + "google.cloud.gke_backup" => "google-cloud-gke-backup", + "google.cloud.gdchardwaremanagement" => "google-cloud-gdchardwaremanagement", + "google.cloud.functions" => "google-cloud-functions", + "google.cloud.financialservices" => "google-cloud-financialservices", + "google.cloud.filestore" => "google-cloud-filestore", + "google.cloud.eventarc" => "google-cloud-eventarc", + "google.cloud.eventarc_publishing" => "google-cloud-eventarc-publishing", + "google.cloud.essential_contacts" => "google-cloud-essential-contacts", + "google.cloud.enterpriseknowledgegraph" => "google-cloud-enterpriseknowledgegraph", + "google.cloud.edgenetwork" => "google-cloud-edgenetwork", + "google.cloud.edgecontainer" => "google-cloud-edgecontainer", + "google.cloud.domains" => "google-cloud-domains", + "google.cloud.discoveryengine" => "google-cloud-discoveryengine", + "google.cloud.dialogflow" => "google-cloud-dialogflow", + "google.cloud.developerconnect" => "google-cloud-developerconnect", + "google.cloud.datastream" => "google-cloud-datastream", + "google.cloud.dataproc" => "google-cloud-dataproc", + "google.cloud.dataplex" => "google-cloud-dataplex", + "google.cloud.datalabeling" => "google-cloud-datalabeling", + "google.cloud.dataform" => "google-cloud-dataform", + "google.cloud.datacatalog" => "google-cloud-datacatalog", + "google.cloud.datacatalog_lineage" => "google-cloud-datacatalog-lineage", + "google.cloud.data_fusion" => "google-cloud-data-fusion", + "google.cloud.contentwarehouse" => "google-cloud-contentwarehouse", + "google.cloud.container" => "google-cloud-container", + "google.cloud.config" => "google-cloud-config", + "google.cloud.confidentialcomputing" => "google-cloud-confidentialcomputing", + "google.cloud.common" => "google-cloud-common", + "google.cloud.cloudcontrolspartner" => "google-cloud-cloudcontrolspartner", + "google.cloud.channel" => "google-cloud-channel", + "google.cloud.certificate_manager" => "google-cloud-certificate-manager", + "google.cloud.billing" => "google-cloud-billing", + "google.cloud.bigquery_migration" => "google-cloud-bigquery-migration", + "google.cloud.bigquery_logging" => "google-cloud-bigquery-logging", + "google.cloud.bigquery_datatransfer" => "google-cloud-bigquery-datatransfer", + "google.cloud.bigquery_datapolicies" => "google-cloud-bigquery-datapolicies", + "google.cloud.bigquery_connection" => "google-cloud-bigquery-connection", + "google.cloud.bigquery_biglake" => "google-cloud-bigquery-biglake", + "google.cloud.bigquery_analyticshub" => "google-cloud-bigquery-analyticshub", + "google.cloud.beyondcorp_clientgateways" => "google-cloud-beyondcorp-clientgateways", + "google.cloud.beyondcorp_clientconnectorservices" => "google-cloud-beyondcorp-clientconnectorservices", + "google.cloud.beyondcorp_appgateways" => "google-cloud-beyondcorp-appgateways", + "google.cloud.beyondcorp_appconnectors" => "google-cloud-beyondcorp-appconnectors", + "google.cloud.beyondcorp_appconnections" => "google-cloud-beyondcorp-appconnections", + "google.cloud.batch" => "google-cloud-batch", + "google.cloud.bare_metal_solution" => "google-cloud-bare-metal-solution", + "google.cloud.backupdr" => "google-cloud-backupdr", + "google.cloud.automl" => "google-cloud-automl", + "google.cloud.asset" => "google-cloud-asset", + "google.cloud.apphub" => "google-cloud-apphub", + "google.cloud.apihub" => "google-cloud-apihub", + "google.cloud.advisorynotifications" => "google-cloud-advisorynotifications", + "google.cloud.spanner" => "google-cloud-spanner", + "google.cloud.storage" => "google-cloud-storage", + "google.cloud.firestore" => "google-cloud-firestore", + "google.cloud.pubsublite" => "google-cloud-pubsublite", + "google.cloud.datastore" => "google-cloud-datastore", + "google.cloud.ndb" => "google-cloud-ndb", + "google.cloud.dns" => "google-cloud-dns", + "google.cloud.runtimeconfig" => "google-cloud-runtimeconfig", + "google.cloud.iot" => "google-cloud-iot", + // Azure + "azure.mgmt.hybridkubernetes" => "azure-mgmt-hybridkubernetes", + "azure.mgmt.sql" => "azure-mgmt-sql", + "azure.mgmt.compute" => "azure-mgmt-compute", + "azure.mgmt.eventgrid" => "azure-mgmt-eventgrid", + "azure.mgmt.containerservice" => "azure-mgmt-containerservice", + "azure.mgmt.databox" => "azure-mgmt-databox", + "azure.mgmt.keyvault" => "azure-mgmt-keyvault", + "azure.mgmt.applicationinsights" => "azure-mgmt-applicationinsights", + "azure.mgmt.storage" => "azure-mgmt-storage", + "azure.mgmt.quota" => "azure-mgmt-quota", + "azure.mgmt.nginx" => "azure-mgmt-nginx", + "azure.mgmt.netapp" => "azure-mgmt-netapp", + "azure.mgmt.resource" => "azure-mgmt-resource", + "azure.mgmt.containerregistry" => "azure-mgmt-containerregistry", + "azure.mgmt.databoxedge" => "azure-mgmt-databoxedge", + "azure.mgmt.logz" => "azure-mgmt-logz", + "azure.mgmt.monitor" => "azure-mgmt-monitor", + "azure.mgmt.servicenetworking" => "azure-mgmt-servicenetworking", + "azure.mgmt.kusto" => "azure-mgmt-kusto", + "azure.mgmt.web" => "azure-mgmt-web", + "azure.mgmt.eventhub" => "azure-mgmt-eventhub", + "azure.mgmt.redis" => "azure-mgmt-redis", + "azure.mgmt.cosmosdb" => "azure-mgmt-cosmosdb", + "azure.mgmt.network" => "azure-mgmt-network", + "azure.mgmt.cognitiveservices" => "azure-mgmt-cognitiveservices", + "azure.mgmt.servicefabricmanagedclusters" => "azure-mgmt-servicefabricmanagedclusters", + "azure.mgmt.datafactory" => "azure-mgmt-datafactory", + "azure.mgmt.hybridcompute" => "azure-mgmt-hybridcompute", + "azure.mgmt.servicebus" => "azure-mgmt-servicebus", + "azure.mgmt.marketplaceordering" => "azure-mgmt-marketplaceordering", + "azure.mgmt.managedservices" => "azure-mgmt-managedservices", + "azure.mgmt.managementgroups" => "azure-mgmt-managementgroups", + "azure.mgmt.loganalytics" => "azure-mgmt-loganalytics", + "azure.mgmt.automation" => "azure-mgmt-automation", + "azure.mgmt.devtestlabs" => "azure-mgmt-devtestlabs", + "azure.mgmt.documentdb" => "azure-mgmt-documentdb", + "azure.mgmt.scheduler" => "azure-mgmt-scheduler", + "azure.mgmt.core" => "azure-mgmt-core", + "azure.mgmt.servermanager" => "azure-mgmt-servermanager", + "azure.mgmt.batchai" => "azure-mgmt-batchai", + "azure.mgmt.extendedlocation" => "azure-mgmt-extendedlocation", + "azure.mgmt.digitaltwins" => "azure-mgmt-digitaltwins", + "azure.mgmt.appconfiguration" => "azure-mgmt-appconfiguration", + "azure.mgmt.edgeorder" => "azure-mgmt-edgeorder", + "azure.mgmt.resourcehealth" => "azure-mgmt-resourcehealth", + "azure.mgmt.redhatopenshift" => "azure-mgmt-redhatopenshift", + "azure.mgmt.appplatform" => "azure-mgmt-appplatform", + "azure.mgmt.appcontainers" => "azure-mgmt-appcontainers", + "azure.mgmt.elastic" => "azure-mgmt-elastic", + "azure.mgmt.dnsresolver" => "azure-mgmt-dnsresolver", + "azure.mgmt.containerinstance" => "azure-mgmt-containerinstance", + "azure.mgmt.elasticsan" => "azure-mgmt-elasticsan", + "azure.mgmt.dns" => "azure-mgmt-dns", + "azure.mgmt.redisenterprise" => "azure-mgmt-redisenterprise", + "azure.mgmt.servicelinker" => "azure-mgmt-servicelinker", + "azure.mgmt.rdbms" => "azure-mgmt-rdbms", + "azure.mgmt.batch" => "azure-mgmt-batch", + "azure.mgmt.avs" => "azure-mgmt-avs", + "azure.mgmt.webpubsub" => "azure-mgmt-webpubsub", + "azure.mgmt.desktopvirtualization" => "azure-mgmt-desktopvirtualization", + "azure.mgmt.privatedns" => "azure-mgmt-privatedns", + "azure.mgmt.hdinsight" => "azure-mgmt-hdinsight", + "azure.mgmt.billing" => "azure-mgmt-billing", + "azure.mgmt.azurestackhci" => "azure-mgmt-azurestackhci", + "azure.mgmt.dataprotection" => "azure-mgmt-dataprotection", + "azure.mgmt.search" => "azure-mgmt-search", + "azure.mgmt.appcomplianceautomation" => "azure-mgmt-appcomplianceautomation", + "azure.mgmt.scvmm" => "azure-mgmt-scvmm", + "azure.mgmt.powerbiembedded" => "azure-mgmt-powerbiembedded", + "azure.mgmt.imagebuilder" => "azure-mgmt-imagebuilder", + "azure.mgmt.storagemover" => "azure-mgmt-storagemover", + "azure.mgmt.mobilenetwork" => "azure-mgmt-mobilenetwork", + "azure.mgmt.cdn" => "azure-mgmt-cdn", + "azure.mgmt.storagecache" => "azure-mgmt-storagecache", + "azure.mgmt.maintenance" => "azure-mgmt-maintenance", + "azure.mgmt.security" => "azure-mgmt-security", + "azure.mgmt.devcenter" => "azure-mgmt-devcenter", + "azure.mgmt.support" => "azure-mgmt-support", + "azure.mgmt.recoveryservicesbackup" => "azure-mgmt-recoveryservicesbackup", + "azure.mgmt.recoveryservices" => "azure-mgmt-recoveryservices", + "azure.mgmt.confidentialledger" => "azure-mgmt-confidentialledger", + "azure.mgmt.healthcareapis" => "azure-mgmt-healthcareapis", + "azure.mgmt.frontdoor" => "azure-mgmt-frontdoor", + "azure.mgmt.notificationhubs" => "azure-mgmt-notificationhubs", + "azure.mgmt.quantum" => "azure-mgmt-quantum", + "azure.mgmt.apimanagement" => "azure-mgmt-apimanagement", + "azure.mgmt.communication" => "azure-mgmt-communication", + "azure.mgmt.newrelicobservability" => "azure-mgmt-newrelicobservability", + "azure.mgmt.confluent" => "azure-mgmt-confluent", + "azure.mgmt.chaos" => "azure-mgmt-chaos", + "azure.mgmt.recoveryservicessiterecovery" => "azure-mgmt-recoveryservicessiterecovery", + "azure.mgmt.servicefabric" => "azure-mgmt-servicefabric", + "azure.mgmt.hybridcontainerservice" => "azure-mgmt-hybridcontainerservice", + "azure.mgmt.streamanalytics" => "azure-mgmt-streamanalytics", + "azure.mgmt.deviceupdate" => "azure-mgmt-deviceupdate", + "azure.mgmt.hybridnetwork" => "azure-mgmt-hybridnetwork", + "azure.mgmt.dashboard" => "azure-mgmt-dashboard", + "azure.mgmt.connectedvmware" => "azure-mgmt-connectedvmware", + "azure.mgmt.datadog" => "azure-mgmt-datadog", + "azure.mgmt.baremetalinfrastructure" => "azure-mgmt-baremetalinfrastructure", + "azure.mgmt.signalr" => "azure-mgmt-signalr", + "azure.mgmt.resourcemover" => "azure-mgmt-resourcemover", + "azure.mgmt.kubernetesconfiguration" => "azure-mgmt-kubernetesconfiguration", + "azure.mgmt.iothub" => "azure-mgmt-iothub", + "azure.mgmt.maps" => "azure-mgmt-maps", + "azure.mgmt.devspaces" => "azure-mgmt-devspaces", + "azure.mgmt.dynatrace" => "azure-mgmt-dynatrace", + "azure.mgmt.resourceconnector" => "azure-mgmt-resourceconnector", + "azure.mgmt.authorization" => "azure-mgmt-authorization", + "azure.mgmt.costmanagement" => "azure-mgmt-costmanagement", + "azure.mgmt.databricks" => "azure-mgmt-databricks", + "azure.mgmt.graphservices" => "azure-mgmt-graphservices", + "azure.mgmt.iothubprovisioningservices" => "azure-mgmt-iothubprovisioningservices", + "azure.mgmt.sqlvirtualmachine" => "azure-mgmt-sqlvirtualmachine", + "azure.mgmt.trafficmanager" => "azure-mgmt-trafficmanager", + "azure.mgmt.agfood" => "azure-mgmt-agfood", + "azure.mgmt.azureadb2c" => "azure-mgmt-azureadb2c", + "azure.mgmt.voiceservices" => "azure-mgmt-voiceservices", + "azure.mgmt.machinelearningservices" => "azure-mgmt-machinelearningservices", + "azure.mgmt.workloads" => "azure-mgmt-workloads", + "azure.mgmt.reservations" => "azure-mgmt-reservations", + "azure.mgmt.orbital" => "azure-mgmt-orbital", + "azure.mgmt.defendereasm" => "azure-mgmt-defendereasm", + "azure.mgmt.msi" => "azure-mgmt-msi", + "azure.mgmt.synapse" => "azure-mgmt-synapse", + "azure.mgmt.commerce" => "azure-mgmt-commerce", + "azure.mgmt.loadtesting" => "azure-mgmt-loadtesting", + "azure.mgmt.botservice" => "azure-mgmt-botservice", + "azure.mgmt.media" => "azure-mgmt-media", + "azure.mgmt.securitydevops" => "azure-mgmt-securitydevops", + "azure.mgmt.policyinsights" => "azure-mgmt-policyinsights", + "azure.mgmt.securityinsight" => "azure-mgmt-securityinsight", + "azure.mgmt.subscription" => "azure-mgmt-subscription", + "azure.mgmt.agrifood" => "azure-mgmt-agrifood", + "azure.mgmt.resourcegraph" => "azure-mgmt-resourcegraph", + "azure.mgmt.alertsmanagement" => "azure-mgmt-alertsmanagement", + "azure.mgmt.labservices" => "azure-mgmt-labservices", + "azure.mgmt.fluidrelay" => "azure-mgmt-fluidrelay", + "azure.mgmt.automanage" => "azure-mgmt-automanage", + "azure.mgmt.billingbenefits" => "azure-mgmt-billingbenefits", + "azure.mgmt.education" => "azure-mgmt-education", + "azure.mgmt.consumption" => "azure-mgmt-consumption", + "azure.mgmt.workloadmonitor" => "azure-mgmt-workloadmonitor", + "azure.mgmt.iotcentral" => "azure-mgmt-iotcentral", + "azure.mgmt.datamigration" => "azure-mgmt-datamigration", + "azure.mgmt.azurearcdata" => "azure-mgmt-azurearcdata", + "azure.mgmt.azurestack" => "azure-mgmt-azurestack", + "azure.mgmt.networkfunction" => "azure-mgmt-networkfunction", + "azure.mgmt.oep" => "azure-mgmt-oep", + "azure.mgmt.storagepool" => "azure-mgmt-storagepool", + "azure.mgmt.relay" => "azure-mgmt-relay", + "azure.mgmt.purview" => "azure-mgmt-purview", + "azure.mgmt.vmwarecloudsimple" => "azure-mgmt-vmwarecloudsimple", + "azure.mgmt.guestconfig" => "azure-mgmt-guestconfig", + "azure.mgmt.testbase" => "azure-mgmt-testbase", + "azure.mgmt.logic" => "azure-mgmt-logic", + "azure.mgmt.storageimportexport" => "azure-mgmt-storageimportexport", + "azure.mgmt.managementpartner" => "azure-mgmt-managementpartner", + "azure.mgmt.serialconsole" => "azure-mgmt-serialconsole", + "azure.mgmt.portal" => "azure-mgmt-portal", + "azure.mgmt.deploymentmanager" => "azure-mgmt-deploymentmanager", + "azure.mgmt.machinelearningcompute" => "azure-mgmt-machinelearningcompute", + "azure.mgmt.mixedreality" => "azure-mgmt-mixedreality", + "azure.mgmt.peering" => "azure-mgmt-peering", + "azure.mgmt.storagesync" => "azure-mgmt-storagesync", + "azure.mgmt.customproviders" => "azure-mgmt-customproviders", + "azure.mgmt.hanaonazure" => "azure-mgmt-hanaonazure", + "azure.mgmt.datashare" => "azure-mgmt-datashare", + "azure.mgmt.powerbidedicated" => "azure-mgmt-powerbidedicated", + "azure.mgmt.timeseriesinsights" => "azure-mgmt-timeseriesinsights", + "azure.mgmt.healthbot" => "azure-mgmt-healthbot", + "azure.mgmt.attestation" => "azure-mgmt-attestation", + "azure.mgmt.advisor" => "azure-mgmt-advisor", + "azure.mgmt.operationsmanagement" => "azure-mgmt-operationsmanagement", + "azure.mgmt.videoanalyzer" => "azure-mgmt-videoanalyzer", + "azure.mgmt.app" => "azure-mgmt-app", + "azure.mgmt.changeanalysis" => "azure-mgmt-changeanalysis", + "azure.mgmt.regionmove" => "azure-mgmt-regionmove", + "azure.mgmt.edgegateway" => "azure-mgmt-edgegateway", + "azure.mgmt.nspkg" => "azure-mgmt-nspkg", + // Add new entry here ^ +}; + +/// import x.y.z +/// ^ replaces x with [?] +/// +/// Additional rules: +/// 1. in x "_" are replaced with "-" +/// 2. If full imports had a hit, this one will not be called +pub static SHORT_IMPORTS_MAP: PyMap = phf_map! { + // import => requirement + "psycopg2" => "psycopg2-binary", + "psycopg" => "psycopg[binary, pool]", + "yaml" => "pyyaml", + "git" => "GitPython", + "shopify" => "ShopifyAPI", + "seleniumwire" => "selenium-wire", + "openbb-terminal" => "openbb[all]", + "riskfolio" => "riskfolio-lib", + "smb" => "pysmb", + "PIL" => "Pillow", + "googleapiclient" => "google-api-python-client", + "googlecloudbigquery" => "google-cloud-bigquery", + "dateutil" => "python-dateutil", + "mailparser" => "mail-parser", + "mailparser-reply" => "mail-parser-reply", + "gitlab" => "python-gitlab", + "smbclient" => "smbprotocol", + "playhouse" => "peewee", + "dns" => "dnspython", + "msoffcrypto" => "msoffcrypto-tool", + "tabula" => "tabula-py", + "shapefile" => "pyshp", + "sklearn" => "scikit-learn", + "umap" => "umap-learn", + "cv2" => "opencv-python", + "atlassian" => "atlassian-python-api", + "mysql" => "mysql-connector-python", + "tenable" => "pytenable", + "ns1" => "ns1-python", + "pymsql" => "PyMySQL", + "haystack" => "haystack-ai", + "github" => "PyGithub", + "ldap" => "python-ldap", + "opensearchpy" => "opensearch-py", + "lokalise" => "python-lokalise-api", + "msgraph" => "msgraph-sdk", + "pythonjsonlogger" => "python-json-logger", + "socks" => "PySocks", + "taiga" => "python-taiga", + "docx" => "python-docx", + // Add new entry here ^ +};