Skip to content

Instantly share code, notes, and snippets.

@blaggacao
Created June 22, 2019 00:46
Show Gist options
  • Save blaggacao/8ca554b3a217c111f4a3d079c6c58d2f to your computer and use it in GitHub Desktop.
Save blaggacao/8ca554b3a217c111f4a3d079c6c58d2f to your computer and use it in GitHub Desktop.
Repo Magic
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
from requests.exceptions import RequestException
from prompt_toolkit import prompt
from prompt_toolkit.completion import FuzzyWordCompleter
RepoMetaOCA = "https://raw.githubusercontent.com/OCA/maintainer-tools/master/tools/repos_with_ids.txt"
def _oca_parser(req):
res = []
for i in req.iter_lines():
res.append(i.split(b'|')[1].decode())
return res
def repo_lister():
word_list = []
try:
word_list.extend(_oca_parser(requests.get(RepoMetaOCA)))
except RequestException:
pass
return word_list
RepoFuzzyCompleter = FuzzyWordCompleter(repo_lister())
text = prompt('Enter Repo Name: ', completer=RepoFuzzyCompleter, complete_while_typing=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment