internal.py 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. from ..animations.bars import bar_factory
  2. from ..animations.spinners import alongside_spinner_factory, bouncing_spinner_factory, \
  3. delayed_spinner_factory, frame_spinner_factory, scrolling_spinner_factory, \
  4. sequential_spinner_factory
  5. def _filter(context):
  6. return {k: v for k, v in context.items() if not k.startswith('_')}
  7. def __create_spinners():
  8. classic = frame_spinner_factory(r'-\|/')
  9. stars = scrolling_spinner_factory('*', 4, 1, hide=False)
  10. twirl = frame_spinner_factory('←↖↑↗→↘↓↙')
  11. twirls = delayed_spinner_factory(twirl, 3)
  12. horizontal = frame_spinner_factory('▏▎▍▌▋▊▉█').reshape(1).bounce().reshape(7)
  13. vertical = frame_spinner_factory('▁▂▃▄▅▆▇█').reshape(1).bounce().reshape(7)
  14. waves = delayed_spinner_factory(vertical, 3, 2)
  15. waves2 = delayed_spinner_factory(vertical, 3, 5)
  16. waves3 = delayed_spinner_factory(vertical, 3, 7)
  17. dots = frame_spinner_factory('⠁⠈⠐⠠⢀⡀⠄⠂')
  18. dots_waves = delayed_spinner_factory(dots, 5)
  19. dots_waves2 = delayed_spinner_factory(dots, 5, 2)
  20. _balloon = bouncing_spinner_factory('🎈', 12, background='⠁⠈⠐⠠⢀⡀⠄⠂', overlay=True)
  21. it = sequential_spinner_factory(
  22. _balloon,
  23. _balloon, # makes the balloon twice as common.
  24. bouncing_spinner_factory('🤡', background='⠁⠈⠐⠠⢀⡀⠄⠂', overlay=False),
  25. intermix=False
  26. ).randomize()
  27. ball_belt = bouncing_spinner_factory('●', 8, 0, '< >', hide=False)
  28. balls_belt = bouncing_spinner_factory('●', 8, 1, r'/~\_', hide=False)
  29. triangles = bouncing_spinner_factory(('▶', '◀'), 6, 2, hide=False)
  30. brackets = bouncing_spinner_factory(('>', '<'), 8, 3, hide=False)
  31. bubbles = bouncing_spinner_factory(('∙●⦿', '○'), 10, 5, hide=False)
  32. circles = bouncing_spinner_factory('●', 8, background='○', hide=False)
  33. squares = bouncing_spinner_factory('■', 8, background='□', hide=False)
  34. flowers = bouncing_spinner_factory('💐🌷🌸🌹🌺🌻🌼', 12, (2, 4)).pause(center=6).randomize()
  35. elements = bouncing_spinner_factory(('🔥💨', '🌊⚡️'), 6, 2)
  36. loving = bouncing_spinner_factory(('😍🥰', '⭐️🤩'), 8, (2, 3), '. ', hide=False, overlay=True)
  37. notes = bouncing_spinner_factory(('♩♪', '♫♬'), 8, 2, hide=False).pause(other=2)
  38. notes2 = delayed_spinner_factory(scrolling_spinner_factory('♩♪♫♬'), 3)
  39. arrow = scrolling_spinner_factory('>>----->', 15)
  40. arrows = bouncing_spinner_factory(('→', '←'), 6, 3)
  41. arrows2 = scrolling_spinner_factory('→➜➞➣➤➩➪➮', 5, 2, hide=False)
  42. _arrows_left = scrolling_spinner_factory('.˱·˂°❮', 6, 3, right=False)
  43. _arrows_right = scrolling_spinner_factory('.˲·˃°❯', 6, 3, right=True)
  44. arrows_in = alongside_spinner_factory(_arrows_right, _arrows_left)
  45. arrows_out = alongside_spinner_factory(_arrows_left, _arrows_right)
  46. _core = frame_spinner_factory('∙○⦿●')
  47. radioactive = alongside_spinner_factory(_arrows_left, _core, _arrows_right)
  48. boat = bouncing_spinner_factory((r'*|___/', r'\___|*'), 12, background='_.--.',
  49. hide=False, overlay=True)
  50. fish = scrolling_spinner_factory("><((('>", 15, hide=False)
  51. fish2 = bouncing_spinner_factory(("><('>", "<')><"), 12, hide=False)
  52. _fish_trail = scrolling_spinner_factory('¸.·´¯`·.·´¯`·.¸¸.·´¯`·.><(((º>', 15)
  53. _small_fishes = bouncing_spinner_factory(('><> ><>', '<>< <>< <><'), 15)
  54. fishes = sequential_spinner_factory(_small_fishes, _small_fishes, _fish_trail,
  55. intermix=False).randomize()
  56. crab = bouncing_spinner_factory((r'Y (••) Y', r'Y ( ) Y'), 15, background='⠠⢀⡀⡀⢀⠄⡀⡀',
  57. hide=False, overlay=True) # hey it's Ferris #rustacean!
  58. _look = bouncing_spinner_factory(('Look!', "It's moving!"))
  59. _alive = bouncing_spinner_factory(("It's alive!", "IT'S ALIVE!!"))
  60. alive = sequential_spinner_factory(_look, _alive, intermix=False) # yep, frankenstein...
  61. wait = scrolling_spinner_factory('please wait...', right=False)
  62. wait2 = bouncing_spinner_factory(('please', 'wait'), 15, hide=False).pause()
  63. wait3 = bouncing_spinner_factory(('please', 'wait'), 15).pause(center=8)
  64. wait4 = bouncing_spinner_factory(('processing', 'this is not easy, please hold on'), 15)
  65. pulse = frame_spinner_factory((
  66. r'•––––––––––––', r'•––––––––––––', r'•––––––––––––', r'•––––––––-–––',
  67. r'–•–––––––––––', r'–•–––––––––––', r'–•–––––––––––', r'–•–––––––––––',
  68. r'––•––––––––––', r'––√––––––––––', r'––•––––––––––', r'––•––––––––––',
  69. r'–––•–––––––––', r'––√•–––––––––', r'–––•–––––––––', r'–––•–––––––––',
  70. r'––––•––––––––', r'––√-•––––––––', r'––––√––––––––', r'––––•––––––––',
  71. r'–––––•–––––––', r'––√--•–––––––', r'––––√\–––––––', r'–––––•–––––––',
  72. r'––––––•––––––', r'––√--–•––––––', r'––––√\/––––––', r'––––––•––––––',
  73. r'–––––––•–––––', r'–––--––•–––––', r'––––√\/•–––––', r'–––––––√–––––',
  74. r'––––––––•––––', r'––––-–––•––––', r'––––√\/–•––––', r'–––––––√\––––',
  75. r'–––––––––•–––', r'–––––––––•–––', r'–––––\/––•–––', r'–––––––√\•–––',
  76. r'––––––––––•––', r'––––––––––•––', r'––––––/–––•––', r'–––––––√\-•––',
  77. r'–––––––––––•–', r'–––––––––––•–', r'–––––––––––•–', r'–––––––√\-–•–',
  78. r'––––––––––––•', r'––––––––––––•', r'––––––––––––•', r'––––––––\-––•',
  79. )).reshape(4).transpose().randomize()
  80. return _filter(locals())
  81. def __create_bars():
  82. smooth = bar_factory('▏▎▍▌▋▊▉█')
  83. classic = bar_factory('=', tip='>', borders='[]', errors='!x')
  84. classic2 = bar_factory('#', background='.', borders='[]', errors='!x')
  85. brackets = bar_factory('>')
  86. blocks = bar_factory('▏▎▍▌▋▊▉')
  87. bubbles = bar_factory('∙○⦿●', borders='<>')
  88. solid = bar_factory('∙□☐■', borders='<>')
  89. checks = bar_factory('✓')
  90. circles = bar_factory('●', background='○', borders='<>')
  91. squares = bar_factory('■', background='□', borders='<>')
  92. halloween = bar_factory('🎃', background=' 👻 💀', errors=('😱', '🗡🗡🗡🗡'))
  93. filling = bar_factory('▁▂▃▄▅▆▇█')
  94. notes = bar_factory('♩♪♫♬', errors='♭♯')
  95. ruler = bar_factory(tip='┃', background='∙∙∙∙.')
  96. ruler2 = bar_factory(tip='┃', background='∙∙∙∙+')
  97. fish = bar_factory(tip="><('>", background='¸.·´¯`·.·´¯`·.¸¸.·´¯`·.')
  98. scuba = bar_factory(tip='>=≗)o', background='⠠⢀⡀⡀⢀⠄⡀⡀')
  99. return _filter(locals())
  100. def __create_themes():
  101. smooth = dict(bar='smooth', spinner='waves', unknown='triangles')
  102. classic = dict(bar='classic', spinner='classic', unknown='brackets')
  103. scuba = dict(bar='scuba', spinner='fish2', unknown='fishes') # I love scuba-diving.
  104. musical = dict(bar='notes', spinner='notes', unknown='notes2')
  105. return _filter(locals())
  106. SPINNERS = __create_spinners()
  107. BARS = __create_bars()
  108. THEMES = __create_themes()