Makes beer pouring scalable.
Change-Id: I458fe1b2bb87e52954e33d1da846abc955ca640b Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
This commit is contained in:
parent
83ed3a51b0
commit
de50c64566
12
beers.py
12
beers.py
|
@ -1,3 +1,4 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# not use this file except in compliance with the License. You may obtain
|
# not use this file except in compliance with the License. You may obtain
|
||||||
# a copy of the License at
|
# a copy of the License at
|
||||||
|
@ -10,15 +11,21 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import argparse
|
import argparse
|
||||||
import time
|
import time
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Pour some beers.')
|
parser = argparse.ArgumentParser(description='Pour some beers.')
|
||||||
|
|
||||||
|
|
||||||
parser.add_argument('beers', metavar='beers_to_pour', type=int,
|
parser.add_argument('beers', metavar='beers_to_pour', type=int,
|
||||||
help='how many beers to pour.')
|
help='how many beers to pour.')
|
||||||
|
|
||||||
|
|
||||||
|
parser.add_argument('--scale', metavar='scale', type=int, default=1,
|
||||||
|
help='how many nodes pouring beer.')
|
||||||
|
|
||||||
|
|
||||||
def pour(beers):
|
def pour(beers):
|
||||||
return u"🍺" * beers
|
return u"🍺" * beers
|
||||||
|
|
||||||
|
@ -29,7 +36,7 @@ def main():
|
||||||
print("\nPouring beers...\n")
|
print("\nPouring beers...\n")
|
||||||
|
|
||||||
for beer in pour(args.beers):
|
for beer in pour(args.beers):
|
||||||
time.sleep(.7)
|
time.sleep(.7 / args.scale)
|
||||||
print(beer, end="", flush=True)
|
print(beer, end="", flush=True)
|
||||||
|
|
||||||
time.sleep(.7)
|
time.sleep(.7)
|
||||||
|
@ -37,4 +44,7 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
try:
|
||||||
main()
|
main()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print("\n\nNo Beers for you guys 😢")
|
||||||
|
|
Loading…
Reference in New Issue