(name)
| 65 | |
| 66 | |
| 67 | def find_application(name): |
| 68 | wanted = normalize_text(name) |
| 69 | if not wanted: |
| 70 | return None |
| 71 | if wanted in BLOCKED_APPS or any(word in wanted.split() for word in DANGEROUS_WORDS): |
| 72 | return None |
| 73 | normalized_apps = [(app, normalize_text(app.get("name", ""))) for app in load_application_index()] |
| 74 | for app, app_name in normalized_apps: |
| 75 | if wanted == app_name: |
| 76 | return app |
| 77 | for app, app_name in normalized_apps: |
| 78 | if wanted in app_name.split(): |
| 79 | return app |
| 80 | best = None |
| 81 | best_score = 0 |
| 82 | for app, app_name in normalized_apps: |
| 83 | if not app_name: |
| 84 | continue |
| 85 | if len(wanted) >= 5 and (wanted in app_name or app_name in wanted): |
| 86 | return app |
| 87 | score = SequenceMatcher(None, wanted, app_name).ratio() |
| 88 | if score > best_score: |
| 89 | best = app |
| 90 | best_score = score |
| 91 | return best if best_score >= 0.72 else None |
| 92 | |
| 93 | |
| 94 | def search_apps(query, limit=8): |
no test coverage detected