You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

59 lines
1.4 KiB

  1. import functools
  2. @functools.lru_cache(maxsize=1024)
  3. def get_first_party_apps():
  4. """Get list of all apps under orgs: frappe. erpnext from GitHub"""
  5. import requests
  6. apps = []
  7. for org in ["frappe", "erpnext"]:
  8. req = requests.get(f"https://api.github.com/users/{org}/repos", {"type": "sources", "per_page": 200})
  9. if req.ok:
  10. apps.extend([x["name"] for x in req.json()])
  11. return apps
  12. def render_table(data):
  13. from terminaltables import AsciiTable
  14. print(AsciiTable(data).table)
  15. def add_line_after(function):
  16. """Adds an extra line to STDOUT after the execution of a function this decorates"""
  17. def empty_line(*args, **kwargs):
  18. result = function(*args, **kwargs)
  19. print()
  20. return result
  21. return empty_line
  22. def add_line_before(function):
  23. """Adds an extra line to STDOUT before the execution of a function this decorates"""
  24. def empty_line(*args, **kwargs):
  25. print()
  26. result = function(*args, **kwargs)
  27. return result
  28. return empty_line
  29. def log(message, colour=''):
  30. """Coloured log outputs to STDOUT"""
  31. colours = {
  32. "nc": '\033[0m',
  33. "blue": '\033[94m',
  34. "green": '\033[92m',
  35. "yellow": '\033[93m',
  36. "red": '\033[91m',
  37. "silver": '\033[90m'
  38. }
  39. colour = colours.get(colour, "")
  40. end_line = '\033[0m'
  41. print(colour + message + end_line)
  42. def warn(message, category=None):
  43. from warnings import warn
  44. warn(message=message, category=category, stacklevel=2)